public class Canvas2d extends Surface
backgroundSprite, component, container, height, sprites, surfaceElement, width
Constructor and Description |
---|
Canvas2d() |
Modifier and Type | Method and Description |
---|---|
protected void |
append(Sprite sprite)
In the Canvas2d class, this method does more or less what renderSprite does in SVG and VML - it
actually renders the sprite to the dom.
|
protected void |
appendAll() |
protected void |
appendPath(Context2d ctx,
PathSprite sprite) |
void |
draw()
Renders the surface to the DOM as well as any sprites already added.
|
protected PreciseRectangle |
getBBoxText(TextSprite sprite)
Calculates the bounding box of the given text sprite.
|
protected CanvasElement |
getCanvas() |
protected Context2d |
getContext() |
protected CanvasGradient |
makeGradient(Gradient gradient,
PreciseRectangle bbox) |
protected void |
renderAll()
Renders all of the sprites added to the surface using
Surface.renderSprite(Sprite) . |
void |
renderSprite(Sprite sprite)
Renders the given sprite to the DOM.
|
void |
setCursor(Sprite sprite,
String property)
Sets the cursor property for the given sprite.
|
void |
setHeight(int height)
Sets the height of the surface.
|
void |
setViewBox(double x,
double y,
double width,
double height)
Sets the view box of the surface.
|
void |
setWidth(int width)
Sets the width of the surface.
|
add, addGradient, clear, create, create, deleteSprite, getBBox, getComponent, getHeight, getSprites, getSurfaceElement, getWidth, setBackground
public void draw()
Surface
protected void renderAll()
Surface
Surface.renderSprite(Sprite)
.protected void appendAll()
public void renderSprite(Sprite sprite)
Surface
renderSprite
in class Surface
sprite
- the sprite to be renderedprotected void append(Sprite sprite)
sprite
- the sprite to drawprotected void appendPath(Context2d ctx, PathSprite sprite)
public void setCursor(Sprite sprite, String property)
Surface
public void setViewBox(double x, double y, double width, double height)
Surface
setViewBox
in class Surface
x
- the x coordinate of the viewboxy
- the y coordinate of the viewboxwidth
- the width of the viewboxheight
- the height of the viewboxprotected PreciseRectangle getBBoxText(TextSprite sprite)
Surface
getBBoxText
in class Surface
sprite
- the text sprite to be used in the calculationprotected CanvasElement getCanvas()
protected Context2d getContext()
public void setWidth(int width)
Surface
public void setHeight(int height)
Surface
protected CanvasGradient makeGradient(Gradient gradient, PreciseRectangle bbox)
Copyright © 2018. All rights reserved.