Enum flo_canvas::Draw
source · pub enum Draw {
Show 47 variants
StartFrame,
ShowFrame,
ResetFrame,
Path(PathOp),
Fill,
Stroke,
LineWidth(f32),
LineWidthPixels(f32),
LineJoin(LineJoin),
LineCap(LineCap),
NewDashPattern,
DashLength(f32),
DashOffset(f32),
FillColor(Color),
FillTexture(TextureId, (f32, f32), (f32, f32)),
FillGradient(GradientId, (f32, f32), (f32, f32)),
FillTransform(Transform2D),
StrokeColor(Color),
WindingRule(WindingRule),
BlendMode(BlendMode),
IdentityTransform,
CanvasHeight(f32),
CenterRegion((f32, f32), (f32, f32)),
MultiplyTransform(Transform2D),
Unclip,
Clip,
Store,
Restore,
FreeStoredBuffer,
PushState,
PopState,
ClearCanvas(Color),
Layer(LayerId),
LayerBlend(LayerId, BlendMode),
ClearLayer,
ClearAllLayers,
SwapLayers(LayerId, LayerId),
Sprite(SpriteId),
ClearSprite,
SpriteTransform(SpriteTransform),
DrawSprite(SpriteId),
Texture(TextureId, TextureOp),
Font(FontId, FontOp),
BeginLineLayout(f32, f32, TextAlignment),
DrawLaidOutText,
DrawText(FontId, String, f32, f32),
Gradient(GradientId, GradientOp),
}
Expand description
Instructions for drawing to a canvas
Variants§
StartFrame
Suspends rendering to the display until the next ‘ShowFrame’
The renderer may perform tessellation or rendering in the background after ‘StartFrame’ but won’t commit anything to the visible frame buffer until ‘ShowFrame’ is hit. If ‘StartFrame’ is nested, then the frame won’t be displayed until ‘ShowFrame’ has been requested at least that many times.
The frame state persists across a ‘ClearCanvas’
ShowFrame
Displays any requested queued after ‘StartFrame’
ResetFrame
Resets the frame count back to 0 (for when regenerating the state of a canvas)
Path(PathOp)
Performs an operation on the currently defined path
Fill
Fill the current path
Stroke
Draw a line around the current path
LineWidth(f32)
Set the line width
LineWidthPixels(f32)
Set the line width in pixels
LineJoin(LineJoin)
Line join
LineCap(LineCap)
The cap to use on lines
NewDashPattern
Resets the dash pattern to empty (which is a solid line)
DashLength(f32)
Adds a dash to the current dash pattern
DashOffset(f32)
Sets the offset for the dash pattern
FillColor(Color)
Set the fill color
FillTexture(TextureId, (f32, f32), (f32, f32))
Sets the fill to be a texture (coordinates are the lower-left and upper-right coordinates where the image should appear)
FillGradient(GradientId, (f32, f32), (f32, f32))
Sets the fill to be a gradient (coordinates are the start and end of the gradient)
FillTransform(Transform2D)
For a gradient or texture fill, apply a transformation matrix
StrokeColor(Color)
Set the line color
WindingRule(WindingRule)
Set the winding rule for fill operations
BlendMode(BlendMode)
Set how future renderings are blended with one another
IdentityTransform
Reset the transformation to the identity transformation
CanvasHeight(f32)
Sets a transformation such that: (0,0) is the center point of the canvas (0,height/2) is the top of the canvas Pixels are square
CenterRegion((f32, f32), (f32, f32))
Moves a particular region to the center of the canvas (coordinates are minx, miny, maxx, maxy)
MultiplyTransform(Transform2D)
Multiply a 2D transform into the canvas
Unclip
Unset the clipping path
Clip
Clip to the currently set path
Store
Stores the content of the clipping path from the current layer in a background buffer
Restore
Restores what was stored in the background buffer. This should be done on the same layer that the Store operation was called upon.
The buffer is left intact by this operation so it can be restored again in the future.
(If the clipping path has changed since then, the restored image is clipped against the new path)
FreeStoredBuffer
Releases the buffer created by the last ‘Store’ operation
Restore will no longer be valid for the current layer
PushState
Push the current state of the canvas
PopState
Restore a state previously pushed
This will restore the line width (and the other stroke settings), stroke colour, current path, fill colour, winding rule, sprite settings and blend settings.
The currently selected layer is not affected by this operation.
ClearCanvas(Color)
Clears the canvas entirely to a background colour, and removes any stored resources (layers, sprites, fonts, textures)
Layer(LayerId)
Selects a particular layer for drawing Layer 0 is selected initially. Layers are drawn in order starting from 0. Layer IDs don’t have to be sequential.
LayerBlend(LayerId, BlendMode)
Sets how a particular layer is blended with the underlying layer
ClearLayer
Clears the current layer
ClearAllLayers
Clears all of the layers
SwapLayers(LayerId, LayerId)
Exchanges the ordering of two layers
Sprite(SpriteId)
Selects a particular sprite for drawing
Future drawing actions are sent to this sprite: use something like Layer(0)
to start drawing
to a layer again.
Sprites can be repeatedly re-rendered with a single command and their appearance may be cached for efficiency. Actions that affect the whole canvas or layers are not permitted in sprites.
ClearSprite
Releases the resources used by the current sprite
SpriteTransform(SpriteTransform)
Adds a sprite transform to the current list of transformations to apply
DrawSprite(SpriteId)
Renders a sprite with a set of transformations
Texture(TextureId, TextureOp)
Performs an operation on a texture
Font(FontId, FontOp)
Performs an operation on a font
BeginLineLayout(f32, f32, TextAlignment)
Begins laying out text on a line: the coordinates specify the baseline position
DrawLaidOutText
Renders the text in the current layout
DrawText(FontId, String, f32, f32)
Draws a string using a font with a baseline starting at the specified position
Gradient(GradientId, GradientOp)
Updates a gradient definition