java.lang.Object | ||
↳ | com.google.gwt.core.client.JavaScriptObject | |
↳ | com.google.gwt.canvas.dom.client.Context2d |
Rendering interface used to draw on a CanvasElement
.
Experimental API: This API is still under development and is subject to change.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Context2d.Composite | Enum for composite style. | ||||||||||
Context2d.LineCap | Enum for line-cap style. | ||||||||||
Context2d.LineJoin | Enum for line-join style. | ||||||||||
Context2d.Repetition | Enum for the repetition values. | ||||||||||
Context2d.TextAlign | Enum for text align style. | ||||||||||
Context2d.TextBaseline | Enum for text baseline style. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | CONTEXT_ID | Specifies the context id property used in creating a Context. |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Draws an arc.
| |||||||||||
Draws an arc.
| |||||||||||
Adds an arc to the current subpath, connecting it to the current point
with a line segment.
| |||||||||||
Begins a new path.
| |||||||||||
Draws a cubic Bézier curve from the current point to the point
(x, y), with control points (cp1x, cp1y) and (cp2x, cp2y).
| |||||||||||
Clears a rectangle.
| |||||||||||
Creates a new clipping region from the current path.
| |||||||||||
Closes the current path.
| |||||||||||
Creates an image data object of the same size as the given object.
| |||||||||||
Creates an image data object of the given size.
| |||||||||||
Creates a linear gradient.
| |||||||||||
Creates a pattern from another canvas.
| |||||||||||
Creates a pattern from an image.
| |||||||||||
Creates a pattern from another canvas.
| |||||||||||
Creates a pattern from an image.
| |||||||||||
Creates a radial gradient.
| |||||||||||
Draws a scaled subset of an image.
| |||||||||||
Draws a scaled image.
| |||||||||||
Draws a scaled image.
| |||||||||||
Draws an image.
| |||||||||||
Draws an image.
| |||||||||||
Draws a scaled subset of an image.
| |||||||||||
Fills the current path.
| |||||||||||
Fills a rectangle.
| |||||||||||
Draws filled text.
| |||||||||||
Draws filled text squeezed into the given max width.
| |||||||||||
Gets this context's canvas.
| |||||||||||
Returns the context's fillStyle.
| |||||||||||
Gets this context's font.
| |||||||||||
Gets the global alpha value.
| |||||||||||
Gets the global composite operation.
| |||||||||||
Returns an image data object for the screen area denoted by
sx, sy, sw and sh.
| |||||||||||
Gets the current line-cap style.
| |||||||||||
Gets the current line-join style.
| |||||||||||
Gets the current line-width.
| |||||||||||
Gets the current miter-limit.
| |||||||||||
Gets the current shadow-blur.
| |||||||||||
Gets the current shadow color.
| |||||||||||
Gets the current x-shadow-offset.
| |||||||||||
Gets the current y-shadow-offset.
| |||||||||||
Returns the context's strokeStyle.
| |||||||||||
Gets the current text align.
| |||||||||||
Gets the current text baseline.
| |||||||||||
Returns true if the given point is in the current path.
| |||||||||||
Adds a line from the current point to the point (x, y) to the current
path.
| |||||||||||
Returns the metrics for the given text.
| |||||||||||
Terminates the current path and sets the current path position to the point
(x, y).
| |||||||||||
Draws the given image data at the given screen position.
| |||||||||||
Draws a quadratic Bézier curve from the current point to the point
(x, y), with control point (cpx, cpy).
| |||||||||||
Creates a new rectangular path.
| |||||||||||
Restores the context's state.
| |||||||||||
Applies rotation to the current transform.
| |||||||||||
Saves the context's state.
| |||||||||||
Applies scale to the current transform.
| |||||||||||
Convenience method to set the context's fillStyle to a
CssColor ,
specified in String form. | |||||||||||
Sets the context's fillStyle.
| |||||||||||
Sets the font.
| |||||||||||
Sets the global alpha value.
| |||||||||||
Sets the global composite operation.
| |||||||||||
Sets the global composite operation.
| |||||||||||
Sets the line-cap style.
| |||||||||||
Sets the line-cap style.
| |||||||||||
Sets the line-join style.
| |||||||||||
Sets the line-join style.
| |||||||||||
Sets the line-width.
| |||||||||||
Sets the miter-limit.
| |||||||||||
Sets the shadow-blur.
| |||||||||||
Sets the shadow-color.
| |||||||||||
Sets the x-shadow-offset.
| |||||||||||
Sets the y-shadow-offset.
| |||||||||||
Sets the context's stroke style.
| |||||||||||
Convenience method to set the context's strokeStyle to a
CssColor . | |||||||||||
Sets the text alignment.
| |||||||||||
Sets the text alignment.
| |||||||||||
Sets the text baseline.
| |||||||||||
Sets the text baseline.
| |||||||||||
Sets the 2D transformation matrix.
| |||||||||||
Draws the current path with the current stroke style.
| |||||||||||
Draws the outline of a rectangle with the current stroke style.
| |||||||||||
Draws the text outline, squeezing the text into the given max width by
compressing the font.
| |||||||||||
Draws the text outline.
| |||||||||||
Multiplies the current transform by the given matrix.
| |||||||||||
Applies a translation to the current transform.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.gwt.core.client.JavaScriptObject
| |||||||||||
From class
java.lang.Object
|
Specifies the context id property used in creating a Context.
Draws an arc. If a current subpath exists, a line segment is added from the
current point to the starting point of the arc. If endAngle -
startAngle
is equal to or greater than 2 * Math.Pi
, the arc is the
whole circumference of the circle.
x | the x coordinate of the center of the arc |
---|---|
y | the y coordinate of the center of the arc |
radius | the radius of the arc |
startAngle | the start angle, measured in radians clockwise from the positive x-axis |
endAngle | the end angle, measured in radians clockwise from the positive x-axis |
Draws an arc. If a current subpath exists, a line segment is added from the
current point to the starting point of the arc. If anticlockwise
is
false and endAngle - startAngle
is equal to or greater than 2 * Math.PI
, or if anticlockwise
is true
and startAngle - endAngle
is equal to or greater than 2 * Math.PI
,
then the arc is the whole circumference of the circle.
x | the x coordinate of the center of the arc |
---|---|
y | the y coordinate of the center of the arc |
radius | the radius of the arc |
startAngle | the start angle, measured in radians clockwise from the positive x-axis |
endAngle | the end angle, measured in radians clockwise from the positive x-axis |
anticlockwise | if true , the arc is drawn in an anticlockwise
direction
|
Adds an arc to the current subpath, connecting it to the current point with a line segment.
x1 | the x coordinate of the starting point of the arc |
---|---|
y1 | the y coordinate of the starting point of the arc |
x2 | the x coordinate of the ending point of the arc |
y2 | the y coordinate of the ending point of the arc |
radius | the radius of a circle containing the arc |
Begins a new path.
Draws a cubic Bézier curve from the current point to the point (x, y), with control points (cp1x, cp1y) and (cp2x, cp2y).
cp1x | the x coordinate of the first control point |
---|---|
cp1y | the y coordinate of the first control point |
cp2x | the x coordinate of the second control point |
cp2y | the y coordinate of the second control point |
x | the x coordinate of the end point |
y | the y coordinate of the end point |
Clears a rectangle.
x | the x coordinate of the rectangle's upper-left corner |
---|---|
y | the y coordinate of the rectangle's upper-left corner |
w | the width of the rectangle |
h | the height of the rectangle |
Creates a new clipping region from the current path.
Closes the current path.
Creates an image data object of the given size.
w | the width of the image |
---|---|
h | the height of the image |
ImageData
object
Creates a linear gradient.
x0 | the x coordinate of the starting point of the gradient |
---|---|
y0 | the y coordinate of the starting point of the gradient |
x1 | the x coordinate of the ending point of the gradient |
y1 | the y coordinate of the ending point of the gradient |
CanvasGradient
object
Creates a pattern from another canvas.
image | an CanvasElement object |
---|---|
repetition | the repetition type as a String |
CanvasPattern
object
Creates a pattern from an image.
image | an ImageElement object |
---|---|
repetition | the repetition type as a String |
CanvasPattern
object
Creates a pattern from another canvas.
image | an CanvasElement object |
---|---|
repetition | a Context2d.Repetition object |
CanvasPattern
object
Creates a pattern from an image.
image | an ImageElement object |
---|---|
repetition | a Context2d.Repetition object |
CanvasPattern
object
Creates a radial gradient.
x0 | the x coordinate of the center of the start circle of the gradient |
---|---|
y0 | the y coordinate of the center of the start circle of the gradient |
r0 | the radius of the start circle of the gradient |
x1 | the x coordinate of the center of the end circle of the gradient |
y1 | the y coordinate of the center of the end circle of the gradient |
r1 | the radius of the end circle of the gradient |
CanvasGradient
object
Draws a scaled subset of an image.
image | an ImageElement object |
---|---|
sx | the x coordinate of the upper-left corner of the source rectangle |
sy | the y coordinate of the upper-left corner of the source rectangle |
sw | the width of the source rectangle |
sh | the width of the source rectangle |
dx | the x coordinate of the upper-left corner of the destination rectangle |
dy | the y coordinate of the upper-left corner of the destination rectangle |
dw | the width of the destination rectangle |
dh | the height of the destination rectangle |
Draws a scaled image.
image | an CanvasElement object |
---|---|
dx | the x coordinate of the upper-left corner of the destination rectangle |
dy | the y coordinate of the upper-left corner of the destination rectangle |
dw | the width of the destination rectangle |
dh | the height of the destination rectangle |
Draws a scaled image.
image | an ImageElement object |
---|---|
dx | the x coordinate of the upper-left corner of the destination rectangle |
dy | the y coordinate of the upper-left corner of the destination rectangle |
dw | the width of the destination rectangle |
dh | the height of the destination rectangle |
Draws an image.
image | an CanvasElement object |
---|---|
dx | the x coordinate of the upper-left corner of the destination rectangle |
dy | the y coordinate of the upper-left corner of the destination rectangle |
Draws an image.
image | an ImageElement object |
---|---|
dx | the x coordinate of the upper-left corner of the destination rectangle |
dy | the y coordinate of the upper-left corner of the destination rectangle |
Draws a scaled subset of an image.
image | an CanvasElement object |
---|---|
sx | the x coordinate of the upper-left corner of the source rectangle |
sy | the y coordinate of the upper-left corner of the source rectangle |
sw | the width of the source rectangle |
sh | the width of the source rectangle |
dx | the x coordinate of the upper-left corner of the destination rectangle |
dy | the y coordinate of the upper-left corner of the destination rectangle |
dw | the width of the destination rectangle |
dh | the height of the destination rectangle |
Fills the current path.
Fills a rectangle.
x | the x coordinate of the rectangle's upper-left corner |
---|---|
y | the y coordinate of the rectangle's upper-left corner |
w | the width of the rectangle |
h | the height of the rectangle |
Draws filled text.
text | the text as a String |
---|---|
x | the x coordinate of the text position |
y | the y coordinate of the text position |
Draws filled text squeezed into the given max width.
text | the text as a String |
---|---|
x | the x coordinate of the text position |
y | the y coordinate of the text position |
maxWidth | the maximum width for the text |
Returns the context's fillStyle. In dev mode, the returned object will be wrapped in a JavaScript array.
FillStrokeStyle
objectGets the global alpha value.
Gets the global composite operation.
Returns an image data object for the screen area denoted by sx, sy, sw and sh.
sx | the x coordinate of the upper-left corner of the desired area |
---|---|
sy | the y coordinate of the upper-left corner of the desired area |
sw | the width of the desired area |
sh | the height of the desired area |
ImageData
object containing screen pixel data
Gets the current line-cap style.
Gets the current line-join style.
Gets the current shadow-blur.
Gets the current x-shadow-offset.
Gets the current y-shadow-offset.
Returns the context's strokeStyle. In dev mode, the returned object will be wrapped in a JavaScript array.
FillStrokeStyle
objectGets the current text baseline.
Returns true if the given point is in the current path.
x | the x coordinate of the point to test. |
---|---|
y | the y coordinate of the point to test. |
true
if the given point is in the current path.
Adds a line from the current point to the point (x, y) to the current path.
x | the x coordinate of the line endpoint |
---|---|
y | the y coordinate of the line endpoint |
Returns the metrics for the given text.
text | the text to measure, as a String |
---|
TextMetrics
object
Terminates the current path and sets the current path position to the point (x, y).
x | the x coordinate of the new position |
---|---|
y | the y coordinate of the new position |
Draws the given image data at the given screen position.
imagedata | an ImageData instance to be written to the screen |
---|---|
x | the x coordinate of the upper-left corner at which to draw |
y | the y coordinate of the upper-left corner at which to draw |
Draws a quadratic Bézier curve from the current point to the point (x, y), with control point (cpx, cpy).
cpx | the x coordinate of the control point |
---|---|
cpy | the y coordinate of the control point |
x | the x coordinate of the end point |
y | the y coordinate of the end point |
Creates a new rectangular path.
x | the x coordinate of the rectangle's upper-left corner |
---|---|
y | the y coordinate of the rectangle's upper-left corner |
w | the width of the rectangle |
h | the height of the rectangle |
Restores the context's state.
Applies rotation to the current transform.
angle | the clockwise rotation angle, in radians |
---|
Saves the context's state.
Applies scale to the current transform.
x | the scale factor along the x-axis |
---|---|
y | the scale factor along the y-axis |
Convenience method to set the context's fillStyle to a CssColor
,
specified in String form.
fillStyleColor | the color as a String |
---|
Sets the context's fillStyle.
fillStyle | the fill style to set. |
---|
Sets the global alpha value.
alpha | the global alpha value as a double |
---|
Sets the global composite operation.
globalCompositeOperation | the operation as a String |
---|
Sets the line-cap style.
lineCap | the line cap style as a Context2d.LineCap value |
---|
Sets the line-join style.
lineJoin | the ling join style as a String |
---|
Sets the line-join style.
lineJoin | the line join style as a Context2d.LineJoin value |
---|
Sets the line-width.
lineWidth | the line width as a double |
---|
Sets the shadow-color.
shadowColor | the shadow color as a String |
---|
Sets the x-shadow-offset.
shadowOffsetX | the x shadow offset |
---|
Sets the y-shadow-offset.
shadowOffsetY | the y shadow offset |
---|
Sets the context's stroke style.
strokeStyle | the stroke style to set |
---|
Convenience method to set the context's strokeStyle to a CssColor
.
strokeStyleColor | the stroke color as a String |
---|
Sets the text alignment.
align | the alignment setting as a Context2d.TextAlign value |
---|
Sets the text baseline.
baseline | the baseline setting as a String |
---|
Sets the text baseline.
baseline | a the baseline setting as a Context2d.TextBaseline value |
---|
Sets the 2D transformation matrix.
m11 | the value at position (1, 1) of the matrix |
---|---|
m12 | the value at position (1, 2) of the matrix |
m21 | the value at position (2, 1) of the matrix |
m22 | the value at position (2, 2) of the matrix |
dx | the x translation value |
dy | the y translation value |
Draws the current path with the current stroke style.
Draws the outline of a rectangle with the current stroke style.
x | the x coordinate of the rectangle's upper-left corner |
---|---|
y | the y coordinate of the rectangle's upper-left corner |
w | the width of the rectangle |
h | the height of the rectangle |
Draws the text outline, squeezing the text into the given max width by compressing the font.
text | the text as a String |
---|---|
x | the x coordinate of the text position |
y | the y coordinate of the text position |
maxWidth | the maximum width for the text |
Draws the text outline.
text | the text as a String |
---|---|
x | the x coordinate of the text position |
y | the y coordinate of the text position |
Multiplies the current transform by the given matrix.
m11 | the value at position (1, 1) of the matrix |
---|---|
m12 | the value at position (1, 2) of the matrix |
m21 | the value at position (2, 1) of the matrix |
m22 | the value at position (2, 2) of the matrix |
dx | the x translation value |
dy | the y translation value |
Applies a translation to the current transform.
x | the amount of translation along the x-axis |
---|---|
y | the amount of translation along the y-axis |