Graphics

package
v0.0.0-...-6544384 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PositionSize = 2
	ColorSize    = 1
	TexCoordSize = 2
	VertexSize   = PositionSize + ColorSize + TexCoordSize
	Stride       = VertexSize * 4
)

Variables

This section is empty.

Functions

func ColorToHEX

func ColorToHEX(color Color) uint32

func ColorToRGBA

func ColorToRGBA(color Color) (r, g, b, a float32)

Types

type Animation

type Animation struct {
	Frames        []*TextureRegion
	FrameDuration float32
	Loop          bool
}

func NewAnimation

func NewAnimation(frames []*TextureRegion, frameDuration float32, loop bool) *Animation

func (*Animation) GetFrame

func (a *Animation) GetFrame(time float32) *TextureRegion

func (*Animation) IsFinished

func (a *Animation) IsFinished(time float32) bool

type Batch

type Batch struct {
	// contains filtered or unexported fields
}

func NewBatch

func NewBatch(driver *Forge.Driver) *Batch

func (*Batch) Begin

func (batch *Batch) Begin()

func (*Batch) Dispose

func (batch *Batch) Dispose()

func (*Batch) Draw

func (batch *Batch) Draw(texture *Texture, x, y, width, height float32)

func (*Batch) DrawEx

func (batch *Batch) DrawEx(
	texture *Texture, x, y, originX, originY,
	width, height, scaleX, scaleY, rotation float32,
	srcX, srcY, srcWidth, srcHeight int,
	flipX, flipY bool,
)

func (*Batch) DrawRegion

func (batch *Batch) DrawRegion(region *TextureRegion, x, y, width, height float32)

func (*Batch) DrawRegionEx

func (batch *Batch) DrawRegionEx(
	region *TextureRegion, x, y, originX, originY,
	width, height, scaleX, scaleY, rotation float32,
)

func (*Batch) End

func (batch *Batch) End()

func (*Batch) FillQuad

func (batch *Batch) FillQuad(x1, y1, x2, y2, x3, y3, x4, y4 float32, color Color)

func (*Batch) FillQuadEx

func (batch *Batch) FillQuadEx(
	x1, y1 float32, c1 Color,
	x2, y2 float32, c2 Color,
	x3, y3 float32, c3 Color,
	x4, y4 float32, c4 Color,
)

func (*Batch) FillRect

func (batch *Batch) FillRect(x, y, width, height float32, color Color)

func (*Batch) FillRectEx

func (batch *Batch) FillRectEx(x, y, width, height float32, c1, c2, c3, c4 Color)

func (*Batch) Flush

func (batch *Batch) Flush()

func (*Batch) GetColor

func (batch *Batch) GetColor() Color

func (*Batch) Line

func (batch *Batch) Line(x1, y1, x2, y2 float32, color Color, stroke float32)

func (*Batch) LineEx

func (batch *Batch) LineEx(x1, y1 float32, c1 Color, x2, y2 float32, c2 Color, stroke float32)

func (*Batch) LineRect

func (batch *Batch) LineRect(x, y, width, height float32, color Color, stroke float32)

func (*Batch) LineRectEx

func (batch *Batch) LineRectEx(x, y, originX, originY, width, height, scaleX, scaleY, rotation float32, color Color, stroke float32)

func (*Batch) PopTransform

func (batch *Batch) PopTransform()

func (*Batch) Push

func (batch *Batch) Push(
	texture *Texture,
	x1, y1 float32, c1 Color, u1, v1 float32,
	x2, y2 float32, c2 Color, u2, v2 float32,
	x3, y3 float32, c3 Color, u3, v3 float32,
	x4, y4 float32, c4 Color, u4, v4 float32,
)

func (*Batch) PushTransform

func (batch *Batch) PushTransform(transform mgl32.Mat3)

func (*Batch) SetColor

func (batch *Batch) SetColor(color Color)

func (*Batch) SetColorHEX

func (batch *Batch) SetColorHEX(hex uint32)

func (*Batch) SetColorRGBA

func (batch *Batch) SetColorRGBA(r, g, b, a float32)

func (*Batch) SetProjection

func (batch *Batch) SetProjection(projection mgl32.Mat4)

type Camera

type Camera struct {
	Position mgl32.Vec2
	Zoom     float32
	Width    float32
	Height   float32
	Matrix   mgl32.Mat4
	Inverse  mgl32.Mat4
}

func NewCamera

func NewCamera(width, height float32) *Camera

func (*Camera) Project

func (camera *Camera) Project(input mgl32.Vec2, viewportX, viewportY, viewportWidth, viewportHeight float32) mgl32.Vec2

func (*Camera) Resize

func (camera *Camera) Resize(width, height float32)

func (*Camera) Translate

func (camera *Camera) Translate(x, y float32)

func (*Camera) Unproject

func (camera *Camera) Unproject(input mgl32.Vec2, viewportX, viewportY, viewportWidth, viewportHeight float32) mgl32.Vec2

func (*Camera) Update

func (camera *Camera) Update()

type Color

type Color float32
const (
	ColorClear  Color = 0x0.0p0
	ColorBlack  Color = -0x1.0p125
	ColorGray   Color = -0x1.0101p126
	ColorSilver Color = -0x1.6d6d6cp126
	ColorWhite  Color = -0x1.fffffep126
	ColorRed    Color = -0x1.0001fep125
	ColorOrange Color = -0x1.00fffep125
	ColorYellow Color = -0x1.01fffep125
	ColorGreen  Color = -0x1.01fep125
	ColorBlue   Color = -0x1.fep126
)

func ColorFromHEX

func ColorFromHEX(hex uint32) Color

func ColorFromRGBA

func ColorFromRGBA(r, g, b, a float32) Color

type Font

type Font struct {
	// contains filtered or unexported fields
}

func LoadFont

func LoadFont(path string) (*Font, error)

func (*Font) Draw

func (font *Font) Draw(batch *Batch, text string, x, y float32)

func (*Font) DrawEx

func (font *Font) DrawEx(batch *Batch, text string, x, y float32, start, end int, targetWidth float32, hAlign int, wrap bool, truncate string)

func (*Font) MeasureText

func (font *Font) MeasureText(text string) float32

type FrameBuffer

type FrameBuffer struct {
	// contains filtered or unexported fields
}

func NewFrameBuffer

func NewFrameBuffer(width, height int32) (*FrameBuffer, error)

func (*FrameBuffer) Bind

func (frameBuffer *FrameBuffer) Bind()

func (*FrameBuffer) Dispose

func (frameBuffer *FrameBuffer) Dispose()

func (*FrameBuffer) GetColorTexture

func (frameBuffer *FrameBuffer) GetColorTexture() *Texture

func (*FrameBuffer) Unbind

func (frameBuffer *FrameBuffer) Unbind()

type Shader

type Shader struct {
	Program uint32
	// contains filtered or unexported fields
}

func NewShader

func NewShader(vertexSource, fragmentSource string) (*Shader, error)

func (*Shader) Bind

func (s *Shader) Bind()

func (*Shader) Dispose

func (s *Shader) Dispose()

func (*Shader) GetUniformLocation

func (s *Shader) GetUniformLocation(name string) int32

func (*Shader) SetUniform1f

func (s *Shader) SetUniform1f(name string, value float32)

func (*Shader) SetUniform1i

func (s *Shader) SetUniform1i(name string, value int32)

func (*Shader) SetUniformMatrix4fv

func (s *Shader) SetUniformMatrix4fv(name string, value *float32)

func (*Shader) Unbind

func (s *Shader) Unbind()

type Texture

type Texture struct {
	ID     uint32
	Width  int32
	Height int32
}

func NewTexture

func NewTexture(filePath string) (*Texture, error)

func (*Texture) Bind

func (texture *Texture) Bind(unit uint32)

func (*Texture) Dispose

func (texture *Texture) Dispose()

func (*Texture) SetFilter

func (texture *Texture) SetFilter(minFilter, magFilter int32)

func (*Texture) SetWrap

func (texture *Texture) SetWrap(wrapS, wrapT int32)

func (*Texture) Unbind

func (texture *Texture) Unbind()

type TextureRegion

type TextureRegion struct {
	Texture *Texture
	U, V    float32
	U2, V2  float32
	Width   int
	Height  int
}

func NewTextureRegion

func NewTextureRegion(texture *Texture) *TextureRegion

func (*TextureRegion) Flip

func (r *TextureRegion) Flip(flipX, flipY bool)

func (*TextureRegion) SetBounds

func (r *TextureRegion) SetBounds(x, y, width, height int32)

func (*TextureRegion) SetTexture

func (r *TextureRegion) SetTexture(texture *Texture)

func (*TextureRegion) SetUV

func (r *TextureRegion) SetUV(u, v, u2, v2 float32)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL