pub struct RenderContext2D { /* private fields */ }
Expand description

The RenderContext2D trait, provides the rendering context (ctx). It is used for drawing shapes, text, images, and other objects.

Implementations

Creates a new 2d render context.

Registers a new font file.

Resizes pixmap with new height and width

Set the background of the render context.

Draws a filled rectangle whose starting point is at the coordinates {x, y} with the specified width and height and whose style is determined by the fillStyle attribute.

Draws a rectangle that is stroked (outlined) according to the current strokeStyle and other ctx settings.

Creates a circular arc centered at (x, y) with a radius of given radius value. The path starts at value startAngle and ends at value endAngle.

Starts a new path by emptying the list of sub-paths. You should call this method, if you want to create a new path.

Adds a cubic Bézier curve to the current sub-path. It requires three points: the first two are control points and the third one is the end point. The starting point is the latest point in the current path, which can be changed using MoveTo{} before creating the Bézier curve.

Creates a clipping mask applied to the current paths. Everything drawn after calling clip() will only act inside the clipping path.

When closing a path, the method attempts to add a straight line starting from the current point to the start point of the current sub-path. Nothing will happen, if the shape has already been closed or only a single point is referenced.

Draws the image.

Draws the pipeline.

Draws a render target.

Fills the current or given path with the current file style.

Draws (fills) a given text at the given (x, y) position.

Adds a straight line to the current sub-path by connecting the sub-path’s last point to the specified {x, y} coordinates.

Returns a TextMetrics object.

Returns a TextMetrics object.

Begins a new sub-path at given point. The point is specified by given {x, y} coordinates.

Adds a quadratic Bézier curve to the current sub-path.

Strokes {outlines} the current or given path with the current stroke style.

Adds a rectangle to the current path.

Sets the alpha value,

Specifies the font family.

Specifies the font size.

Sets the thickness of lines.

Specifies the fill color to use inside shapes.

Specifies the fill stroke to use inside shapes.

Clear the given brush.

Return the pixmap data lenght as an u8 reference value.

Byteorder: RGBA

Return the pixmap data lenght as a mutable u8 reference value.

Byteorder: RGBA

Return the pixmap data lenght as a mutable u8 reference value.

Byteorder: RGBA

Restores the most recently saved canvas state by popping the top entry in the drawing state stack. If there is no saved state, this method does nothing.

Saves the entire state of the pixmap by pushing the current state onto a stack.

Fill the background pixmap colors using their rgba8 values.

Cleanup, once we are finished.

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.