Enum flo_canvas::Draw[][src]

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

Performs an operation on the currently defined path

Tuple Fields of Path

0: PathOp
Fill

Fill the current path

Stroke

Draw a line around the current path

LineWidth

Set the line width

Tuple Fields of LineWidth

0: f32
LineWidthPixels

Set the line width in pixels

Tuple Fields of LineWidthPixels

0: f32
LineJoin

Line join

Tuple Fields of LineJoin

0: LineJoin
LineCap

The cap to use on lines

Tuple Fields of LineCap

0: LineCap
NewDashPattern

Resets the dash pattern to empty (which is a solid line)

DashLength

Adds a dash to the current dash pattern

Tuple Fields of DashLength

0: f32
DashOffset

Sets the offset for the dash pattern

Tuple Fields of DashOffset

0: f32
FillColor

Set the fill color

Tuple Fields of FillColor

0: Color
FillTexture

Sets the fill to be a texture (coordinates are the lower-left and upper-right coordinates where the image should appear)

Tuple Fields of FillTexture

0: TextureId1: (f32, f32)2: (f32, f32)
FillGradient

Sets the fill to be a gradient (coordinates are the start and end of the gradient)

Tuple Fields of FillGradient

0: GradientId1: (f32, f32)2: (f32, f32)
FillTransform

For a gradient or texture fill, apply a transformation matrix

Tuple Fields of FillTransform

0: Transform2D
StrokeColor

Set the line color

Tuple Fields of StrokeColor

0: Color
WindingRule

Set the winding rule for fill operations

Tuple Fields of WindingRule

0: WindingRule
BlendMode

Set how future renderings are blended with one another

Tuple Fields of BlendMode

0: BlendMode
IdentityTransform

Reset the transformation to the identity transformation

CanvasHeight

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

Tuple Fields of CanvasHeight

0: f32
CenterRegion

Moves a particular region to the center of the canvas (coordinates are minx, miny, maxx, maxy)

Tuple Fields of CenterRegion

0: (f32, f32)1: (f32, f32)
MultiplyTransform

Multiply a 2D transform into the canvas

Tuple Fields of MultiplyTransform

0: Transform2D
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

Clears the canvas entirely to a background colour, and removes any stored resources (layers, sprites, fonts, textures)

Tuple Fields of ClearCanvas

0: Color
Layer

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.

Tuple Fields of Layer

0: LayerId
LayerBlend

Sets how a particular layer is blended with the underlying layer

Tuple Fields of LayerBlend

0: LayerId1: BlendMode
ClearLayer

Clears the current layer

ClearAllLayers

Clears all of the layers

SwapLayers

Exchanges the ordering of two layers

Tuple Fields of SwapLayers

0: LayerId1: LayerId
Sprite

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.

Tuple Fields of Sprite

0: SpriteId
ClearSprite

Releases the resources used by the current sprite

SpriteTransform

Adds a sprite transform to the current list of transformations to apply

Tuple Fields of SpriteTransform

0: SpriteTransform
DrawSprite

Renders a sprite with a set of transformations

Tuple Fields of DrawSprite

0: SpriteId
Texture

Performs an operation on a texture

Tuple Fields of Texture

0: TextureId1: TextureOp
Font

Performs an operation on a font

Tuple Fields of Font

0: FontId1: FontOp
BeginLineLayout

Begins laying out text on a line: the coordinates specify the baseline position

Tuple Fields of BeginLineLayout

0: f321: f322: TextAlignment
DrawLaidOutText

Renders the text in the current layout

DrawText

Draws a string using a font with a baseline starting at the specified position

Tuple Fields of DrawText

0: FontId1: String2: f323: f32
Gradient

Updates a gradient definition

Tuple Fields of Gradient

0: GradientId1: GradientOp

Trait Implementations

Encodes this item by appending it to the specified string Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.