pub struct CanvasRenderingContext2D {}
Implementations
sourceimpl CanvasRenderingContext2D
impl CanvasRenderingContext2D
sourcepub fn set_fill_style_rgba(r: u8, g: u8, b: u8, a: u8)
pub fn set_fill_style_rgba(r: u8, g: u8, b: u8, a: u8)
setter for property that specifies the color to use for the fills (outlines) around shapes. The default is black. see CanvasRenderingContext2D.fillStyle
Parameters
- ‘r’ - value from 0 to 255 that represents how much red is in the color
- ‘g’ - value from 0 to 255 that represents how much green is in the color
- ‘b’ - value from 0 to 255 that represents how much blue is in the color
- ‘a’ - value from 0 to 255 that represents how opaque the color is
sourcepub fn get_line_join() -> LineJoin
pub fn get_line_join() -> LineJoin
getter for property that determines the shape used to join two line segments where they meet. see CanvasRenderingContext2D.lineJap
sourcepub fn set_line_join(value: LineJoin)
pub fn set_line_join(value: LineJoin)
setter for property that determines the shape used to join two line segments where they meet. see CanvasRenderingContext2D.lineJoin
Parameters
- ‘value’ - the type of line join. Valid options are Bevel, Round, Miter
sourcepub fn get_line_cap() -> LineCap
pub fn get_line_cap() -> LineCap
getter for property that determines the shape used to draw the end points of lines. see CanvasRenderingContext2D.lineCap
sourcepub fn set_line_cap(value: LineCap)
pub fn set_line_cap(value: LineCap)
setter for property that determines the shape used to draw the end points of lines. see CanvasRenderingContext2D.lineCap
Parameters
- ‘value’ - the type of line cap. Valid options are Butt, Round, Square
sourcepub fn get_line_width() -> u32
pub fn get_line_width() -> u32
getter for property that sets the thickness of lines. see CanvasRenderingContext2D.lineWidth
sourcepub fn set_line_width(value: u32)
pub fn set_line_width(value: u32)
setter for property that sets the thickness of lines. see CanvasRenderingContext2D.lineWidth
Parameters
- ‘value’ - the thickness of lines. Must be a non-zero positive number
sourcepub fn set_stroke_style_rgba(r: u8, g: u8, b: u8, a: u8)
pub fn set_stroke_style_rgba(r: u8, g: u8, b: u8, a: u8)
setter for property that specifies the color to use for the strokes (outlines) around shapes. The default is black. see CanvasRenderingContext2D.strokeStyle
Parameters
- ‘r’ - value from 0 to 255 that represents how much red is in the color
- ‘g’ - value from 0 to 255 that represents how much green is in the color
- ‘b’ - value from 0 to 255 that represents how much blue is in the color
- ‘a’ - value from 0 to 255 that represents how opaque the color is
sourcepub fn arc(
x: f32,
y: f32,
radius: f32,
start_angle: f32,
end_angle: f32,
counter_clockwise: bool
)
pub fn arc(
x: f32,
y: f32,
radius: f32,
start_angle: f32,
end_angle: f32,
counter_clockwise: bool
)
adds a circular arc to the current sub-path. see CanvasRenderingContext2D.arc
Parameters
- ‘x’ - the horizontal coordinate of the arc’s center
- ‘y’ - the vertical coordinate of the arc’s center
- ‘radius’ - the arc’s radius. Must be positive
- ‘start_angle’ - the angle at which the arc starts in radians, measured from the positive x-axis
- ‘end_angle’ - the angle at which the arc ends in radians, measured from the positive x-axis
- ‘counter_clockwise’ - if true, draws the arc counter-clockwise between the start and end angles
sourcepub fn arc_to(x1: f32, y1: f32, x2: f32, y2: f32, radius: f32)
pub fn arc_to(x1: f32, y1: f32, x2: f32, y2: f32, radius: f32)
adds a circular arc to the current sub-path, using the given control points and radius. The arc is automatically connected to the path’s latest point with a straight line, if necessary for the specified parameters. see CanvasRenderingContext2D.arcTo
Parameters
- ‘x1’ - the x-axis coordinate of the first control point
- ‘y1’ - the y-axis coordinate of the first control point.
- ‘x2’ - the x-axis coordinate of the second control point
- ‘y2’ - the y-axis coordinate of the second control point.
- ‘radius’ - the arc’s radius. Must be positive
sourcepub fn begin_path()
pub fn begin_path()
starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path. see CanvasRenderingContext2D.beginPath
Parameters (none)
sourcepub fn clear_rect(x: f32, y: f32, width: f32, height: f32)
pub fn clear_rect(x: f32, y: f32, width: f32, height: f32)
erases the pixels in a rectangular area by setting them to transparent black. see CanvasRenderingContext2D.clearRect
Parameters
- ‘x’ - the x-axis coordinate of the rectangle’s starting point.
- ‘y’ - the y-axis coordinate of the rectangle’s starting point.
- ‘width’ - the rectangle’s width. Positive values are to the right, and negative to the left.
- ‘height’ - the rectangle’s height. Positive values are down, and negative are up.
sourcepub fn close_path()
pub fn close_path()
attempts to add a straight line from the current point to the start of the current sub-path. If the shape has already been closed or has only one point, this function does nothing.
This method doesn’t draw anything to the canvas directly. You can render the path using the stroke() or fill() methods. see CanvasRenderingContext2D.closePath
Parameters (none)
sourcepub fn fill()
pub fn fill()
fills the current path with the current fillStyle
see CanvasRenderingContext2D.fill
Parameters (none)
sourcepub fn fill_rect(x: f32, y: f32, width: f32, height: f32)
pub fn fill_rect(x: f32, y: f32, width: f32, height: f32)
draws a rectangle that is filled according to the current fillStyle.
This method draws directly to the canvas without modifying the current path, so any subsequent fill() or stroke() calls will have no effect on it.
see CanvasRenderingContext2D.fillRect
Parameters
- ‘x’ - the x-axis coordinate of the rectangle’s starting point.
- ‘y’ - the y-axis coordinate of the rectangle’s starting point.
- ‘width’ - the rectangle’s width. Positive values are to the right, and negative to the left.
- ‘height’ - the rectangle’s height. Positive values are down, and negative are up.
sourcepub fn line_to(x: f32, y: f32)
pub fn line_to(x: f32, y: f32)
adds a straight line to the current sub-path by connecting the sub-path’s last point to the specified (x, y) coordinates. see CanvasRenderingContext2D.lineTo
Parameters
- ‘x’ - the x-axis coordinate of the line’s end point
- ‘y’ - the y-axis coordinate of the line’s end point.
sourcepub fn move_to(x: f32, y: f32)
pub fn move_to(x: f32, y: f32)
begins a new sub-path at the point specified by the given (x, y) coordinates. see CanvasRenderingContext2D.moveTo
Parameters
- ‘x’ - the x-axis coordinate of the point
- ‘y’ - the y-axis coordinate of the point.
sourcepub fn stroke()
pub fn stroke()
strokes (outlines) the current or given path with the current stroke style. see CanvasRenderingContext2D.stroke
Parameters (none)
Auto Trait Implementations
impl RefUnwindSafe for CanvasRenderingContext2D
impl Send for CanvasRenderingContext2D
impl Sync for CanvasRenderingContext2D
impl Unpin for CanvasRenderingContext2D
impl UnwindSafe for CanvasRenderingContext2D
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more