Skip to content

OffscreenCanvasRenderingContext2D

Generated from idl/canvas.webidl when the site was built at 7aa23e2.

OffscreenCanvasRenderingContext2D is an interface in idl/canvas.webidl, exposed in Window, Worker. It includes CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath. What it does is on MDN; this page says what niso has of it.

The web features its members belong to, each with its Baseline status on the web and how much of the feature’s WPT suite passes in niso (see Web platform support).

Feature On the web In niso Members
Offscreen canvas Widely available Partial 69% 1069 of 1545 subtests pass 66
Canvas reset() Widely available Partial 96% 84 of 87 subtests pass 1
contextlost and contextrestored Limited availability No WPT tests WPT maps no test to it 1
Canvas createConicGradient() Widely available Full 9 of 9 subtests pass 1
Canvas roundRect() Widely available Full 168 of 168 subtests pass 1
attribute
readonly attribute OffscreenCanvas canvas;
int32_t niso_offscreen_canvas_rendering_context2_d_get_canvas(niso_dom* dom, niso_handle self, niso_handle* out);
operation from CanvasState
undefined save();
int32_t niso_canvas_state_save(niso_dom* dom, niso_handle self);
operation from CanvasState
undefined restore();
int32_t niso_canvas_state_restore(niso_dom* dom, niso_handle self);
operation Canvas reset(): Partial 96% from CanvasState
undefined reset();
int32_t niso_canvas_state_reset(niso_dom* dom, niso_handle self);
operation contextlost and contextrestored: No WPT tests from CanvasState
boolean isContextLost();
int32_t niso_canvas_state_is_context_lost(niso_dom* dom, niso_handle self, bool* out);
operation from CanvasTransform
undefined scale(unrestricted double x, unrestricted double y);
int32_t niso_canvas_transform_scale(niso_dom* dom, niso_handle self, double x, double y);
operation from CanvasTransform
undefined rotate(unrestricted double angle);
int32_t niso_canvas_transform_rotate(niso_dom* dom, niso_handle self, double angle);
operation from CanvasTransform
undefined translate(unrestricted double x, unrestricted double y);
int32_t niso_canvas_transform_translate(niso_dom* dom, niso_handle self, double x, double y);
operation from CanvasTransform
undefined transform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
int32_t niso_canvas_transform_transform(niso_dom* dom, niso_handle self, double a, double b, double c, double d, double e, double f);
operation from CanvasTransform
[NisoGlue] undefined setTransform(optional any a, optional any b, optional any c, optional any d, optional any e, optional any f);
operation not in JS from CanvasTransform
[NisoInternal] undefined setMatrix(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
int32_t niso_canvas_transform_set_matrix(niso_dom* dom, niso_handle self, double a, double b, double c, double d, double e, double f);
operation from CanvasTransform
undefined resetTransform();
int32_t niso_canvas_transform_reset_transform(niso_dom* dom, niso_handle self);
attribute from CanvasCompositing
attribute unrestricted double globalAlpha;
int32_t niso_canvas_compositing_get_global_alpha(niso_dom* dom, niso_handle self, double* out);
int32_t niso_canvas_compositing_set_global_alpha(niso_dom* dom, niso_handle self, double value);
attribute from CanvasCompositing
attribute DOMString globalCompositeOperation;
int32_t niso_canvas_compositing_get_global_composite_operation(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_compositing_set_global_composite_operation(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasImageSmoothing
attribute boolean imageSmoothingEnabled;
int32_t niso_canvas_image_smoothing_get_image_smoothing_enabled(niso_dom* dom, niso_handle self, bool* out);
int32_t niso_canvas_image_smoothing_set_image_smoothing_enabled(niso_dom* dom, niso_handle self, bool value);
attribute from CanvasImageSmoothing
attribute ImageSmoothingQuality imageSmoothingQuality;
int32_t niso_canvas_image_smoothing_get_image_smoothing_quality(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_image_smoothing_set_image_smoothing_quality(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasFillStrokeStyles
[NisoGlue] attribute any strokeStyle;
attribute from CanvasFillStrokeStyles
[NisoGlue] attribute any fillStyle;
operation not in JS from CanvasFillStrokeStyles
[NisoInternal] undefined setStyleColor(boolean stroke, DOMString color);
int32_t niso_canvas_fill_stroke_styles_set_style_color(niso_dom* dom, niso_handle self, bool stroke, const char* color, size_t color_len);

stroke: the stroke style, else the fill style. A colour that does not parse leaves the style as it was.

operation not in JS from CanvasFillStrokeStyles
[NisoInternal] undefined setStyleGradient(boolean stroke, CanvasGradient gradient);
int32_t niso_canvas_fill_stroke_styles_set_style_gradient(niso_dom* dom, niso_handle self, bool stroke, niso_handle gradient);
operation not in JS from CanvasFillStrokeStyles
[NisoInternal] undefined setStylePattern(boolean stroke, CanvasPattern pattern);
int32_t niso_canvas_fill_stroke_styles_set_style_pattern(niso_dom* dom, niso_handle self, bool stroke, niso_handle pattern);
operation not in JS from CanvasFillStrokeStyles
[NisoInternal] DOMString? styleColor(boolean stroke);
int32_t niso_canvas_fill_stroke_styles_style_color(niso_dom* dom, niso_handle self, bool stroke, niso_str* out);

The style’s colour serialized, or null for a gradient or pattern.

operation not in JS from CanvasFillStrokeStyles
[NisoInternal] CanvasGradient? styleGradient(boolean stroke);
int32_t niso_canvas_fill_stroke_styles_style_gradient(niso_dom* dom, niso_handle self, bool stroke, niso_handle* out);
operation not in JS from CanvasFillStrokeStyles
[NisoInternal] CanvasPattern? stylePattern(boolean stroke);
int32_t niso_canvas_fill_stroke_styles_style_pattern(niso_dom* dom, niso_handle self, bool stroke, niso_handle* out);
operation from CanvasFillStrokeStyles
[NewObject] CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
int32_t niso_canvas_fill_stroke_styles_create_linear_gradient(niso_dom* dom, niso_handle self, double x0, double y0, double x1, double y1, niso_handle* out);
operation from CanvasFillStrokeStyles
[NewObject] CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
int32_t niso_canvas_fill_stroke_styles_create_radial_gradient(niso_dom* dom, niso_handle self, double x0, double y0, double r0, double x1, double y1, double r1, niso_handle* out);
operation Canvas createConicGradient(): Full from CanvasFillStrokeStyles
[NewObject] CanvasGradient createConicGradient(double startAngle, double x, double y);
int32_t niso_canvas_fill_stroke_styles_create_conic_gradient(niso_dom* dom, niso_handle self, double start_angle, double x, double y, niso_handle* out);
operation from CanvasFillStrokeStyles
[NisoGlue] CanvasPattern? createPattern(any image, [LegacyNullToEmptyString] DOMString repetition);
operation not in JS from CanvasFillStrokeStyles
[NisoInternal] CanvasPattern? patternFrom(Element? element, ImageBitmap? bitmap, OffscreenCanvas? offscreen, DOMString repetition);
int32_t niso_canvas_fill_stroke_styles_pattern_from(niso_dom* dom, niso_handle self, niso_handle element, niso_handle bitmap, niso_handle offscreen, const char* repetition, size_t repetition_len, niso_handle* out);

One of element, bitmap and offscreen is the image.

attribute from CanvasShadowStyles
attribute unrestricted double shadowOffsetX;
int32_t niso_canvas_shadow_styles_get_shadow_offset_x(niso_dom* dom, niso_handle self, double* out);
int32_t niso_canvas_shadow_styles_set_shadow_offset_x(niso_dom* dom, niso_handle self, double value);
attribute from CanvasShadowStyles
attribute unrestricted double shadowOffsetY;
int32_t niso_canvas_shadow_styles_get_shadow_offset_y(niso_dom* dom, niso_handle self, double* out);
int32_t niso_canvas_shadow_styles_set_shadow_offset_y(niso_dom* dom, niso_handle self, double value);
attribute from CanvasShadowStyles
attribute unrestricted double shadowBlur;
int32_t niso_canvas_shadow_styles_get_shadow_blur(niso_dom* dom, niso_handle self, double* out);
int32_t niso_canvas_shadow_styles_set_shadow_blur(niso_dom* dom, niso_handle self, double value);
attribute from CanvasShadowStyles
attribute DOMString shadowColor;
int32_t niso_canvas_shadow_styles_get_shadow_color(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_shadow_styles_set_shadow_color(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasFilters
attribute DOMString filter;
int32_t niso_canvas_filters_get_filter(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_filters_set_filter(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
operation from CanvasRect
undefined clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
int32_t niso_canvas_rect_clear_rect(niso_dom* dom, niso_handle self, double x, double y, double w, double h);
operation from CanvasRect
undefined fillRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
int32_t niso_canvas_rect_fill_rect(niso_dom* dom, niso_handle self, double x, double y, double w, double h);
operation from CanvasRect
undefined strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
int32_t niso_canvas_rect_stroke_rect(niso_dom* dom, niso_handle self, double x, double y, double w, double h);
operation from CanvasDrawPath
undefined beginPath();
int32_t niso_canvas_draw_path_begin_path(niso_dom* dom, niso_handle self);
operation from CanvasDrawPath
[NisoGlue] undefined fill(optional any a, optional any b);
operation from CanvasDrawPath
[NisoGlue] undefined stroke(optional Path2D path);
operation from CanvasDrawPath
[NisoGlue] undefined clip(optional any a, optional any b);
operation from CanvasDrawPath
[NisoGlue] boolean isPointInPath(any a, any b, optional any c, optional any d);
operation from CanvasDrawPath
[NisoGlue] boolean isPointInStroke(any a, any b, optional any c);
operation not in JS from CanvasDrawPath
[NisoInternal] undefined fillWith(Path2D? path, CanvasFillRule fillRule);
int32_t niso_canvas_draw_path_fill_with(niso_dom* dom, niso_handle self, niso_handle path, const char* fill_rule, size_t fill_rule_len);
operation not in JS from CanvasDrawPath
[NisoInternal] undefined strokeWith(Path2D? path);
int32_t niso_canvas_draw_path_stroke_with(niso_dom* dom, niso_handle self, niso_handle path);
operation not in JS from CanvasDrawPath
[NisoInternal] undefined clipWith(Path2D? path, CanvasFillRule fillRule);
int32_t niso_canvas_draw_path_clip_with(niso_dom* dom, niso_handle self, niso_handle path, const char* fill_rule, size_t fill_rule_len);
operation not in JS from CanvasDrawPath
[NisoInternal] boolean pointInPath(Path2D? path, unrestricted double x, unrestricted double y, CanvasFillRule fillRule);
int32_t niso_canvas_draw_path_point_in_path(niso_dom* dom, niso_handle self, niso_handle path, double x, double y, const char* fill_rule, size_t fill_rule_len, bool* out);
operation not in JS from CanvasDrawPath
[NisoInternal] boolean pointInStroke(Path2D? path, unrestricted double x, unrestricted double y);
int32_t niso_canvas_draw_path_point_in_stroke(niso_dom* dom, niso_handle self, niso_handle path, double x, double y, bool* out);
operation from CanvasText
undefined fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
int32_t niso_canvas_text_fill_text(niso_dom* dom, niso_handle self, const char* text, size_t text_len, double x, double y, bool has_max_width, double max_width);
operation from CanvasText
undefined strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
int32_t niso_canvas_text_stroke_text(niso_dom* dom, niso_handle self, const char* text, size_t text_len, double x, double y, bool has_max_width, double max_width);
operation from CanvasText
TextMetrics measureText(DOMString text);
int32_t niso_canvas_text_measure_text(niso_dom* dom, niso_handle self, const char* text, size_t text_len, niso_text_metrics* out);
operation from CanvasDrawImage
[NisoGlue] undefined drawImage(any image, unrestricted double a, unrestricted double b, optional unrestricted double c, optional unrestricted double d, optional unrestricted double e, optional unrestricted double f, optional unrestricted double g, optional unrestricted double h);
operation not in JS from CanvasDrawImage
[NisoInternal] undefined drawFrom(Element? element, ImageBitmap? bitmap, OffscreenCanvas? offscreen, unsigned short count, unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f, unrestricted double g, unrestricted double h);
int32_t niso_canvas_draw_image_draw_from(niso_dom* dom, niso_handle self, niso_handle element, niso_handle bitmap, niso_handle offscreen, uint16_t count, double a, double b, double c, double d, double e, double f, double g, double h);

count is how many numbers were given: 2, 4 or 8.

operation from CanvasImageData
[NisoGlue] ImageData createImageData(any a, optional any b, optional any c);
operation from CanvasImageData
ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh, optional ImageDataSettings settings = {});
int32_t niso_canvas_image_data_get_image_data(niso_dom* dom, niso_handle self, int32_t sx, int32_t sy, int32_t sw, int32_t sh, const niso_image_data_settings* settings, niso_image_data* out);
operation from CanvasImageData
[NisoGlue] undefined putImageData(ImageData imagedata, long dx, long dy, optional long dirtyX, optional long dirtyY, optional long dirtyWidth, optional long dirtyHeight);
operation not in JS from CanvasImageData
[NisoInternal] undefined putDirty(ImageData imagedata, long dx, long dy, long dirtyX, long dirtyY, long dirtyWidth, long dirtyHeight);
int32_t niso_canvas_image_data_put_dirty(niso_dom* dom, niso_handle self, const niso_image_data* imagedata, int32_t dx, int32_t dy, int32_t dirty_x, int32_t dirty_y, int32_t dirty_width, int32_t dirty_height);
attribute from CanvasPathDrawingStyles
attribute unrestricted double lineWidth;
int32_t niso_canvas_path_drawing_styles_get_line_width(niso_dom* dom, niso_handle self, double* out);
int32_t niso_canvas_path_drawing_styles_set_line_width(niso_dom* dom, niso_handle self, double value);
attribute from CanvasPathDrawingStyles
attribute CanvasLineCap lineCap;
int32_t niso_canvas_path_drawing_styles_get_line_cap(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_path_drawing_styles_set_line_cap(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasPathDrawingStyles
attribute CanvasLineJoin lineJoin;
int32_t niso_canvas_path_drawing_styles_get_line_join(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_path_drawing_styles_set_line_join(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasPathDrawingStyles
attribute unrestricted double miterLimit;
int32_t niso_canvas_path_drawing_styles_get_miter_limit(niso_dom* dom, niso_handle self, double* out);
int32_t niso_canvas_path_drawing_styles_set_miter_limit(niso_dom* dom, niso_handle self, double value);
operation from CanvasPathDrawingStyles
[NisoGlue] undefined setLineDash(sequence<unrestricted double> segments);
operation from CanvasPathDrawingStyles
[NisoGlue] sequence<unrestricted double> getLineDash();
operation not in JS from CanvasPathDrawingStyles
[NisoInternal] undefined setDash(Float64Array segments);
int32_t niso_canvas_path_drawing_styles_set_dash(niso_dom* dom, niso_handle self, const uint8_t* segments, size_t segments_len);
operation not in JS from CanvasPathDrawingStyles
[NisoInternal] Float64Array dash();
int32_t niso_canvas_path_drawing_styles_dash(niso_dom* dom, niso_handle self, niso_bytes* out);
attribute from CanvasPathDrawingStyles
attribute unrestricted double lineDashOffset;
int32_t niso_canvas_path_drawing_styles_get_line_dash_offset(niso_dom* dom, niso_handle self, double* out);
int32_t niso_canvas_path_drawing_styles_set_line_dash_offset(niso_dom* dom, niso_handle self, double value);
attribute from CanvasTextDrawingStyles
attribute DOMString font;
int32_t niso_canvas_text_drawing_styles_get_font(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_font(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasTextDrawingStyles
attribute CanvasTextAlign textAlign;
int32_t niso_canvas_text_drawing_styles_get_text_align(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_text_align(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasTextDrawingStyles
attribute CanvasTextBaseline textBaseline;
int32_t niso_canvas_text_drawing_styles_get_text_baseline(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_text_baseline(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasTextDrawingStyles
attribute CanvasDirection direction;
int32_t niso_canvas_text_drawing_styles_get_direction(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_direction(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasTextDrawingStyles
attribute DOMString letterSpacing;
int32_t niso_canvas_text_drawing_styles_get_letter_spacing(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_letter_spacing(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasTextDrawingStyles
attribute CanvasFontKerning fontKerning;
int32_t niso_canvas_text_drawing_styles_get_font_kerning(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_font_kerning(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasTextDrawingStyles
attribute CanvasFontStretch fontStretch;
int32_t niso_canvas_text_drawing_styles_get_font_stretch(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_font_stretch(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasTextDrawingStyles
attribute CanvasFontVariantCaps fontVariantCaps;
int32_t niso_canvas_text_drawing_styles_get_font_variant_caps(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_font_variant_caps(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasTextDrawingStyles
attribute CanvasTextRendering textRendering;
int32_t niso_canvas_text_drawing_styles_get_text_rendering(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_text_rendering(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
attribute from CanvasTextDrawingStyles
attribute DOMString wordSpacing;
int32_t niso_canvas_text_drawing_styles_get_word_spacing(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_canvas_text_drawing_styles_set_word_spacing(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
operation from CanvasPath
undefined closePath();
int32_t niso_canvas_path_close_path(niso_dom* dom, niso_handle self);
operation from CanvasPath
undefined moveTo(unrestricted double x, unrestricted double y);
int32_t niso_canvas_path_move_to(niso_dom* dom, niso_handle self, double x, double y);
operation from CanvasPath
undefined lineTo(unrestricted double x, unrestricted double y);
int32_t niso_canvas_path_line_to(niso_dom* dom, niso_handle self, double x, double y);
operation from CanvasPath
undefined quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y);
int32_t niso_canvas_path_quadratic_curve_to(niso_dom* dom, niso_handle self, double cpx, double cpy, double x, double y);
operation from CanvasPath
undefined bezierCurveTo(unrestricted double cp1x, unrestricted double cp1y, unrestricted double cp2x, unrestricted double cp2y, unrestricted double x, unrestricted double y);
int32_t niso_canvas_path_bezier_curve_to(niso_dom* dom, niso_handle self, double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
operation from CanvasPath
undefined arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
int32_t niso_canvas_path_arc_to(niso_dom* dom, niso_handle self, double x1, double y1, double x2, double y2, double radius);
operation from CanvasPath
undefined rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
int32_t niso_canvas_path_rect(niso_dom* dom, niso_handle self, double x, double y, double w, double h);
operation Canvas roundRect(): Full from CanvasPath
[NisoGlue] undefined roundRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h, optional any radii = 0);
operation not in JS from CanvasPath
[NisoInternal] undefined roundRectWith(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h, Float64Array radii);
int32_t niso_canvas_path_round_rect_with(niso_dom* dom, niso_handle self, double x, double y, double w, double h, const uint8_t* radii, size_t radii_len);

radii: an x and y radius for each corner, upper left first.

operation from CanvasPath
undefined arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean counterclockwise = false);
int32_t niso_canvas_path_arc(niso_dom* dom, niso_handle self, double x, double y, double radius, double start_angle, double end_angle, bool counterclockwise);
operation from CanvasPath
undefined ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean counterclockwise = false);
int32_t niso_canvas_path_ellipse(niso_dom* dom, niso_handle self, double x, double y, double radius_x, double radius_y, double rotation, double start_angle, double end_angle, bool counterclockwise);

Members the web has, by the BCD keys web-features 3.45.0 lists, that idl/ doesn’t declare. The list is partial: web-features lists only the keys it maps to a feature.

  • drawElementImage (HTML-in-canvas)
  • getTransform (Offscreen canvas)