Documentation
¶
Index ¶
- Variables
- type Backend
- type BlendMode
- type BlurEffect
- type ChromaticAberration
- type ColorGradeEffect
- type CustomEffect
- type DrawCall
- type Driver
- type Effect
- type Font
- type Framebuffer
- type GLSLSource
- type GPUCanvas
- func (c *GPUCanvas) ApplyEffect(effect Effect)
- func (c *GPUCanvas) Begin()
- func (c *GPUCanvas) BeginPath()
- func (c *GPUCanvas) BezierTo(c1x, c1y, c2x, c2y, x, y float32)
- func (c *GPUCanvas) Clear(col color.RGBA)
- func (c *GPUCanvas) ClosePath()
- func (c *GPUCanvas) Dispose()
- func (c *GPUCanvas) DrawImage(img Texture, x, y float32)
- func (c *GPUCanvas) DrawImageScaled(img Texture, x, y, w, h float32)
- func (c *GPUCanvas) DrawLine(x1, y1, x2, y2 float32)
- func (c *GPUCanvas) DrawText(text string, x, y float32, font *Font)
- func (c *GPUCanvas) End() []byte
- func (c *GPUCanvas) EndToTexture() Texture
- func (c *GPUCanvas) Fill()
- func (c *GPUCanvas) FillCircle(cx, cy, r float32)
- func (c *GPUCanvas) FillRect(x, y, w, h float32)
- func (c *GPUCanvas) FillRoundedRect(x, y, w, h, radius float32)
- func (c *GPUCanvas) LineTo(x, y float32)
- func (c *GPUCanvas) MoveTo(x, y float32)
- func (c *GPUCanvas) PopLayer(effects ...Effect)
- func (c *GPUCanvas) PushLayer()
- func (c *GPUCanvas) QuadraticTo(cx, cy, x, y float32)
- func (c *GPUCanvas) Resize(width, height int) error
- func (c *GPUCanvas) Restore()
- func (c *GPUCanvas) Rotate(radians float32)
- func (c *GPUCanvas) Save()
- func (c *GPUCanvas) Scale(x, y float32)
- func (c *GPUCanvas) SetFillColor(col color.RGBA)
- func (c *GPUCanvas) SetStrokeColor(col color.RGBA)
- func (c *GPUCanvas) SetStrokeWidth(w float32)
- func (c *GPUCanvas) Size() (int, int)
- func (c *GPUCanvas) Stroke()
- func (c *GPUCanvas) StrokeCircle(cx, cy, r float32)
- func (c *GPUCanvas) StrokeRect(x, y, w, h float32)
- func (c *GPUCanvas) Translate(x, y float32)
- type GlowEffect
- type Matrix3
- type PixelFont
- type PixelateEffect
- type Shader
- type ShaderSource
- type ShadowEffect
- type Texture
- type VertexAttrib
- type VertexLayout
- type VignetteEffect
Constants ¶
This section is empty.
Variables ¶
var DefaultPixelFont = &PixelFont{ Width: 3, Height: 5, Spacing: 1, Glyphs: map[rune][]string{ ' ': {"...", "...", "...", "...", "..."}, '0': {"###", "#.#", "#.#", "#.#", "###"}, '1': {".#.", "##.", ".#.", ".#.", "###"}, '2': {"###", "..#", "###", "#..", "###"}, '3': {"###", "..#", "###", "..#", "###"}, '4': {"#.#", "#.#", "###", "..#", "..#"}, '5': {"###", "#..", "###", "..#", "###"}, '6': {"###", "#..", "###", "#.#", "###"}, '7': {"###", "..#", "..#", "..#", "..#"}, '8': {"###", "#.#", "###", "#.#", "###"}, '9': {"###", "#.#", "###", "..#", "###"}, 'A': {".#.", "#.#", "###", "#.#", "#.#"}, 'B': {"##.", "#.#", "##.", "#.#", "##."}, 'C': {".##", "#..", "#..", "#..", ".##"}, 'D': {"##.", "#.#", "#.#", "#.#", "##."}, 'E': {"###", "#..", "##.", "#..", "###"}, 'F': {"###", "#..", "##.", "#..", "#.."}, 'G': {".##", "#..", "#.#", "#.#", ".##"}, 'H': {"#.#", "#.#", "###", "#.#", "#.#"}, 'I': {"###", ".#.", ".#.", ".#.", "###"}, 'J': {"..#", "..#", "..#", "#.#", ".#."}, 'K': {"#.#", "##.", "#..", "##.", "#.#"}, 'L': {"#..", "#..", "#..", "#..", "###"}, 'M': {"#.#", "###", "###", "#.#", "#.#"}, 'N': {"#.#", "##.", "#.#", ".##", "#.#"}, 'O': {".#.", "#.#", "#.#", "#.#", ".#."}, 'P': {"##.", "#.#", "##.", "#..", "#.."}, 'Q': {".#.", "#.#", "#.#", ".##", "..#"}, 'R': {"##.", "#.#", "##.", "#.#", "#.#"}, 'S': {".##", "#..", ".#.", "..#", "##."}, 'T': {"###", ".#.", ".#.", ".#.", ".#."}, 'U': {"#.#", "#.#", "#.#", "#.#", "###"}, 'V': {"#.#", "#.#", "#.#", "#.#", ".#."}, 'W': {"#.#", "#.#", "###", "###", "#.#"}, 'X': {"#.#", "#.#", ".#.", "#.#", "#.#"}, 'Y': {"#.#", "#.#", ".#.", ".#.", ".#."}, 'Z': {"###", "..#", ".#.", "#..", "###"}, '.': {"...", "...", "...", "...", ".#."}, '-': {"...", "...", "###", "...", "..."}, ':': {"...", ".#.", "...", ".#.", "..."}, '!': {".#.", ".#.", ".#.", "...", ".#."}, '?': {"###", "..#", ".#.", "...", ".#."}, '+': {"...", ".#.", "###", ".#.", "..."}, '/': {"..#", ".#.", "#..", "...", "..."}, '"': {"#.#", "#.#", "...", "...", "..."}, '\'': {".#.", ".#.", "...", "...", "..."}, '_': {"...", "...", "...", "...", "###"}, }, }
DefaultPixelFont is a compact 3x5 pixel font.
var ErrUnsupported = errors.New("gpu backend unsupported")
ErrUnsupported is returned when a backend is unavailable.
Functions ¶
This section is empty.
Types ¶
type BlendMode ¶
type BlendMode int
BlendMode controls how source pixels blend with the destination.
type BlurEffect ¶
type BlurEffect struct {
Radius float32
}
BlurEffect applies a box blur.
func (BlurEffect) Apply ¶
func (e BlurEffect) Apply(src Texture, dst Framebuffer, driver Driver)
type ChromaticAberration ¶
type ChromaticAberration struct {
Amount float32
}
ChromaticAberration offsets color channels.
func (ChromaticAberration) Apply ¶
func (e ChromaticAberration) Apply(src Texture, dst Framebuffer, driver Driver)
type ColorGradeEffect ¶
ColorGradeEffect adjusts color properties.
func (ColorGradeEffect) Apply ¶
func (e ColorGradeEffect) Apply(src Texture, dst Framebuffer, driver Driver)
type CustomEffect ¶
CustomEffect applies a custom shader.
func (CustomEffect) Apply ¶
func (e CustomEffect) Apply(src Texture, dst Framebuffer, driver Driver)
type DrawCall ¶
type DrawCall struct {
Shader Shader
Vertices []float32
Indices []uint16
Textures []Texture
Target Framebuffer
Blend BlendMode
Scissor *image.Rectangle
Layout *VertexLayout
}
DrawCall describes a batched draw operation.
type Driver ¶
type Driver interface {
Backend() Backend
Init() error
Dispose()
NewTexture(width, height int) (Texture, error)
NewFramebuffer(width, height int) (Framebuffer, error)
NewShader(src ShaderSource) (Shader, error)
Clear(r, g, b, a float32)
Draw(call DrawCall)
ReadPixels(fb Framebuffer, rect image.Rectangle) ([]byte, error)
MaxTextureSize() int
}
Driver provides low-level rendering operations.
type Effect ¶
type Effect interface {
Apply(src Texture, dst Framebuffer, driver Driver)
}
Effect applies a post-processing operation.
type Framebuffer ¶
Framebuffer represents a render target.
type GLSLSource ¶
GLSLSource contains vertex and fragment shader source.
type GPUCanvas ¶
type GPUCanvas struct {
// contains filtered or unexported fields
}
GPUCanvas renders into an offscreen RGBA buffer.
func NewGPUCanvas ¶
NewGPUCanvas creates a new GPU canvas.
func NewGPUCanvasWithDriver ¶
NewGPUCanvasWithDriver creates a canvas with a provided driver.
func (*GPUCanvas) ApplyEffect ¶
ApplyEffect applies a post-processing effect.
func (*GPUCanvas) DrawImageScaled ¶
DrawImageScaled draws a texture scaled to the given size.
func (*GPUCanvas) EndToTexture ¶
EndToTexture captures the current frame into a texture.
func (*GPUCanvas) FillCircle ¶
FillCircle fills a circle.
func (*GPUCanvas) FillRoundedRect ¶
FillRoundedRect fills a rounded rectangle.
func (*GPUCanvas) QuadraticTo ¶
QuadraticTo adds a quadratic curve.
func (*GPUCanvas) SetFillColor ¶
SetFillColor sets the fill color.
func (*GPUCanvas) SetStrokeColor ¶
SetStrokeColor sets the stroke color.
func (*GPUCanvas) SetStrokeWidth ¶
SetStrokeWidth sets the stroke width.
func (*GPUCanvas) StrokeCircle ¶
StrokeCircle draws a circle outline.
func (*GPUCanvas) StrokeRect ¶
StrokeRect draws a rectangle outline.
type GlowEffect ¶
GlowEffect applies a colored glow.
func (GlowEffect) Apply ¶
func (e GlowEffect) Apply(src Texture, dst Framebuffer, driver Driver)
type Matrix3 ¶
type Matrix3 struct {
// contains filtered or unexported fields
}
Matrix3 is a 3x3 matrix for 2D transforms.
func (Matrix3) IsIdentity ¶
IsIdentity reports whether the matrix is the identity.
type PixelateEffect ¶
type PixelateEffect struct {
PixelSize float32
}
PixelateEffect reduces resolution.
func (PixelateEffect) Apply ¶
func (e PixelateEffect) Apply(src Texture, dst Framebuffer, driver Driver)
type ShaderSource ¶
type ShaderSource struct {
GLSL GLSLSource
Metal string
}
ShaderSource contains shader source for multiple backends.
func LoadShaderSource ¶
func LoadShaderSource(name string) (ShaderSource, error)
LoadShaderSource loads embedded shader source by name (e.g. "solid" or "solid.glsl").
type ShadowEffect ¶
ShadowEffect applies a drop shadow.
func (ShadowEffect) Apply ¶
func (e ShadowEffect) Apply(src Texture, dst Framebuffer, driver Driver)
type Texture ¶
type Texture interface {
ID() uint32
Size() (w, h int)
Upload(pixels []byte, region image.Rectangle)
Dispose()
}
Texture represents a GPU texture resource.
type VertexAttrib ¶
type VertexAttrib struct {
Index uint32
Size int32
Type uint32
Normalized bool
Stride int
Offset int
}
VertexAttrib defines a single vertex attribute.
type VertexLayout ¶
type VertexLayout struct {
Stride int
Attributes []VertexAttrib
}
VertexLayout describes vertex attribute layout in bytes.
type VignetteEffect ¶
VignetteEffect darkens edges.
func (VignetteEffect) Apply ¶
func (e VignetteEffect) Apply(src Texture, dst Framebuffer, driver Driver)
Source Files
¶
- batch.go
- canvas.go
- canvas_gpu.go
- canvas_native.go
- driver.go
- driver_stub.go
- effects.go
- effects_gpu.go
- font.go
- matrix.go
- metal_driver_stub.go
- opengl_context_osmesa.go
- opengl_driver.go
- opengl_layout.go
- opengl_types.go
- opengl_uniforms.go
- opengl_worker.go
- path.go
- pipeline.go
- pixels.go
- shader_sources.go
- software.go
- types.go
- webgl_driver_stub.go