Class Index | File Index

Classes


Class Graphics2D


Defined in: graphics2d.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Graphics2D(canvas)
This class is a wrapper that implements 2D drawing functions on a canvas.
Method Summary
Method Attributes Method Name and Description
 
Clears the canvas.
 
clip(clip)
Adds the given clip to the current clip.
 
clipRect(x, y, width, height)
Sets the current clip as a rectangle region.
 
Creates a pattern from an image.
 
draw(shape)
Draws a shape on the canvas using the current stroke.
 
drawImage(img, x, y, bgcolor)
Draws an image on the canvas.
 
drawImageWithSize(img, x, y, width, height, bgcolor)
Draws an image on the canvas.
 
drawString(str, x, y)
Draws a string with the current paint.
 
drawStringOutline(str, x, y)
Draws a string outline with the current stroke.
 
fill(shape)
Fills a shape on the canvas using the current paint.
 
fillRect(x, y, width, height)
Fills the given rectangular region with the current paint.
 
Gets the alpha component of the canvas.
 
Gets the fill style.
 
Gets the current clip.
 
Gets the current color.
 
Gets the wrapped canvas context.
 
Gets the current font.
 
Gets the current paint.
 
Gets the current transform matrix.
 
rotate(theta, x, y)
Rotates the canvas current transform matrix.
 
scale(sx, sy)
Scales the canvas current transform matrix.
 
setAlpha(alpha)
Sets the alpha component for all subsequent drawing and fill operations.
 
Sets the fill style as a color.
 
setClip(clip)
Sets the current clip.
 
setColor(color)
Sets the current stroke and fill style as a CSS style.
 
setFont(font)
Sets the current font.
 
setPaint(paint)
Sets the current paint.
 
Sets the current stroke.
 
setTransform(transform)
Sets (overrides) the current transform matrix.
 
shear(shx, shy)
Shears the canvas current transform matrix.
 
transform(transform)
Applies the given transform matrix to the current transform matrix.
 
translate(x, y)
Translates the canvas transform matrix.
Class Detail
Graphics2D(canvas)
This class is a wrapper that implements 2D drawing functions on a canvas. Creates a new instance wrapping the given HTML canvas.
Author: Renaud Pawlak, Emmanuel Puybaret.
Parameters:
canvas
Method Detail
clear()
Clears the canvas.

clip(clip)
Adds the given clip to the current clip.
Parameters:
{java.awt.Shape} clip
the added clip as a shape

clipRect(x, y, width, height)
Sets the current clip as a rectangle region.
Parameters:
{number} x
{number} y
{number} width
{number} height

createPattern(image)
Creates a pattern from an image.
Parameters:
{HTMLImageElement} image
Returns:
CanvasPattern

draw(shape)
Draws a shape on the canvas using the current stroke.
Parameters:
{java.awt.Shape} shape
the shape to be drawn

drawImage(img, x, y, bgcolor)
Draws an image on the canvas.
Parameters:
{HTMLImageElement} img
the image to be drawn
{number} x
{number} y
{string} bgcolor Optional

drawImageWithSize(img, x, y, width, height, bgcolor)
Draws an image on the canvas.
Parameters:
{HTMLImageElement} img
the image to be drawn
{number} x
{number} y
{number} width
{number} height
{string} bgcolor Optional

drawString(str, x, y)
Draws a string with the current paint.
Parameters:
{string} str
{number} x
{number} y

drawStringOutline(str, x, y)
Draws a string outline with the current stroke.
Parameters:
{string} str
{number} x
{number} y

fill(shape)
Fills a shape on the canvas using the current paint.
Parameters:
{java.awt.Shape} shape
the shape to be filled

fillRect(x, y, width, height)
Fills the given rectangular region with the current paint.
Parameters:
{number} x
{number} y
{number} width
{number} height

{number} getAlpha()
Gets the alpha component of the canvas.
Returns:
{number}

{string} getBackground()
Gets the fill style.
Returns:
{string} a CSS color descriptor

{java.awt.Shape} getClip()
Gets the current clip.
Returns:
{java.awt.Shape} the clip as a shape

getColor()
Gets the current color.

getContext()
Gets the wrapped canvas context.

{string} getFont()
Gets the current font.
Returns:
{string} a CSS font descriptor

{string|CanvasPattern} getPaint()
Gets the current paint.
Returns:
{string|CanvasPattern}

{java.awt.geom.AffineTransform} getTransform()
Gets the current transform matrix.
Returns:
{java.awt.geom.AffineTransform} the current transform matrix

rotate(theta, x, y)
Rotates the canvas current transform matrix.
Parameters:
{number} theta
the rotation angle
{number} x Optional
the rotation origin (x)
{number} y Optional
the rotation origin (y)

scale(sx, sy)
Scales the canvas current transform matrix.
Parameters:
{number} sx
the x scale factor
{number} sy
the y scale factor

setAlpha(alpha)
Sets the alpha component for all subsequent drawing and fill operations.
Parameters:
{number} alpha

setBackground(color)
Sets the fill style as a color.
Parameters:
{string} color
a CSS color descriptor

setClip(clip)
Sets the current clip.
Parameters:
{java.awt.Shape} clip
the clip as a shape

setColor(color)
Sets the current stroke and fill style as a CSS style.
Parameters:
{string} color
a CSS style

setFont(font)
Sets the current font.
Parameters:
{string} font
a CSS font descriptor

setPaint(paint)
Sets the current paint.
Parameters:
{string|CanvasPattern} paint

setStroke(s)
Sets the current stroke.
Parameters:
s

setTransform(transform)
Sets (overrides) the current transform matrix.
Parameters:
{java.awt.geom.AffineTransform} transform
the new transform matrix

shear(shx, shy)
Shears the canvas current transform matrix.
Parameters:
{number} shx
the x shear factor
{number} shy
the y shear factor

transform(transform)
Applies the given transform matrix to the current transform matrix.
Parameters:
{java.awt.geom.AffineTransform} transform
the transform matrix to be applied

translate(x, y)
Translates the canvas transform matrix.
Parameters:
{number} x
{number} y

© Copyright 2021 Emmanuel PUYBARET / eTeks
Distributed under GNU General Public License
Documentation generated by JsDoc Toolkit 2.4.0 on Tue Mar 02 2021 19:55:52 GMT+0100 (CET)