ICanvasRenderingContext2D class
ICanvasRenderingContext2D class
The ICanvasRenderingContext2D interface is used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a canvas element.
The ICanvasRenderingContext2D type exposes the following members:
Properties
Property | Description |
---|---|
canvas | A read-only back-reference to the HTMLCanvasElement. Might be null if it is not associated with a canvas element. |
global_alpha | Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque). |
global_composite_operation | With globalAlpha applied this sets how shapes and images are drawn onto the existing bitmap. Default: (source-over) |
stroke_style | Color or style to use for the lines around shapes. Default: (black). |
fill_style | Color or style to use inside shapes. Default: (black). |
image_smoothing_enabled | Image smoothing mode; if disabled, images will not be smoothed if scaled. |
shadow_offset_x | Horizontal distance the shadow will be offset. Default 0. |
shadow_offset_y | Vertical distance the shadow will be offset. Default 0. |
shadow_blur | Specifies the blurring effect. Default 0 |
shadow_color | Color of the shadow. Default fully-transparent black. |
line_width | Width of lines. Default 1.0 |
line_cap | Type of endings on the end of lines. Possible values: butt (default), round, square. |
line_join | Defines the type of corners where two lines meet. Possible values: round, bevel, miter (default). |
miter_limit | Miter limit ratio. Default 10. |
line_dash_offset | Specifies where to start a dash array on a line. |
font | Font setting. Default value 10px sans-serif |
text_align | Text alignment setting. Possible values: start (default), end, left, right or center. |
text_baseline | Baseline alignment setting. Possible values: top, hanging, middle, alphabetic (default), ideographic, bottom. |
Methods
Method | Description |
---|---|
create_pattern | Creates a pattern using the specified image (a CanvasImageSource). It repeats the source in the directions specified by the repetition argument. |
create_pattern | Creates a pattern using the specified image (a CanvasImageSource). It repeats the source in the directions specified by the repetition argument. |
fill | Fills the subpaths with the current fill style and default algorithm CanvasFillRule.Nonzero. |
fill | Fills the subpaths with the current fill style. |
fill | Fills the subpaths with the current fill style and default algorithm CanvasFillRule.Nonzero. |
fill | Fills the subpaths with the current fill style. |
stroke | Strokes the subpaths with the current stroke style. |
stroke | Strokes the subpaths with the current stroke style. |
clip | Creates a new clipping region by calculating the intersection of the current clipping region and the area described by the path, using the non-zero winding number rule. Open subpaths must be implicitly closed when computing the clipping region, without affecting the actual subpaths. The new clipping region replaces the current clipping region. |
clip | Creates a new clipping region by calculating the intersection of the current clipping region and the area described by the path, using the non-zero winding number rule. Open subpaths must be implicitly closed when computing the clipping region, without affecting the actual subpaths. The new clipping region replaces the current clipping region. |
clip | Creates a new clipping region by calculating the intersection of the current clipping region and the area described by the path, using the non-zero winding number rule. Open subpaths must be implicitly closed when computing the clipping region, without affecting the actual subpaths. The new clipping region replaces the current clipping region. |
is_point_in_path | Reports whether or not the specified point is contained in the current path. |
is_point_in_path | Reports whether or not the specified point is contained in the current path. |
is_point_in_path | Reports whether or not the specified point is contained in the current path. |
is_point_in_path | Reports whether or not the specified point is contained in the current path. |
is_point_in_stroke | Reports whether or not the specified point is inside the area contained by the stroking of a path. |
is_point_in_stroke | Reports whether or not the specified point is inside the area contained by the stroking of a path. |
fill_text | Draws (fills) a given text at the given (x,y) position. |
fill_text | Draws (fills) a given text at the given (x,y) position. |
stroke_text | Draws (strokes) a given text at the given (x, y) position. |
stroke_text | |
draw_image | Draws the specified image. |
draw_image | Draws the specified image. |
draw_image | Draws the specified image. |
draw_image | Draws the specified image. |
draw_image | Draws the specified image. |
draw_image | Draws the specified image. |
create_image_data | Creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are transparent black. |
create_image_data | Creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are transparent black. |
put_image_data | Paints data from the given ImageData object onto the bitmap. If a dirty rectangle is provided, only the pixels from that rectangle are painted. This method is not affected by the canvas transformation matrix. |
put_image_data | Paints data from the given ImageData object onto the bitmap. If a dirty rectangle is provided, only the pixels from that rectangle are painted. This method is not affected by the canvas transformation matrix. |
arc | |
arc | |
ellipse | |
ellipse | |
save | Saves the current drawing style state using a stack so you can revert any change you make to it using restore(). |
restore | Restores the drawing style state to the last element on the ‘state stack’ saved by save(). |
scale | Adds a scaling transformation to the canvas units by x horizontally and by y vertically. |
rotate | Adds a rotation to the transformation matrix. The angle argument represents a clockwise rotation angle and is expressed in radians. |
translate | Adds a translation transformation by moving the canvas and its origin x horzontally and y vertically on the grid. |
transform | Multiplies the current transformation matrix with the matrix described by its arguments. |
set_transform | Resets the current transform to the identity matrix, and then invokes the transform() method with the same arguments. |
reset_transform | Resets the current transform by the identity matrix. |
create_linear_gradient | Creates a linear gradient along the line given by the coordinates represented by the parameters. |
create_radial_gradient | Creates a radial gradient given by the coordinates of the two circles represented by the parameters. |
clear_rect | Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black, erasing any previously drawn content. |
fill_rect | Draws a filled rectangle at (x, y) position whose size is determined by width and height. |
stroke_rect | Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using the current stroke style. |
begin_path | Starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path. |
draw_focus_if_needed | If a given element is focused, this method draws a focus ring around the current path. |
measure_text | Returns a TextMetrics object. |
remove_hit_region | Removes the hit region with the specified id from the canvas. |
clear_hit_regions | Removes all hit regions from the canvas. |
get_image_data | Returns an ImageData object representing the underlying pixel data for the area of the canvas denoted by the rectangle which starts at (sx, sy) and has an sw width and sh height. This method is not affected by the canvas transformation matrix. |
set_line_dash | Sets the current line dash pattern. |
get_line_dash | Returns the current line dash pattern array containing an even number of non-negative numbers. |
close_path | |
move_to | |
line_to | |
quadratic_curve_to | |
bezier_curve_to | |
arc_to | |
rect |
See Also
- module
aspose.html.dom.canvas
- class
ICanvasDrawingStyles