WARNING: Most of this content (with the exception of the Mozilla 1.9 XPCOM reference) is very old, and can be expected to be out of date and possibly obsolete. For better XUL documentation, please visit the XUL hub at the Mozilla Developer Center.

nsIDOMCanvasRenderingContext2D

IID:87d2b1c4-b64e-41f6-98f7-7ac4244ce9bf
Inherits From:nsISupports

Properties

readonly nsIDOMHTMLCanvasElement canvas

nsIVariant fillStyle

float globalAlpha

DOMString globalCompositeOperation

DOMString lineCap

DOMString lineJoin

float lineWidth

float miterLimit

DOMString mozTextStyle

float shadowBlur

DOMString shadowColor

float shadowOffsetX

float shadowOffsetY

nsIVariant strokeStyle


Methods

void arc ( float x , float y , float r , float startAngle , float endAngle , PRBool clockwise ) void arcTo ( float x1 , float y1 , float x2 , float y2 , float radius ) void beginPath ( ) void bezierCurveTo ( float cp1x , float cp1y , float cp2x , float cp2y , float x , float y ) void clearRect ( float x , float y , float w , float h ) void clip ( ) void closePath ( ) nsIDOMCanvasGradient createLinearGradient ( float x0 , float y0 , float x1 , float y1 ) nsIDOMCanvasPattern createPattern ( nsIDOMHTMLElement image , DOMString repetition ) nsIDOMCanvasGradient createRadialGradient ( float x0 , float y0 , float r0 , float x1 , float y1 , float r1 ) void drawImage ( ) void drawWindow ( nsIDOMWindow window , PRInt32 x , PRInt32 y , PRInt32 w , PRInt32 h , DOMString bgColor ) void fill ( ) void fillRect ( float x , float y , float w , float h ) void getImageData ( ) PRBool isPointInPath ( float x , float y ) void lineTo ( float x , float y ) void moveTo ( float x , float y ) void mozDrawText ( DOMString textToDraw ) float mozMeasureText ( DOMString textToMeasure ) void mozPathText ( DOMString textToPath ) void mozTextAlongPath ( DOMString textToDraw , PRBool stroke ) void putImageData ( ) void quadraticCurveTo ( float cpx , float cpy , float x , float y ) void rect ( float x , float y , float w , float h ) void restore ( ) void rotate ( float angle ) void save ( ) void scale ( float x , float y ) void setTransform ( float m11 , float m12 , float m21 , float m22 , float dx , float dy ) void stroke ( ) void strokeRect ( float x , float y , float w , float h ) void transform ( float m11 , float m12 , float m21 , float m22 , float dx , float dy ) void translate ( float x , float y )

void arc ( float x , float y , float r , float startAngle , float endAngle , PRBool clockwise )

Arguments:
x
y
r
startAngle
endAngle
clockwise

void arcTo ( float x1 , float y1 , float x2 , float y2 , float radius )

Arguments:
x1
y1
x2
y2
radius

void beginPath ( )


void bezierCurveTo ( float cp1x , float cp1y , float cp2x , float cp2y , float x , float y )

Arguments:
cp1x
cp1y
cp2x
cp2y
x
y

void clearRect ( float x , float y , float w , float h )

Arguments:
x
y
w
h

void clip ( )


void closePath ( )


nsIDOMCanvasGradient createLinearGradient ( float x0 , float y0 , float x1 , float y1 )

Arguments:
x0
y0
x1
y1

nsIDOMCanvasPattern createPattern ( nsIDOMHTMLElement image , DOMString repetition )

Arguments:
image
repetition

nsIDOMCanvasGradient createRadialGradient ( float x0 , float y0 , float r0 , float x1 , float y1 , float r1 )

Arguments:
x0
y0
r0
x1
y1
r1

void drawImage ( )


void drawWindow ( nsIDOMWindow window , PRInt32 x , PRInt32 y , PRInt32 w , PRInt32 h , DOMString bgColor )

Renders a region of a window into the canvas. The contents of the window's viewport are rendered, ignoring viewport clipping and scrolling.

Of course, the rendering obeys the current scale, transform and globalAlpha values.

Hints: -- If 'rgba(0,0,0,0)' is used for the background color, the drawing will be transparent wherever the window is transparent. -- Top-level browsed documents are usually not transparent because the user's background-color preference is applied, but IFRAMEs are transparent if the page doesn't set a background. -- If an opaque color is used for the background color, rendering will be faster because we won't have to compute the window's transparency.

This API cannot currently be used by Web content. It is chrome only.

Arguments:
window
x
y
w
h: specify the area of the window to render, in CSS pixels.
bgColor

void fill ( )


void fillRect ( float x , float y , float w , float h )

Arguments:
x
y
w
h

void getImageData ( )


PRBool isPointInPath ( float x , float y )

Arguments:
x
y

void lineTo ( float x , float y )

Arguments:
x
y

void moveTo ( float x , float y )

Arguments:
x
y

void mozDrawText ( DOMString textToDraw )

Arguments:
textToDraw

float mozMeasureText ( DOMString textToMeasure )

Arguments:
textToMeasure

void mozPathText ( DOMString textToPath )

Arguments:
textToPath

void mozTextAlongPath ( DOMString textToDraw , PRBool stroke )

Arguments:
textToDraw
stroke

void putImageData ( )


void quadraticCurveTo ( float cpx , float cpy , float x , float y )

Arguments:
cpx
cpy
x
y

void rect ( float x , float y , float w , float h )

Arguments:
x
y
w
h

void restore ( )


void rotate ( float angle )

Arguments:
angle

void save ( )


void scale ( float x , float y )

Arguments:
x
y

void setTransform ( float m11 , float m12 , float m21 , float m22 , float dx , float dy )

Arguments:
m11
m12
m21
m22
dx
dy

void stroke ( )


void strokeRect ( float x , float y , float w , float h )

Arguments:
x
y
w
h

void transform ( float m11 , float m12 , float m21 , float m22 , float dx , float dy )

Arguments:
m11
m12
m21
m22
dx
dy

void translate ( float x , float y )

Arguments:
x
y

Reference documentation is generated from Mozilla's source.