CanvasRenderingContext2D
Module: JavaScript DOM API
#include <CanvasRenderingContext2D.Idl>
Public Functions
| Name | |
|---|---|
| attribute(DOMString or CanvasGradient or CanvasPattern) | |
| attribute(DOMString or CanvasGradient or CanvasPattern) | |
| CanvasGradient | createLinearGradient(float x0, float y0, float x1, float y1) | 
| CanvasGradient | createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1) | 
| CanvasGradient | createConicGradient(float startAngle, float x, float y) | 
| CanvasPattern | createPattern(HTMLCanvasElement image, DOMString repetition) | 
| CanvasPattern | createPattern(HTMLImageElement image, DOMString repetition) | 
| void | save() | 
| void | restore() | 
| void | clearRect(float x, float y, float w, float h) | 
| void | fillRect(float x, float y, float w, float h) | 
| void | strokeRect(float x, float y, float w, float h) | 
| void | fillText(DOMString text, float x, float y, optional float maxWidth) | 
| void | strokeText(DOMString text, float x, float y, optional float maxWidth) | 
| TextMetrics | measureText(DOMString text) | 
| void | drawImage(HTMLCanvasElement image, float dx, float dy) | 
| void | drawImage(HTMLCanvasElement image, float dx, float dy, float dw, float dh) | 
| void | drawImage(HTMLCanvasElement image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) | 
| void | drawImage(HTMLVideoElement image, float dx, float dy) | 
| void | drawImage(HTMLVideoElement image, float dx, float dy, float dw, float dh) | 
| void | drawImage(HTMLVideoElement image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) | 
| void | drawImage(HTMLImageElement image, float dx, float dy) | 
| void | drawImage(HTMLImageElement image, float dx, float dy, float dw, float dh) | 
| void | drawImage(HTMLImageElement image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) | 
| void | scale(float x, float y) | 
| void | rotate(float angle) | 
| void | translate(float x, float y) | 
| void | transform(float a, float b, float c, float d, float e, float f) | 
| void | setTransform(float a, float b, float c, float d, float e, float f) | 
| void | beginPath() | 
| void | fill() | 
| void | stroke() | 
| void | drawFocusIfNeeded(Element element) | 
| void | clip() | 
| void | closePath() | 
| void | moveTo(float x, float y) | 
| void | lineTo(float x, float y) | 
| void | quadraticCurveTo(float cpx, float cpy, float x, float y) | 
| void | bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y) | 
| void | arcTo(float x1, float y1, float x2, float y2, float radius) | 
| void | rect(float x, float y, float w, float h) | 
| void | arc(float x, float y, float radius, float startAngle, float endAngle, optional boolean counterclockwise =false) | 
Public Attributes
| Name | |
|---|---|
| readonly attributeHTMLCanvasElement | canvas | 
| attribute float | globalAlpha | 
| attribute DOMString | globalCompositeOperation | 
| attribute float | lineWidth | 
| attribute DOMString | lineCap | 
| attribute DOMString | lineJoin | 
| attribute float | miterLimit | 
| attribute DOMString | font Specifies the current text style to use when drawing text. This string uses the same syntax as the CSS font specifier. | 
| attribute DOMString | textAlign | 
| attribute DOMString | textBaseline | 
| attribute float | shadowOffsetX | 
| attribute float | shadowOffsetY | 
| attribute float | shadowBlur | 
| attribute DOMString | shadowColor | 
| attribute boolean | enableFastLineSegmentDrawing | 
Public Functions Documentation
function attribute
attribute(
    DOMString or CanvasGradient or CanvasPattern
)
function attribute
attribute(
    DOMString or CanvasGradient or CanvasPattern
)
function createLinearGradient
CanvasGradient createLinearGradient(
    float x0,
    float y0,
    float x1,
    float y1
)
function createRadialGradient
CanvasGradient createRadialGradient(
    float x0,
    float y0,
    float r0,
    float x1,
    float y1,
    float r1
)
function createConicGradient
CanvasGradient createConicGradient(
    float startAngle,
    float x,
    float y
)
function createPattern
CanvasPattern createPattern(
    HTMLCanvasElement image,
    DOMString repetition
)
function createPattern
CanvasPattern createPattern(
    HTMLImageElement image,
    DOMString repetition
)
function save
void save()
function restore
void restore()
function clearRect
void clearRect(
    float x,
    float y,
    float w,
    float h
)
function fillRect
void fillRect(
    float x,
    float y,
    float w,
    float h
)
function strokeRect
void strokeRect(
    float x,
    float y,
    float w,
    float h
)
function fillText
void fillText(
    DOMString text,
    float x,
    float y,
    optional float maxWidth
)
function strokeText
void strokeText(
    DOMString text,
    float x,
    float y,
    optional float maxWidth
)
function measureText
TextMetrics measureText(
    DOMString text
)
function drawImage
void drawImage(
    HTMLCanvasElement image,
    float dx,
    float dy
)
function drawImage
void drawImage(
    HTMLCanvasElement image,
    float dx,
    float dy,
    float dw,
    float dh
)
function drawImage
void drawImage(
    HTMLCanvasElement image,
    float sx,
    float sy,
    float sw,
    float sh,
    float dx,
    float dy,
    float dw,
    float dh
)
function drawImage
void drawImage(
    HTMLVideoElement image,
    float dx,
    float dy
)
function drawImage
void drawImage(
    HTMLVideoElement image,
    float dx,
    float dy,
    float dw,
    float dh
)
function drawImage
void drawImage(
    HTMLVideoElement image,
    float sx,
    float sy,
    float sw,
    float sh,
    float dx,
    float dy,
    float dw,
    float dh
)
function drawImage
void drawImage(
    HTMLImageElement image,
    float dx,
    float dy
)
function drawImage
void drawImage(
    HTMLImageElement image,
    float dx,
    float dy,
    float dw,
    float dh
)
function drawImage
void drawImage(
    HTMLImageElement image,
    float sx,
    float sy,
    float sw,
    float sh,
    float dx,
    float dy,
    float dw,
    float dh
)
function scale
void scale(
    float x,
    float y
)
function rotate
void rotate(
    float angle
)
function translate
void translate(
    float x,
    float y
)
function transform
void transform(
    float a,
    float b,
    float c,
    float d,
    float e,
    float f
)
function setTransform
void setTransform(
    float a,
    float b,
    float c,
    float d,
    float e,
    float f
)
function beginPath
void beginPath()
function fill
void fill()
function stroke
void stroke()
function drawFocusIfNeeded
void drawFocusIfNeeded(
    Element element
)
function clip
void clip()
function closePath
void closePath()
function moveTo
void moveTo(
    float x,
    float y
)
function lineTo
void lineTo(
    float x,
    float y
)
function quadraticCurveTo
void quadraticCurveTo(
    float cpx,
    float cpy,
    float x,
    float y
)
function bezierCurveTo
void bezierCurveTo(
    float cp1x,
    float cp1y,
    float cp2x,
    float cp2y,
    float x,
    float y
)
function arcTo
void arcTo(
    float x1,
    float y1,
    float x2,
    float y2,
    float radius
)
function rect
void rect(
    float x,
    float y,
    float w,
    float h
)
function arc
void arc(
    float x,
    float y,
    float radius,
    float startAngle,
    float endAngle,
    optional boolean counterclockwise =false
)
Public Attributes Documentation
variable canvas
readonly attributeHTMLCanvasElement canvas;
variable globalAlpha
attribute float globalAlpha;
variable globalCompositeOperation
attribute DOMString globalCompositeOperation;
variable lineWidth
attribute float lineWidth;
variable lineCap
attribute DOMString lineCap;
variable lineJoin
attribute DOMString lineJoin;
variable miterLimit
attribute float miterLimit;
variable font
attribute DOMString font;
Specifies the current text style to use when drawing text. This string uses the same syntax as the CSS font specifier.
Note: Currently supports only “bold”, “italic”, font-size in pixels and a single font-family. Font fallback is not supported.
Warning: Canvas can only draw with already loaded fonts.
variable textAlign
attribute DOMString textAlign;
variable textBaseline
attribute DOMString textBaseline;
variable shadowOffsetX
attribute float shadowOffsetX;
variable shadowOffsetY
attribute float shadowOffsetY;
variable shadowBlur
attribute float shadowBlur;
variable shadowColor
attribute DOMString shadowColor;
variable enableFastLineSegmentDrawing
attribute boolean enableFastLineSegmentDrawing;