Canvas
- The native Canvaspublic interface GraphicsEnvironment<Canvas>
GraphicsContext2D
GraphicsContext2D
Modifier and Type | Method and Description |
---|---|
void |
arc(Canvas canvas,
double centerX,
double centerY,
double radius,
double startAngle,
double endAngle,
boolean acw)
Adds path elements to the current path to make an arc.
|
void |
arcTo(Canvas canvas,
double x1,
double y1,
double x2,
double y2,
double radius)
Adds segments to the current path to make an arc.
|
void |
beginPath(Canvas canvas)
Starts a Path
|
void |
bezierCurveTo(Canvas canvas,
double cp1x,
double cp1y,
double cp2x,
double cp2y,
double x,
double y)
Adds segments to the current path to make a cubic bezier curve.
|
void |
clearRect(Canvas canvas,
double x,
double y,
double width,
double height)
Clears a portion of the canvas with a transparent color value.
|
void |
clip(Canvas canvas)
Clips using the current path
|
void |
closePath(Canvas canvas)
Closes the path.
|
ImageData |
createPixelMap(Canvas canvas,
double x,
double y)
Get a pixel array that you can manipulate, e.g.
|
ImageData |
createPixelMap(Canvas canvas,
double x,
double y,
int[] all)
Get a pixel array that you can manipulate, e.g.
|
ImageData |
createPixelMap(Canvas canvas,
ImageData imageData)
Create a new ImageData object with the same dimensions as the
object specified by imageData (this does not copy the image data)
|
Object |
drawImage(Canvas canvas,
Image image,
double sx,
double sy,
double sWidth,
double sHeight,
double x,
double y,
double width,
double height,
Object nativeImage)
Draws the current source rectangle of the given image to the given
destination rectangle of the Canvas.
|
Object |
drawImage(Canvas canvas,
Image image,
double x,
double y,
double width,
double height,
Object nativeImage)
Draws an image into the given destination rectangle of the canvas.
|
Object |
drawImage(Canvas canvas,
Image image,
double x,
double y,
Object nativeImage)
Draws an image at the given x, y position using the width and height of
the given image.
|
void |
fill(Canvas canvas)
Fills the path with the current fill paint.
|
void |
fillRect(Canvas canvas,
double x,
double y,
double width,
double height)
Fills a rectangle using the current fill paint.
|
void |
fillText(Canvas canvas,
String text,
double x,
double y)
Fills the given string of text at position x, y (0,0 at top left) with
the current fill paint attribute.
|
void |
fillText(Canvas canvas,
String text,
double x,
double y,
double maxWidth)
Fills text and includes a maximum width of the string.
|
String |
getFont(Canvas canvas)
Gets the current Font.
|
double |
getGlobalAlpha(Canvas canvas)
Get the global alpha of the current state.
|
String |
getGlobalCompositeOperation(Canvas canvas)
Gets the global blend mode.
|
int |
getHeight(Canvas canvas)
Get the height of this GraphicsContext2D (which should be the same as the
enclosing canvas height)
|
int |
getHeight(Canvas canvas,
Image image,
Object nativeImage)
Get the height of this Image
|
String |
getLineCap(Canvas canvas)
Gets the current stroke line cap.
|
String |
getLineJoin(Canvas canvas)
Gets the current stroke line join.
|
double |
getLineWidth(Canvas canvas)
Gets the current line width.
|
double |
getMiterLimit(Canvas canvas)
Gets the current miter limit.
|
Canvas |
getOrCreateCanvas(String id)
Get the Canvas with this ID or create it.
|
ImageData |
getPixelMap(Canvas canvas,
double x,
double y,
double width,
double height)
Get the pixels for a region of your GraphicsContext2D
|
String |
getTextAlign(Canvas canvas)
Gets the current
TextAlignment . |
String |
getTextBaseline(Canvas canvas)
Sets the current Text Baseline.
|
int |
getWidth(Canvas canvas)
Get the width of this GraphicsContext2D (which should be the same as the
enclosing canvas height)
|
int |
getWidth(Canvas canvas,
Image image,
Object nativeImage)
Get the width of this Image
|
boolean |
isPointInPath(Canvas canvas,
double x,
double y)
Returns true if the the given x,y point is inside the path.
|
void |
lineTo(Canvas canvas,
double x,
double y)
Adds segments to the current path to make a line at the given x,y
coordinate.
|
Dimension |
measureText(Canvas canvas,
String text)
The Dimension of this text using the current Font settings
|
Object |
mergeImages(Canvas canvas,
Image a,
Image b,
Object cachedA,
Object cachedB)
Merges two images drawing one on top of the other and returning the
result.
|
void |
moveTo(Canvas canvas,
double x,
double y)
Issues a move command for the current path to the given x,y coordinate.
|
void |
putPixelMap(Canvas canvas,
ImageData imageData,
double x,
double y)
Render an ImageData Object at the specified position
|
void |
quadraticCurveTo(Canvas canvas,
double cpx,
double cpy,
double x,
double y)
Adds segments to the current path to make a quadratic curve.
|
void |
rect(Canvas canvas,
double x,
double y,
double width,
double height)
Clears a portion of the canvas with a transparent color value.
|
void |
restore(Canvas canvas)
Pops the state off of the stack, setting the following attributes to
their value at the time when that state was pushed onto the stack.
|
void |
rotate(Canvas canvas,
double angle)
Rotates the current transform in degrees.
|
void |
save(Canvas canvas)
Saves the following attributes onto a stack.
|
void |
scale(Canvas canvas,
double x,
double y)
Scales the current transform by x, y.
|
Object |
setFillStyle(Canvas canvas,
Style style,
Object nativeStyle)
When implementing you can return an Object of your choice to enable
caching.
|
void |
setFont(Canvas canvas,
String font)
Sets the current Font.
|
void |
setGlobalAlpha(Canvas canvas,
double alpha)
Sets the global alpha of the current state.
|
void |
setGlobalCompositeOperation(Canvas canvas,
String operation)
Sets the global blend mode.
|
void |
setHeight(Canvas canvas,
int height)
set the width of this Canvas
|
void |
setLineCap(Canvas canvas,
String style)
Sets the current stroke line cap.
|
void |
setLineJoin(Canvas canvas,
String style)
Sets the current stroke line join.
|
void |
setLineWidth(Canvas canvas,
double width)
Sets the current line width.
|
void |
setMiterLimit(Canvas canvas,
double limit)
Sets the current miter limit.
|
Object |
setStrokeStyle(Canvas canvas,
Style style,
Object nativeStyle)
When implementing you can return an Object of your choice to enable
caching.
|
void |
setTextAlign(Canvas canvas,
String textAlign)
Defines horizontal text alignment, relative to the text origin.
|
void |
setTextBaseline(Canvas canvas,
String baseline)
Sets the current Text Baseline.
|
void |
setTransform(Canvas canvas,
double a,
double b,
double c,
double d,
double e,
double f)
Concatenates the input with the current transform.
|
void |
setWidth(Canvas canvas,
int width)
set the height of this Canvas
|
void |
stroke(Canvas canvas)
Strokes the path with the current stroke paint.
|
void |
strokeRect(Canvas canvas,
double x,
double y,
double width,
double height)
Strokes a rectangle using the current stroke paint.
|
void |
strokeText(Canvas canvas,
String text,
double x,
double y)
draws the given string of text at position x, y (0,0 at top left) with
the current stroke paint attribute.
|
void |
strokeText(Canvas canvas,
String text,
double x,
double y,
double maxWidth)
Draws text with stroke paint and includes a maximum width of the string.
|
void |
transform(Canvas canvas,
double a,
double b,
double c,
double d,
double e,
double f)
Concatenates the input with the current transform.
|
void |
translate(Canvas canvas,
double x,
double y)
Translates the current transform by x, y.
|
Canvas getOrCreateCanvas(String id)
id
- the Canvas idvoid arc(Canvas canvas, double centerX, double centerY, double radius, double startAngle, double endAngle, boolean acw)
canvas
- the native CanvascenterX
- the center x position of the arc.centerY
- the center y position of the arc.startAngle
- the startAngle of the arcradius
- the radius of the arc.endAngle
- the endAngle of the arcacw
- the direction of the arc (anticlockwise)void arcTo(Canvas canvas, double x1, double y1, double x2, double y2, double radius)
canvas
- the native Canvasx1
- the X coordinate of the first point of the arc.y1
- the Y coordinate of the first point of the arc.x2
- the X coordinate of the second point of the arc.y2
- the Y coordinate of the second point of the arc.radius
- the radius of the arc in the range {0.0-positive infinity}.boolean isPointInPath(Canvas canvas, double x, double y)
canvas
- the native Canvasx
- the X coordinate to use for the check.y
- the Y coordinate to use for the check.void fill(Canvas canvas)
canvas
- the native Canvasvoid stroke(Canvas canvas)
canvas
- the native Canvasvoid beginPath(Canvas canvas)
canvas
- the native Canvasvoid closePath(Canvas canvas)
canvas
- the native Canvasvoid clip(Canvas canvas)
canvas
- the native Canvasvoid moveTo(Canvas canvas, double x, double y)
canvas
- the native Canvasx
- the X position for the move to command.y
- the Y position for the move to command.void lineTo(Canvas canvas, double x, double y)
canvas
- the native Canvasx
- the X coordinate of the ending point of the line.y
- the Y coordinate of the ending point of the line.void quadraticCurveTo(Canvas canvas, double cpx, double cpy, double x, double y)
canvas
- the native Canvascpx
- the X coordinate of the control pointcpy
- the Y coordinate of the control pointx
- the X coordinate of the end pointy
- the Y coordinate of the end pointvoid bezierCurveTo(Canvas canvas, double cp1x, double cp1y, double cp2x, double cp2y, double x, double y)
canvas
- the native Canvascp1x
- the X coordinate of first bezier control point.cp1y
- the Y coordinate of the first bezier control point.cp2x
- the X coordinate of the second bezier control point.cp2y
- the Y coordinate of the second bezier control point.x
- the X coordinate of the end point.y
- the Y coordinate of the end point.void fillRect(Canvas canvas, double x, double y, double width, double height)
canvas
- the native Canvasx
- the X position of the upper left corner of the rectangle.y
- the Y position of the upper left corner of the rectangle.width
- the width of the rectangle.height
- the height of the rectangle.void strokeRect(Canvas canvas, double x, double y, double width, double height)
canvas
- the native Canvasx
- the X position of the upper left corner of the rectangle.y
- the Y position of the upper left corner of the rectangle.width
- the width of the rectangle.height
- the height of the rectangle.void clearRect(Canvas canvas, double x, double y, double width, double height)
canvas
- the native Canvasx
- X position of the upper left corner of the rectangle.y
- Y position of the upper left corner of the rectangle.width
- width of the rectangle.height
- height of the rectangle.void rect(Canvas canvas, double x, double y, double width, double height)
canvas
- the native Canvasx
- X position of the upper left corner of the rectangle.y
- Y position of the upper left corner of the rectangle.width
- width of the rectangle.height
- height of the rectangle.void save(Canvas canvas)
canvas
- the native Canvasvoid restore(Canvas canvas)
canvas
- the native Canvasvoid rotate(Canvas canvas, double angle)
canvas
- the native Canvasangle
- value in degrees to rotate the current transform.void transform(Canvas canvas, double a, double b, double c, double d, double e, double f)
canvas
- the native Canvasa
- - the X coordinate scaling element of the 3x4 matrixb
- - the Y coordinate shearing element of the 3x4 matrixc
- - the X coordinate shearing element of the 3x4 matrixd
- - the Y coordinate scaling element of the 3x4 matrixe
- - the X coordinate translation element of the 3x4 matrixf
- - the Y coordinate translation element of the 3x4 matrixvoid setTransform(Canvas canvas, double a, double b, double c, double d, double e, double f)
canvas
- the native Canvasa
- - the X coordinate scaling element of the 3x4 matrixb
- - the Y coordinate shearing element of the 3x4 matrixc
- - the X coordinate shearing element of the 3x4 matrixd
- - the Y coordinate scaling element of the 3x4 matrixe
- - the X coordinate translation element of the 3x4 matrixf
- - the Y coordinate translation element of the 3x4 matrixvoid translate(Canvas canvas, double x, double y)
canvas
- the native Canvasx
- value to translate along the x axis.y
- value to translate along the y axis.void scale(Canvas canvas, double x, double y)
canvas
- the native Canvasx
- value to scale in the x axis.y
- value to scale in the y axis.Object drawImage(Canvas canvas, Image image, double x, double y, Object nativeImage)
canvas
- the native Canvasimage
- the image to be drawn.x
- the X coordinate on the destination for the upper left of the
image.y
- the Y coordinate on the destination for the upper left of the
image.nativeImage
- the native Image or nullObject drawImage(Canvas canvas, Image image, double x, double y, double width, double height, Object nativeImage)
canvas
- the native Canvasimage
- the image to be drawn.x
- the X coordinate on the destination for the upper left of the
image.y
- the Y coordinate on the destination for the upper left of the
image.width
- the width of the destination rectangle.height
- the height of the destination rectangle.nativeImage
- the native image, or nullObject drawImage(Canvas canvas, Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height, Object nativeImage)
canvas
- the native Canvasimage
- the image to be drawn.sx
- the source rectangle's X coordinate position.sy
- the source rectangle's Y coordinate position.sWidth
- the source rectangle's width.sHeight
- the source rectangle's height.x
- the destination rectangle's X coordinate position.y
- the destination rectangle's Y coordinate position.width
- the destination rectangle's width.height
- the destination rectangle's height.nativeImage
- the native Image, or nullint getWidth(Canvas canvas, Image image, Object nativeImage)
canvas
- the native Canvasimage
- the image to measurenativeImage
- the cached native Image or nullint getHeight(Canvas canvas, Image image, Object nativeImage)
canvas
- the native Canvasimage
- the image to measurenativeImage
- the cached native Image or nullObject setFillStyle(Canvas canvas, Style style, Object nativeStyle)
canvas
- the native Canvasstyle
- The style object you should use to create your native stylenativeStyle
- your native object if cached, null otherwiseObject setStrokeStyle(Canvas canvas, Style style, Object nativeStyle)
canvas
- the native Canvasstyle
- The style object you should use to create your native stylenativeStyle
- your native object if cached, null otherwiseString getLineCap(Canvas canvas)
canvas
- the native CanvasStrokeLineCap
with a value of Butt, Round, or Square.void setLineCap(Canvas canvas, String style)
canvas
- the native Canvasstyle
- a value of Butt, Round, or Square.String getLineJoin(Canvas canvas)
canvas
- the native Canvasvoid setLineJoin(Canvas canvas, String style)
canvas
- the native Canvasstyle
- with a value of Miter, Bevel, or Round.double getLineWidth(Canvas canvas)
canvas
- the native Canvasvoid setLineWidth(Canvas canvas, double width)
canvas
- the native Canvaswidth
- value in the range {0-positive infinity}, with any other
value being ignored and leaving the value unchanged.double getMiterLimit(Canvas canvas)
canvas
- the native Canvas0.0-positive infinity
void setMiterLimit(Canvas canvas, double limit)
canvas
- the native Canvaslimit
- miter limit value between 0 and positive infinity with any
other value being ignored and leaving the value unchanged.String getFont(Canvas canvas)
canvas
- the native Canvasvoid setFont(Canvas canvas, String font)
canvas
- the native Canvasfont
- The font to useString getTextAlign(Canvas canvas)
TextAlignment
.canvas
- the native Canvasvoid setTextAlign(Canvas canvas, String textAlign)
canvas
- the native CanvastextAlign
- with values of Left, Center, Right.String getTextBaseline(Canvas canvas)
canvas
- the native Canvasvoid setTextBaseline(Canvas canvas, String baseline)
canvas
- the native Canvasbaseline
- with values of Top, Center, Baseline, or Bottomvoid fillText(Canvas canvas, String text, double x, double y)
canvas
- the native Canvastext
- the string of text.x
- position on the x axis.y
- position on the y axis.void fillText(Canvas canvas, String text, double x, double y, double maxWidth)
canvas
- the native Canvastext
- the string of text.x
- position on the x axis.y
- position on the y axis.maxWidth
- maximum width the text string can have.Dimension measureText(Canvas canvas, String text)
canvas
- the native Canvastext
- The text to measurevoid strokeText(Canvas canvas, String text, double x, double y)
canvas
- the native Canvastext
- the string of text.x
- position on the x axis.y
- position on the y axis.void strokeText(Canvas canvas, String text, double x, double y, double maxWidth)
canvas
- the native Canvastext
- the string of text.x
- position on the x axis.y
- position on the y axis.maxWidth
- maximum width the text string can have.ImageData createPixelMap(Canvas canvas, double x, double y)
canvas
- the native Canvasx
- widthy
- heightImageData createPixelMap(Canvas canvas, double x, double y, int[] all)
canvas
- the native Canvasx
- widthy
- heightall
- an int [] of initial dataImageData createPixelMap(Canvas canvas, ImageData imageData)
canvas
- the native CanvasimageData
- an ImageData Object to copy the dimensions fromImageData getPixelMap(Canvas canvas, double x, double y, double width, double height)
canvas
- the native Canvasx
- start x coordinatey
- start y coordinatewidth
- widthheight
- heightvoid putPixelMap(Canvas canvas, ImageData imageData, double x, double y)
canvas
- the native CanvasimageData
- the Pixel arrayx
- start x coordinatey
- start y coordinatevoid setGlobalAlpha(Canvas canvas, double alpha)
canvas
- the native Canvasalpha
- value in the range 0.0-1.0
. The value is clamped if
it is out of range.double getGlobalAlpha(Canvas canvas)
canvas
- the native Canvas0.0-1.0
.void setGlobalCompositeOperation(Canvas canvas, String operation)
canvas
- the native Canvasoperation
- the BlendMode that will be set.String getGlobalCompositeOperation(Canvas canvas)
canvas
- the native Canvasint getHeight(Canvas canvas)
canvas
- the native Canvasint getWidth(Canvas canvas)
canvas
- the native Canvasvoid setHeight(Canvas canvas, int height)
canvas
- the native Canvasheight
- the target height of the Canvasvoid setWidth(Canvas canvas, int width)
canvas
- the native Canvaswidth
- the target width of the CanvasObject mergeImages(Canvas canvas, Image a, Image b, Object cachedA, Object cachedB)
canvas
- the native Canvasa
- the lower Imageb
- the upper ImagecachedA
- the native cached Image, if available, or null.cachedB
- the native cached Image, if available, or null.Copyright © 2018. All Rights Reserved.