Documentation
¶
Overview ¶
Package canvasshade lays out the GPU pass of a canvas op that shades with a program (driver.DrawShader, or an image op under SetShader), for the backends whose canvases draw on the CPU: each renders the pass's triangles into a transparent texture of its own, source over, and draws the texture into the canvas at the pass's bounds, in the target's pixels, under the canvas's clip, alpha and operator.
The program's dst and pos are what the vertices carry rather than the pixel's place in the texture: a DrawShader's rectangle in its own points, or the point of the image an image op draws, so a rotated or scaled op shades its own space. The pass's color is the program's, premultiplied, times the vertex's color: a sprite's alpha, a mesh vertex's color or a tint.
Index ¶
Constants ¶
const Floats = 10
Floats is how many floats Pack writes for a vertex: its position in clip space, dst, pos and color.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Affine ¶
type Affine struct{ A, B, C, D, E, F float64 }
Affine maps canvas points to the target's pixels, as the web's transform(a, b, c, d, e, f): (x, y) to (A*x + C*y + E, B*x + D*y + F).
type Image ¶
type Image struct{ W, H, PixelsW, PixelsH float64 }
Image is the size of the image an image op draws, in its points and in its pixels.
type Pass ¶
type Pass struct {
// Bounds is where the pass's texture goes, in the target's pixels.
Bounds image.Rectangle
// Vertices are triangles, three vertices each.
Vertices []Vertex
// Size and Scale are what the program's rectSize and pixelScale
// return.
Size [2]float64
Scale float64
// Images are what the program reads as image0 on: an image op's
// image first, then the shader's own.
Images []driver.ImageSource
// Shader is the op's.
Shader *driver.Shader
}
Pass is what a backend renders for one op.
func Plan ¶
func Plan(d *driver.Drawing, op *driver.DrawOp, m Affine, clip image.Rectangle, img Image) (Pass, bool)
Plan lays out op under m, within clip, the target's pixels the canvas may change; img is the size of an image op's image. It reports false when op shades nothing there.
func (*Pass) Lanes ¶
Lanes returns the lanes of the program's uniforms: the bridge's, which are rectSize, pixelScale and the size in pixels of each of the textures images the program reads (size), then the shader's own.