Struct vg::Canvas

source · []
pub struct Canvas<T: Renderer> { /* private fields */ }
Expand description

Main 2D drawing context.

Implementations

Creates a new canvas.

Creates a new canvas with the specified renderer and using the fonts registered with the provided TextContext. Note that the context is explicitly shared, so that any fonts registered with a clone of this context will also be visible to this canvas.

Sets the size of the default framebuffer (screen size)

Clears the rectangle area defined by left upper corner (x,y), width and height with the provided color.

Returns the width of the current render target.

Returns the height of the current render target.

Tells the renderer to execute all drawing commands and clears the current internal state

Call this at the end of each frame.

Creates streenshot

Pushes and saves the current render state into a state stack.

A matching restore() must be used to restore the state.

Restores the previous render state

Restoring the initial/first state will just reset it to the defaults

Resets current state to default values. Does not affect the state stack.

Saves the current state before calling the callback and restores it afterwards

This is less error prone than remembering to match save() -> restore() calls

Sets the transparency applied to all rendered shapes.

Already transparent paths will get proportionally more transparent as well.

Sets the composite operation.

Sets the composite operation with custom pixel arithmetic.

Sets the composite operation with custom pixel arithmetic for RGB and alpha components separately.

Sets a new render target. All drawing operations after this call will happen on the provided render target

Allocates an empty image with the provided domensions and format.

Creates image from specified image data.

Retrieve image by id

Retrieve mutable image by id

Resizes an image to the new provided dimensions.

Decode an image from file

Decode an image from memory

Updates image data specified by image handle.

Deletes created image.

Returns image info

Returns the size in pixels of the image for the specified id.

Renders the given source_image into target_image while applying a filter effect.

The target image must have the same size as the source image. The filtering is recorded as a drawing command and run by the renderer when Self::flush() is called.

The filtering does not take any transformation set on the Canvas into account nor does it change the current rendering target.

Resets current transform to a identity matrix.

Premultiplies current coordinate system by specified matrix.

The parameters are interpreted as matrix as follows: [a c e] [b d f] [0 0 1]

Translates the current coordinate system.

Rotates the current coordinate system. Angle is specified in radians.

Skews the current coordinate system along X axis. Angle is specified in radians.

Skews the current coordinate system along Y axis. Angle is specified in radians.

Scales the current coordinate system.

Returns the current transformation matrix

TODO: It’s not ok that this method returns Transform2D while set_transform accepts 6 floats - make it consistant

Sets the current scissor rectangle.

The scissor rectangle is transformed by the current transform.

Intersects current scissor rectangle with the specified rectangle.

The scissor rectangle is transformed by the current transform. Note: in case the rotation of previous scissor rect differs from the current one, the intersection will be done between the specified rectangle and the previous scissor rectangle transformed in the current transform space. The resulting shape is always rectangle.

Reset and disables scissoring.

Returns true if the specified point (x,y) is in the provided path, and false otherwise.

Return the bounding box for a Path

Fills the provided Path with the specified Paint.

Strokes the provided Path with the specified Paint.

Adds a font file to the canvas

Adds a font to the canvas by reading it from the specified chunk of memory.

Adds all .ttf files from a directory

Returns information on how the provided text will be drawn with the specified paint.

Returns font metrics for a particular Paint.

Returns the maximum index-th byte of text that will fit inside max_width.

The retuned index will always lie at the start and/or end of a UTF-8 code point sequence or at the start or end of the text

Returnes a list of ranges representing each line of text that will fit inside max_width

Fills the provided string with the specified Paint.

Strokes the provided string with the specified Paint.

Trait Implementations

Executes the destructor for this type. 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

Returns the argument unchanged.

Calls U::from(self).

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

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.