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

Trait Implementations§

source§

impl CanvasEncoding<String> for Draw

source§

fn encode_canvas(&self, append_to: &mut String)

Encodes this item by appending it to the specified string
source§

impl Clone for Draw

source§

fn clone(&self) -> Draw

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Draw

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Draw

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a, Curve: BezierCurve> From<&'a Curve> for Drawwhere Curve::Point: Coordinate2D,

source§

fn from(curve: &'a Curve) -> Draw

Converts to this type from the input type.
source§

impl Into<Draw> for PathOp

source§

fn into(self) -> Draw

Converts this type into the (usually inferred) input type.
source§

impl PartialEq<Draw> for Draw

source§

fn eq(&self, other: &Draw) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Draw

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Draw

Auto Trait Implementations§

§

impl RefUnwindSafe for Draw

§

impl Send for Draw

§

impl Sync for Draw

§

impl Unpin for Draw

§

impl UnwindSafe for Draw

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,