Documentation
¶
Overview ¶
Package gg provides a simple 2D graphics library for Go.
Overview ¶
gg is a Pure Go 2D graphics library inspired by fogleman/gg and designed to integrate with the GoGPU ecosystem. It provides an immediate-mode drawing API similar to HTML Canvas, with both software and GPU rendering backends.
Quick Start ¶
import "github.com/gogpu/gg"
// Create a context
ctx := gg.NewContext(512, 512)
// Draw shapes
ctx.SetRGB(1, 0, 0)
ctx.DrawCircle(256, 256, 100)
ctx.Fill()
// Save to PNG
ctx.SavePNG("output.png")
API Compatibility ¶
The API is designed to be compatible with fogleman/gg for easy migration. Most fogleman/gg code should work with minimal changes.
Renderers ¶
v0.1.0 includes a software rasterizer for immediate usability. Future versions will add GPU-accelerated rendering via gogpu/wgpu.
Architecture ¶
The library is organized into:
- Public API: Context, Path, Paint, Matrix, Point
- Internal: raster (scanline), path (tessellation), blend (compositing)
- Renderers: software (v0.1), gpu (v0.3+)
Coordinate System ¶
Uses standard computer graphics coordinates:
- Origin (0,0) at top-left
- X increases right
- Y increases down
- Angles in radians, 0 is right, increases counter-clockwise
Performance ¶
The software renderer is optimized for correctness over speed. For performance-critical applications, use the GPU renderer (v0.3+).
Index ¶
- Constants
- Variables
- type BlendMode
- type Close
- type Context
- func (c *Context) Clear()
- func (c *Context) ClearPath()
- func (c *Context) ClearWithColor(col RGBA)
- func (c *Context) Clip()
- func (c *Context) ClipPreserve()
- func (c *Context) ClipRect(x, y, w, h float64)
- func (c *Context) ClosePath()
- func (c *Context) CreateImagePattern(img *ImageBuf, x, y, w, h int) Pattern
- func (c *Context) CubicTo(c1x, c1y, c2x, c2y, x, y float64)
- func (c *Context) DrawArc(x, y, r, angle1, angle2 float64)
- func (c *Context) DrawCircle(x, y, r float64)
- func (c *Context) DrawEllipse(x, y, rx, ry float64)
- func (c *Context) DrawEllipticalArc(x, y, rx, ry, angle1, angle2 float64)
- func (c *Context) DrawImage(img *ImageBuf, x, y float64)
- func (c *Context) DrawImageEx(img *ImageBuf, opts DrawImageOptions)
- func (c *Context) DrawLine(x1, y1, x2, y2 float64)
- func (c *Context) DrawPoint(x, y, r float64)
- func (c *Context) DrawRectangle(x, y, w, h float64)
- func (c *Context) DrawRegularPolygon(n int, x, y, r, rotation float64)
- func (c *Context) DrawRoundedRectangle(x, y, w, h, r float64)
- func (c *Context) DrawString(s string, x, y float64)
- func (c *Context) DrawStringAnchored(s string, x, y, ax, ay float64)
- func (c *Context) Fill()
- func (c *Context) FillPreserve()
- func (c *Context) Font() text.Face
- func (c *Context) Height() int
- func (c *Context) Identity()
- func (c *Context) Image() image.Image
- func (c *Context) InvertY()
- func (c *Context) LineTo(x, y float64)
- func (c *Context) LoadFontFace(path string, points float64) errordeprecated
- func (c *Context) MeasureString(s string) (w, h float64)
- func (c *Context) MoveTo(x, y float64)
- func (c *Context) NewSubPath()
- func (c *Context) Pop()
- func (c *Context) PopLayer()
- func (c *Context) Push()
- func (c *Context) PushLayer(blendMode BlendMode, opacity float64)
- func (c *Context) QuadraticTo(cx, cy, x, y float64)
- func (c *Context) ResetClip()
- func (c *Context) Rotate(angle float64)
- func (c *Context) RotateAbout(angle, x, y float64)
- func (c *Context) SavePNG(path string) error
- func (c *Context) Scale(x, y float64)
- func (c *Context) SetBlendMode(_ BlendMode)
- func (c *Context) SetColor(col color.Color)
- func (c *Context) SetFillPattern(pattern Pattern)
- func (c *Context) SetFillRule(rule FillRule)
- func (c *Context) SetFont(face text.Face)
- func (c *Context) SetHexColor(hex string)
- func (c *Context) SetLineCap(lineCap LineCap)
- func (c *Context) SetLineJoin(join LineJoin)
- func (c *Context) SetLineWidth(width float64)
- func (c *Context) SetPixel(x, y int, col RGBA)
- func (c *Context) SetRGB(r, g, b float64)
- func (c *Context) SetRGBA(r, g, b, a float64)
- func (c *Context) SetStrokePattern(pattern Pattern)
- func (c *Context) Shear(x, y float64)
- func (c *Context) Stroke()
- func (c *Context) StrokePreserve()
- func (c *Context) TransformPoint(x, y float64) (float64, float64)
- func (c *Context) Translate(x, y float64)
- func (c *Context) Width() int
- type CubicTo
- type DrawImageOptions
- type FillRule
- type ImageBuf
- type ImageFormat
- type ImagePattern
- type InterpolationMode
- type Layer
- type LineCap
- type LineJoin
- type LineTo
- type Matrix
- type MoveTo
- type Paint
- type Path
- func (p *Path) Arc(cx, cy, r, angle1, angle2 float64)
- func (p *Path) Circle(cx, cy, r float64)
- func (p *Path) Clear()
- func (p *Path) Close()
- func (p *Path) CubicTo(c1x, c1y, c2x, c2y, x, y float64)
- func (p *Path) CurrentPoint() Point
- func (p *Path) Elements() []PathElement
- func (p *Path) Ellipse(cx, cy, rx, ry float64)
- func (p *Path) LineTo(x, y float64)
- func (p *Path) MoveTo(x, y float64)
- func (p *Path) QuadraticTo(cx, cy, x, y float64)
- func (p *Path) Rectangle(x, y, w, h float64)
- func (p *Path) RoundedRectangle(x, y, w, h, r float64)
- func (p *Path) Transform(m Matrix) *Path
- type PathElement
- type Pattern
- type Pixmap
- func (p *Pixmap) At(x, y int) color.Color
- func (p *Pixmap) Bounds() image.Rectangle
- func (p *Pixmap) Clear(c RGBA)
- func (p *Pixmap) ColorModel() color.Model
- func (p *Pixmap) Data() []uint8
- func (p *Pixmap) FillSpan(x1, x2, y int, c RGBA)
- func (p *Pixmap) FillSpanBlend(x1, x2, y int, c RGBA)
- func (p *Pixmap) GetPixel(x, y int) RGBA
- func (p *Pixmap) Height() int
- func (p *Pixmap) SavePNG(path string) error
- func (p *Pixmap) SetPixel(x, y int, c RGBA)
- func (p *Pixmap) ToImage() *image.RGBA
- func (p *Pixmap) Width() int
- type Point
- func (p Point) Add(q Point) Point
- func (p Point) Cross(q Point) float64
- func (p Point) Distance(q Point) float64
- func (p Point) Div(s float64) Point
- func (p Point) Dot(q Point) float64
- func (p Point) Length() float64
- func (p Point) LengthSquared() float64
- func (p Point) Lerp(q Point, t float64) Point
- func (p Point) Mul(s float64) Point
- func (p Point) Normalize() Point
- func (p Point) Rotate(angle float64) Point
- func (p Point) Sub(q Point) Point
- type QuadTo
- type RGBA
- type Renderer
- type SoftwareRenderer
- type SolidPattern
Constants ¶
const ( // InterpNearest selects the closest pixel (no interpolation). // Fast but produces blocky results when scaling. InterpNearest = intImage.InterpNearest // InterpBilinear performs linear interpolation between 4 neighboring pixels. // Good balance between quality and performance. InterpBilinear = intImage.InterpBilinear // InterpBicubic performs cubic interpolation using a 4x4 pixel neighborhood. // Highest quality but slower than bilinear. InterpBicubic = intImage.InterpBicubic )
Image interpolation modes.
const ( // FormatGray8 is 8-bit grayscale (1 byte per pixel). FormatGray8 = intImage.FormatGray8 // FormatGray16 is 16-bit grayscale (2 bytes per pixel). FormatGray16 = intImage.FormatGray16 // FormatRGB8 is 24-bit RGB (3 bytes per pixel, no alpha). FormatRGB8 = intImage.FormatRGB8 // FormatRGBA8 is 32-bit RGBA in sRGB color space (4 bytes per pixel). // This is the standard format for most operations. FormatRGBA8 = intImage.FormatRGBA8 // FormatRGBAPremul is 32-bit RGBA with premultiplied alpha (4 bytes per pixel). // Used for correct alpha blending operations. FormatRGBAPremul = intImage.FormatRGBAPremul // FormatBGRA8 is 32-bit BGRA in sRGB color space (4 bytes per pixel). // Common on Windows and some GPU formats. FormatBGRA8 = intImage.FormatBGRA8 // FormatBGRAPremul is 32-bit BGRA with premultiplied alpha (4 bytes per pixel). FormatBGRAPremul = intImage.FormatBGRAPremul )
Pixel formats.
const ( // BlendNormal performs standard alpha blending (source over destination). BlendNormal = intImage.BlendNormal // BlendMultiply multiplies source and destination colors. // Result is always darker or equal. Formula: dst * src BlendMultiply = intImage.BlendMultiply // BlendScreen performs inverse multiply for lighter results. // Formula: 1 - (1-dst) * (1-src) BlendScreen = intImage.BlendScreen // BlendOverlay combines multiply and screen based on destination brightness. // Dark areas are multiplied, bright areas are screened. BlendOverlay = intImage.BlendOverlay )
Blend modes.
const ( // Version is the current version of the library Version = "0.1.0-alpha.1" // VersionMajor is the major version VersionMajor = 0 // VersionMinor is the minor version VersionMinor = 1 // VersionPatch is the patch version VersionPatch = 0 // VersionPrerelease is the prerelease identifier VersionPrerelease = "alpha.1" )
Version information
Variables ¶
var ( Black = RGB(0, 0, 0) White = RGB(1, 1, 1) Red = RGB(1, 0, 0) Green = RGB(0, 1, 0) Blue = RGB(0, 0, 1) Yellow = RGB(1, 1, 0) Cyan = RGB(0, 1, 1) Magenta = RGB(1, 0, 1) Transparent = RGBA2(0, 0, 0, 0) )
Common colors
Functions ¶
This section is empty.
Types ¶
type BlendMode ¶ added in v0.3.0
BlendMode defines how source pixels are blended with destination pixels.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is the main drawing context. It maintains a pixmap, current path, paint state, and transformation stack.
func NewContext ¶
NewContext creates a new drawing context with the given dimensions.
func NewContextForImage ¶
NewContextForImage creates a context for drawing on an existing image.
func (*Context) ClearWithColor ¶
ClearWithColor fills the entire context with a specific color.
func (*Context) Clip ¶ added in v0.3.0
func (c *Context) Clip()
Clip sets the current path as the clipping region and clears the path. Subsequent drawing operations will be clipped to this region. The clip region is intersected with any existing clip regions.
func (*Context) ClipPreserve ¶ added in v0.3.0
func (c *Context) ClipPreserve()
ClipPreserve sets the current path as the clipping region but keeps the path. This is like Clip() but doesn't clear the path, allowing you to both clip and then fill/stroke the same path.
func (*Context) ClipRect ¶ added in v0.3.0
ClipRect sets a rectangular clipping region. This is a faster alternative to creating a rectangular path and calling Clip(). The clip region is intersected with any existing clip regions.
func (*Context) CreateImagePattern ¶ added in v0.3.0
CreateImagePattern creates an image pattern from a rectangular region of an image. The pattern can be used with SetFillPattern or SetStrokePattern.
Example:
img, _ := gg.LoadImage("texture.png")
pattern := dc.CreateImagePattern(img, 0, 0, 100, 100)
dc.SetFillPattern(pattern)
dc.DrawRectangle(0, 0, 400, 300)
dc.Fill()
func (*Context) DrawCircle ¶
DrawCircle draws a circle.
func (*Context) DrawEllipse ¶
DrawEllipse draws an ellipse.
func (*Context) DrawEllipticalArc ¶
DrawEllipticalArc draws an elliptical arc (advanced).
func (*Context) DrawImage ¶ added in v0.3.0
DrawImage draws an image at the specified position. The current transformation matrix is applied to the position and size.
Example:
img, _ := gg.LoadImage("photo.png")
dc.DrawImage(img, 100, 100)
func (*Context) DrawImageEx ¶ added in v0.3.0
func (c *Context) DrawImageEx(img *ImageBuf, opts DrawImageOptions)
DrawImageEx draws an image with advanced options. The current transformation matrix is applied to the position and size.
Example:
dc.DrawImageEx(img, gg.DrawImageOptions{
X: 100,
Y: 100,
DstWidth: 200,
DstHeight: 150,
Interpolation: gg.InterpBicubic,
Opacity: 0.8,
BlendMode: gg.BlendNormal,
})
func (*Context) DrawRectangle ¶
DrawRectangle draws a rectangle.
func (*Context) DrawRegularPolygon ¶
DrawRegularPolygon draws a regular polygon with n sides.
func (*Context) DrawRoundedRectangle ¶
DrawRoundedRectangle draws a rectangle with rounded corners.
func (*Context) DrawString ¶
DrawString draws text at position (x, y) where y is the baseline. If no font has been set with SetFont, this function does nothing.
The baseline is the line on which most letters sit. Characters with descenders (like 'g', 'j', 'p', 'q', 'y') extend below the baseline.
func (*Context) DrawStringAnchored ¶
DrawStringAnchored draws text with an anchor point. The anchor point is specified by ax and ay, which are in the range [0, 1].
(0, 0) = top-left (0.5, 0.5) = center (1, 1) = bottom-right
The text is positioned so that the anchor point is at (x, y).
func (*Context) FillPreserve ¶
func (c *Context) FillPreserve()
FillPreserve fills the current path and preserves it for additional operations.
func (*Context) Font ¶ added in v0.2.0
Font returns the current font face. Returns nil if no font has been set.
func (*Context) Identity ¶
func (c *Context) Identity()
Identity resets the transformation matrix to identity.
func (*Context) InvertY ¶
func (c *Context) InvertY()
InvertY inverts the Y axis (useful for coordinate system changes).
func (*Context) LoadFontFace
deprecated
LoadFontFace loads a font from a file and sets it as the current font. The size is specified in points.
Deprecated: Use text.NewFontSourceFromFile and SetFont instead. This method is provided for convenience and backward compatibility.
Example (new way):
source, err := text.NewFontSourceFromFile("font.ttf")
if err != nil {
return err
}
face := source.Face(12.0)
ctx.SetFont(face)
func (*Context) MeasureString ¶
MeasureString returns the dimensions of text in pixels. Returns (width, height) where:
- width is the horizontal advance of the text
- height is the line height (ascent + descent + line gap)
If no font has been set, returns (0, 0).
func (*Context) NewSubPath ¶
func (c *Context) NewSubPath()
NewSubPath starts a new subpath without closing the previous one.
func (*Context) PopLayer ¶ added in v0.4.0
func (c *Context) PopLayer()
PopLayer composites the current layer onto the parent layer/canvas. Uses the blend mode and opacity specified in the corresponding PushLayer call.
The layer is composited using the specified blend mode and opacity. After compositing, the layer's memory is returned to the pool for reuse.
If there are no layers to pop, this function does nothing.
Example:
dc.PushLayer(gg.BlendScreen, 1.0) // ... draw operations ... dc.PopLayer() // Composite layer onto parent
func (*Context) Push ¶
func (c *Context) Push()
Push saves the current state (transform, paint, and clip).
func (*Context) PushLayer ¶ added in v0.4.0
PushLayer creates a new layer and makes it the active drawing target. All subsequent drawing operations will render to this layer until PopLayer is called.
The layer will be composited onto the parent layer/canvas when PopLayer is called, using the specified blend mode and opacity.
Parameters:
- blendMode: How to composite this layer onto the parent (e.g., BlendMultiply, BlendScreen)
- opacity: Layer opacity in range [0.0, 1.0] where 0 is fully transparent and 1 is fully opaque
Example:
dc.PushLayer(gg.BlendMultiply, 0.5) dc.SetRGB(1, 0, 0) dc.DrawCircle(100, 100, 50) dc.Fill() dc.PopLayer() // Composite circle onto canvas with multiply blend at 50% opacity
func (*Context) QuadraticTo ¶
QuadraticTo adds a quadratic Bezier curve to the current path.
func (*Context) ResetClip ¶ added in v0.3.0
func (c *Context) ResetClip()
ResetClip removes all clipping regions, restoring the full canvas as drawable.
func (*Context) RotateAbout ¶
RotateAbout rotates around a specific point.
func (*Context) SetBlendMode ¶ added in v0.4.0
SetBlendMode sets the blend mode for subsequent fill and stroke operations. This is currently a placeholder for future blend mode support in direct drawing operations.
For now, blend modes are primarily used with layers via PushLayer/PopLayer.
Example:
dc.SetBlendMode(gg.BlendMultiply) dc.Fill() // Future: will use multiply blend mode
func (*Context) SetFillPattern ¶ added in v0.3.0
SetFillPattern sets the fill pattern.
func (*Context) SetFillRule ¶
SetFillRule sets the fill rule.
func (*Context) SetFont ¶ added in v0.2.0
SetFont sets the current font face for text drawing. The face should be created from a FontSource.
Example:
source, _ := text.NewFontSourceFromFile("font.ttf")
face := source.Face(12.0)
ctx.SetFont(face)
func (*Context) SetHexColor ¶
SetHexColor sets the current color using a hex string.
func (*Context) SetLineCap ¶
SetLineCap sets the line cap style.
func (*Context) SetLineJoin ¶
SetLineJoin sets the line join style.
func (*Context) SetLineWidth ¶
SetLineWidth sets the line width for stroking.
func (*Context) SetStrokePattern ¶ added in v0.3.0
SetStrokePattern sets the stroke pattern.
func (*Context) StrokePreserve ¶
func (c *Context) StrokePreserve()
StrokePreserve strokes the current path and preserves it.
func (*Context) TransformPoint ¶
TransformPoint transforms a point by the current matrix.
type DrawImageOptions ¶ added in v0.3.0
type DrawImageOptions struct {
// X, Y specify the top-left corner where the image will be drawn.
X, Y float64
// DstWidth and DstHeight specify the dimensions to scale the image to.
// If zero, the source dimensions are used (possibly from SrcRect).
DstWidth float64
DstHeight float64
// SrcRect defines the source rectangle to sample from.
// If nil, the entire source image is used.
SrcRect *image.Rectangle
// Interpolation specifies the interpolation mode for sampling.
// Default is InterpBilinear.
Interpolation InterpolationMode
// Opacity controls the overall transparency of the source image (0.0 to 1.0).
// 1.0 means fully opaque, 0.0 means fully transparent.
// Default is 1.0.
Opacity float64
// BlendMode specifies how to blend source and destination pixels.
// Default is BlendNormal.
BlendMode BlendMode
}
DrawImageOptions specifies parameters for drawing an image.
type FillRule ¶
type FillRule int
FillRule specifies how to determine which areas are inside a path.
type ImageBuf ¶ added in v0.3.0
ImageBuf is a public alias for internal ImageBuf. It represents a memory-efficient image buffer with support for multiple pixel formats and lazy premultiplication.
func ImageBufFromImage ¶ added in v0.3.0
ImageBufFromImage creates an ImageBuf from a standard image.Image.
func LoadImage ¶ added in v0.3.0
LoadImage loads an image from a file and returns an ImageBuf. Supported formats: PNG, JPEG, GIF.
func NewImageBuf ¶ added in v0.3.0
func NewImageBuf(width, height int, format ImageFormat) (*ImageBuf, error)
NewImageBuf creates a new image buffer with the given dimensions and format.
type ImageFormat ¶ added in v0.3.0
ImageFormat represents a pixel storage format.
type ImagePattern ¶ added in v0.3.0
type ImagePattern struct {
// contains filtered or unexported fields
}
ImagePattern represents an image-based pattern.
func (*ImagePattern) ColorAt ¶ added in v0.3.0
func (p *ImagePattern) ColorAt(x, y float64) RGBA
ColorAt implements the Pattern interface. It samples the image at the given coordinates using wrapping/tiling behavior.
type InterpolationMode ¶ added in v0.3.0
type InterpolationMode = intImage.InterpolationMode
InterpolationMode defines how texture sampling is performed when drawing images.
type Layer ¶ added in v0.4.0
type Layer struct {
// contains filtered or unexported fields
}
Layer represents a drawing layer with blend mode and opacity. Layers allow isolating drawing operations and compositing them with different blend modes and opacity values, similar to layers in Photoshop or SVG group opacity.
type Matrix ¶
Matrix represents a 2D affine transformation matrix. It uses a 2x3 matrix in row-major order:
| a b c | | d e f |
This represents the transformation:
x' = a*x + b*y + c y' = d*x + e*y + f
func (Matrix) Invert ¶
Invert returns the inverse matrix. Returns the identity matrix if the matrix is not invertible.
func (Matrix) IsIdentity ¶
IsIdentity returns true if the matrix is the identity matrix.
func (Matrix) IsTranslation ¶
IsTranslation returns true if the matrix is only a translation.
func (Matrix) TransformPoint ¶
TransformPoint applies the transformation to a point.
func (Matrix) TransformVector ¶
TransformVector applies the transformation to a vector (no translation).
type Paint ¶
type Paint struct {
// Pattern is the fill or stroke pattern
Pattern Pattern
// LineWidth is the width of strokes
LineWidth float64
// LineCap is the shape of line endpoints
LineCap LineCap
// LineJoin is the shape of line joins
LineJoin LineJoin
// MiterLimit is the miter limit for sharp joins
MiterLimit float64
// FillRule is the fill rule for paths
FillRule FillRule
// Antialias enables anti-aliasing
Antialias bool
}
Paint represents the styling information for drawing.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path represents a vector path.
func (*Path) Arc ¶
Arc adds a circular arc to the path. The arc is drawn from angle1 to angle2 (in radians) around center (cx, cy).
func (*Path) Close ¶
func (p *Path) Close()
Close closes the current subpath by drawing a line to the start point.
func (*Path) CurrentPoint ¶
CurrentPoint returns the current point.
func (*Path) QuadraticTo ¶
QuadraticTo draws a quadratic Bezier curve.
func (*Path) RoundedRectangle ¶
RoundedRectangle adds a rectangle with rounded corners.
type PathElement ¶
type PathElement interface {
// contains filtered or unexported methods
}
PathElement represents a single element in a path.
type Pattern ¶
type Pattern interface {
// ColorAt returns the color at the given point.
ColorAt(x, y float64) RGBA
}
Pattern represents a fill or stroke pattern.
type Pixmap ¶
type Pixmap struct {
// contains filtered or unexported fields
}
Pixmap represents a rectangular pixel buffer.
func (*Pixmap) ColorModel ¶
ColorModel implements the image.Image interface.
func (*Pixmap) FillSpan ¶ added in v0.5.0
FillSpan fills a horizontal span of pixels with a solid color (no blending). This is optimized for batch operations when the span is >= 16 pixels. The span is from x1 (inclusive) to x2 (exclusive) on row y.
func (*Pixmap) FillSpanBlend ¶ added in v0.5.0
FillSpanBlend fills a horizontal span with blending. This uses batch blending operations for spans >= 16 pixels.
type Point ¶
type Point struct {
X, Y float64
}
Point represents a 2D point or vector.
func (Point) LengthSquared ¶
LengthSquared returns the squared length of the vector.
func (Point) Lerp ¶
Lerp performs linear interpolation between two points. t=0 returns p, t=1 returns q, intermediate values interpolate.
type RGBA ¶
type RGBA struct {
R, G, B, A float64
}
RGBA represents a color with red, green, blue, and alpha components. Each component is in the range [0, 1].
func HSL ¶
HSL creates a color from HSL values. h is hue [0, 360), s is saturation [0, 1], l is lightness [0, 1].
func Hex ¶
Hex creates a color from a hex string. Supports formats: "RGB", "RGBA", "RRGGBB", "RRGGBBAA".
func (RGBA) Premultiply ¶
Premultiply returns a premultiplied color.
func (RGBA) Unpremultiply ¶
Unpremultiply returns an unpremultiplied color.
type Renderer ¶
type Renderer interface {
// Fill fills a path with the given paint.
Fill(pixmap *Pixmap, path *Path, paint *Paint)
// Stroke strokes a path with the given paint.
Stroke(pixmap *Pixmap, path *Path, paint *Paint)
}
Renderer is the interface for rendering paths to a pixmap.
type SoftwareRenderer ¶
type SoftwareRenderer struct {
// contains filtered or unexported fields
}
SoftwareRenderer is a CPU-based scanline rasterizer.
func NewSoftwareRenderer ¶
func NewSoftwareRenderer(width, height int) *SoftwareRenderer
NewSoftwareRenderer creates a new software renderer.
type SolidPattern ¶
type SolidPattern struct {
Color RGBA
}
SolidPattern represents a solid color pattern.
func NewSolidPattern ¶
func NewSolidPattern(color RGBA) *SolidPattern
NewSolidPattern creates a solid color pattern.
func (*SolidPattern) ColorAt ¶
func (p *SolidPattern) ColorAt(x, y float64) RGBA
ColorAt implements Pattern.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package backend provides a pluggable rendering backend abstraction.
|
Package backend provides a pluggable rendering backend abstraction. |
|
cmd
|
|
|
ggdemo
command
Command ggdemo demonstrates the gg 2D graphics library.
|
Command ggdemo demonstrates the gg 2D graphics library. |
|
examples
|
|
|
basic
command
|
|
|
clipping
command
Package main demonstrates the clipping API in gogpu/gg.
|
Package main demonstrates the clipping API in gogpu/gg. |
|
images
command
Package main demonstrates image drawing capabilities in gg.
|
Package main demonstrates image drawing capabilities in gg. |
|
scene
command
Package main demonstrates the scene graph (retained mode) API for gogpu/gg.
|
Package main demonstrates the scene graph (retained mode) API for gogpu/gg. |
|
shapes
command
|
|
|
text
command
|
|
|
text_fallback
command
|
|
|
internal
|
|
|
blend
Package blend implements advanced separable and non-separable blend modes.
|
Package blend implements advanced separable and non-separable blend modes. |
|
clip
Package clip provides geometric clipping for paths and shapes.
|
Package clip provides geometric clipping for paths and shapes. |
|
color
Package color provides color space types and conversions for gg.
|
Package color provides color space types and conversions for gg. |
|
filter
Package filter provides image filter implementations for the scene graph.
|
Package filter provides image filter implementations for the scene graph. |
|
image
Package image provides image buffer management for gogpu/gg.
|
Package image provides image buffer management for gogpu/gg. |
|
parallel
Package parallel provides tile-based parallel rendering infrastructure for gogpu/gg.
|
Package parallel provides tile-based parallel rendering infrastructure for gogpu/gg. |
|
path
Package path provides internal path processing utilities.
|
Package path provides internal path processing utilities. |
|
raster
Package raster provides scanline rasterization for 2D paths.
|
Package raster provides scanline rasterization for 2D paths. |
|
wide
Package wide provides SIMD-friendly wide types for batch pixel processing.
|
Package wide provides SIMD-friendly wide types for batch pixel processing. |
|
Package scene provides blend mode integration with internal/blend package.
|
Package scene provides blend mode integration with internal/blend package. |
|
Package text provides text rendering for gg.
|
Package text provides text rendering for gg. |