Documentation ¶
Overview ¶
Canvas defines a standard interface for images that support drawing primitives.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Shatter ¶ added in v0.8.0
Shatter takes in a bounding rectangle, and several rectangles to be subtracted from it. It returns a slice of rectangles that tile together to make up the difference between them. This is intended to be used for figuring out which areas of a container box's background are covered by other boxes so it doesn't waste CPU cycles drawing to those areas.
Types ¶
type Canvas ¶
type Canvas interface { draw.Image // Pen returns a new pen for this canvas. Pen() Pen // Clip returns a new canvas that points to a specific area of this one. Clip(image.Rectangle) Canvas }
Canvas is an image that supports drawing paths.
type Drawer ¶
type Drawer interface { // Draw draws to the given canvas. Draw(Canvas) }
Drawer is an object that can draw to a canvas.
type Pen ¶
type Pen interface { // Rectangle draws a rectangle Rectangle(image.Rectangle) // Path draws a path Path(points ...image.Point) Closed(bool) // if the path is closed Cap(Cap) // line cap stype Joint(Joint) // line joint style StrokeWeight(int) // how thick the stroke is StrokeAlign(StrokeAlign) // where the stroke is drawn Stroke(color.Color) // Sets the stroke to a solid color Fill(color.Color) // Sets the fill to a solid color Texture(Texture) // Overlaps a texture onto the fill color }
Pen represents a drawing context that is linked to a canvas. Each canvas can have multiple pens associated with it, each maintaining their own drawing context.
type PushCanvas ¶
type PushCanvas interface { Canvas // Push pushes a specified region to the screen. Push(image.Rectangle) }
PushCanvas is a canvas that can push a region of itself to the screen (or some other destination).
type StrokeAlign ¶
type StrokeAlign int
StrokeAlign determines whether a stroke is drawn inside, outside, or on a path.
const ( StrokeAlignCenter StrokeAlign = iota // Centered on the path StrokeAlignInner // Inset into the path StrokeAlignOuter // Outset around the path )
type Texture ¶ added in v0.26.0
type Texture interface { image.Image // Clip returns a smaller section of this texture, pointing to the same // internal data. Clip(image.Rectangle) Texture }
Texture is a handle that points to a 2D raster image managed by the backend.
type TextureCloser ¶ added in v0.28.0
TextureCloser is a texture that can be closed. Anything that receives a TextureCloser must close it after use.