Crate flo_canvas[−][src]
Expand description
flo_canvas
flo_canvas
provides an abstraction of a 2D vector canvas, and supporting methods to stream
updates to implementations.
The main features that this library supports are the set of primitives in the Draw
enum, the
Canvas
type for streaming drawing instructions elsewhere, and the encoding and decoding
functions that can be used to send canvas instructions over a byte stream. Encoding uses MIME64
characters, so it’s easy to embed encoded canvases in other protocols.
By itself, flo_canvas
is an excellent way to describe how a 2D scene should be rendered without
needing to depend on a system-specific library.
FlowBetween comes with several implementations of the canvas for generating the final rendered
results. Most notably, flo_render_canvas
will convert between a stream of Draw
instructions
and a stream of instructions suitable for rendering with most graphics APIs. The accompanying
flo_render
can render these instructions to OpenGL or Metal and flo_render_gl_offscreen
is
available to generate bitmap images on a variety of systems.
canvas.js
provides a Javascript implementation that can render the instructions to a HTML
canvas, and there are also Quartz and Cairo implementations of the canvas provided in FlowBetween’s
user interface layers.
Features
Some features of flo_canvas
are optional due to the extra dependencies they can bring in. They
can be enabled if the extra functionality is required or left out to get a more compact library.
outline-fonts
- provides a function that will convert a stream of Draw instructions into another stream of Draw instructions, except all the font commands will be removed and replaced with an outline rendering of the font (useful for rendering back-ends that don’t have native font support or for generating vector files that don’t require particular fonts to be installed)
Re-exports
pub use flo_curves as curves;
Structs
A canvas is an abstract interface for drawing graphics. It doesn’t actually provide a means to render anything, but rather a way to describe how things should be drawn and pass those on to a renderer elsewhere.
Represents a (stateful) canvas decoder
Representation of a font face
Graphics context for a Canvas
Represents a 2D point
A draw stream relays Draw
instructions from a source such as a Canvas
or a DrawContext
as a stream
A drawing target sends drawing instructions to a DrawStream
Identifier for a font
Describes where to position a line relative to some text
Metrics for a font
The properties to use when selecting a font face
ID for a glyph within a font
Describes how a glyph is positioned on the canvas
Identifies a gradient
Identifier of a canvas layer
Identifier of a canvas ‘sprite’
The layout metrics for a piece of text
Identifier for a texture
Represents a 2D affine transformation matrix
Enums
Blend mode to use when drawing
Representation of a colour
Possible formats of a colour value
Possible error from the decoder
Instructions for drawing to a canvas
Operations that can be performed on a font
The possible styles of a font
Operations that can be applied to a gradient
How to cap lines
Possible way to join lines
Attributes used to render a bezier path
Operations that define paths
Transformation to apply to a canvas ‘sprite’
Error from either a decoder or the stream that’s feeding it
Determines how text is drawn relative to its alignment’s origin point
Format of a rendering texture
Operations that can be performed on a texture
How a path should determine if it’s an outer edge or not
Traits
Trait implemented by objects that can be encoded into a canvas
Represents a coordinate with a 2D position
A graphics context provides the basic set of graphics actions that can be performed
GraphicsPrimitives adds new primitives that can be built directly from a graphics context
Functions
Decodes a canvas drawing represented as an iterator of characters. If there’s an error in the stream, it will be the last item decoded.
Decodes a canvas drawing represented as a stream of characters.
Returns the drawing commands for a circle
Returns the drawing commands for a rectangle
Converts a stream of drawing instructions into a stream of bezier paths with attributes that specify how they’re rendered.
Converts a stream of drawing instructions into a stream of bezier paths (stripping any other attributes from the stream)
Converts dashed line stroke operations into separate lines
Creates a gradient scale, as 8-bit RGBA quads from a set of gradient operations
Converts a bezier path to a set of paths by a dash patter