CanvasRenderingContext2D

This object is available to unprivileged JavaScript. It implements the following interfaces:

Properties

readonly HTMLCanvasElement canvas

nsIVariant fillStyle

float globalAlpha

String globalCompositeOperation

String lineCap

String lineJoin

float lineWidth

float miterLimit

float shadowBlur

String shadowColor

float shadowOffsetX

float shadowOffsetY

nsIVariant strokeStyle


Methods

void arc ( float x , float y , float r , float startAngle , float endAngle , boolean 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 ( ) CanvasGradient createLinearGradient ( float x0 , float y0 , float x1 , float y1 ) CanvasPattern createPattern ( HTMLImageElement image , String repetition ) CanvasGradient createRadialGradient ( float x0 , float y0 , float r0 , float x1 , float y1 , float r1 ) void drawImage ( ) void drawWindow ( Window window , PRInt32 x , PRInt32 y , PRInt32 w , PRInt32 h , String bgColor ) void fill ( ) void fillRect ( float x , float y , float w , float h ) void lineTo ( float x , float y ) void moveTo ( float x , float y ) 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 stroke ( ) void strokeRect ( float x , float y , float w , float h ) void translate ( float x , float y )

void arc ( float x , float y , float r , float startAngle , float endAngle , boolean 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 ( )


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

Arguments:
x0
y0
x1
y1

CanvasPattern createPattern ( HTMLImageElement image , String repetition )

Arguments:
image
repetition

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

Arguments:
x0
y0
r0
x1
y1
r1

void drawImage ( )


void drawWindow ( Window window , PRInt32 x , PRInt32 y , PRInt32 w , PRInt32 h , String 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 lineTo ( float x , float y )

Arguments:
x
y

void moveTo ( float x , float y )

Arguments:
x
y

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 stroke ( )


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

Arguments:
x
y
w
h

void translate ( float x , float y )

Arguments:
x
y

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
No comments available

Copyright © 1999 - 2005 XULPlanet.com