Last updated

API / geotoolkit / renderer / Graphics / Graphics

Class: Graphics

renderer.Graphics.Graphics

Graphics

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new Graphics()

new Graphics()

Methods

arcTo

Abstract arcTo(x1, y1, x2, y2, radius): Graphics

Draws an arc to the target point as part of a path.

Parameters

Name Type Description
x1numbercoordinate of destination
y1numbercoordinate of destination
x2numbercoordinate
y2numbercoordinate
radiusnumberradius of arc

Returns

Graphics

this


beginPath

Abstract beginPath(): Graphics

Begin path

Returns

Graphics

this


bezierCurveTo

Abstract bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y): Graphics

Draws a cubic B\u00e9zier curve from the current point to the point (x, y), with control points (cp1x, cp1y) and (cp2x, cp2y).

Parameters

Name Type Description
cp1xnumberthe x coordinate of the first control point
cp1ynumberthe y coordinate of the first control point
cp2xnumberthe x coordinate of the second control point
cp2ynumberthe y coordinate of the second control point
xnumberthe x coordinate of the end point
ynumberthe y coordinate of the end point

Returns

Graphics

this


closePath

Abstract closePath(): Graphics

Do nothing if the context has no subpaths. Otherwise, it marks the last subpath as closed, create a new subpath whose first point is the same as the previous subpath's first point, and finally add this new subpath to the path.

Returns

Graphics

this


drawAnnulusArc

Abstract drawAnnulusArc(x, y, innerRadius, outerRadius, startAngle, endAngle, sweepAngle?): Graphics

Draws a portion of an annulus clockwise ranging from startAngle to endAngle. If endAngle exceeds startAngle by Math.PI * 2 or more than annulus is drawn. Will fill in between the two arcs if fillStyle exists.

Parameters

Name Type Description
xnumberx-coordinate of the center of the arc.
ynumbery-coordinate of the center of the arc.
innerRadiusnumberinner radius of the arc
outerRadiusnumberouter radius of the arc
startAnglenumberangle in radians measured from x-axis to the starting point of the arc (clockwise means positive angle; counterclockwise - otherwise).
endAnglenumberAngle in radians measured from x-axis to ending point of the arc.
Optional sweepAnglenumberDefines the sweep of the arc

Returns

Graphics

this


drawArc

Abstract drawArc(x, y, width, height, startAngle, endAngle, sweepAngle?, suppressLineToCenter?): Graphics

Draws an arc clockwise from startAngle to endAngle. If endAngle exceeds startAngle by Math.PI * 2 or more than ellipse is drawn. If fillStyle is not null, will fill the arc area using a direct line to close the path between start and end of arc. By default, this function renders a "pie" shape, using given fill and stroke style. In order to draw a real arc, set suppressLineToCenter=true.

Parameters

Name Type Description
xnumberx-coordinate of the upper-left corner of the rectangle that bounds the ellipse.
ynumbery-coordinate of the upper-left corner of the rectangle that bounds the ellipse.
widthnumberwidth of the rectangle that bounds the ellipse.
heightnumberheight of the rectangle that bounds the ellipse.
startAnglenumberangle in radians measured clockwise from positive x-axis to the starting point of the arc.
endAnglenumberAngle in radians measured clockwise from positive x-axis to the ending point of the arc.
Optional sweepAnglenumberDefines the sweep of the arc in radians. This parameter used if and only if startAngle == endAngle
Optional suppressLineToCenterbooleanDoes not draw lines from the edges of arc to center point

Returns

Graphics

this


drawEllipse

Abstract drawEllipse(x, y, width, height): Graphics

Draw and fill ellipse

Parameters

Name Type Description
xnumberx-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse
ynumbery--coordinate of the upper-left corner of the bounding rectangle that defines the ellipse
widthnumberwidth of the bounding rectangle that defines the ellipse.
heightnumberheight of the bounding rectangle that defines the ellipse.

Returns

Graphics

this


drawImage

Abstract drawImage(image, srcX, srcY, srcW?, srcH?, dstX?, dstY?, dstW?, dstH?): Graphics

Draw an image onto the graphics context

Example

// Draw image can be used it the three different ways

// Provide only destination x and y
graphics.drawImage(image, dstX, dstY);
// Provide destination x and y and destination width and height
graphics.drawImage(image, dstX, dstY, dstW, dstW);
// Provide source x, y, width, height and destination x and y and destination width and height
graphics.drawImage(image, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstW);

Parameters

Name Type Description
imageSurface | IBaseImageimage to be rendered
srcXnumberThe x-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context. Use the 7- or 9-argument syntax to use it as a source or the x-axis coordinate in the destination context at which to place the top-left corner of the source image. Use the 3- or 5-argument syntax to apply this argument as destination position.
srcYnumberThe y-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context. Use the 7- or 9-argument syntax to use it as a source or the y-axis coordinate in the destination context at which to place the top-left corner of the source image. Use the 3- or 5-argument syntax to apply this argument as destination position.
Optional srcWnumbersource width if 7- or 9-argument is used or image width for other cases
Optional srcHnumbersource height if y-argument | image height for other cases
Optional dstXnumberdestination x position
Optional dstYnumberdestination y position
Optional dstWnumberdestination width This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.
Optional dstHnumberdestination height. If not specified, the image is not scaled in height when drawn.

Returns

Graphics

this


drawLine

Abstract drawLine(x1, y1, x2, y2): Graphics

Draw line

Parameters

Name Type Description
x1numberx-position of start point
y1numbery-position of start point
x2numberx-position of end point
y2numbery-position of end point

Returns

Graphics

this


drawPath

drawPath(path): Graphics

Apply geometry on the rendering context. The method stroke must be called to draw path outlines or fillPath to fill the geometry

Parameters

Name Type Description
pathGraphicsPathpath to draw

Returns

Graphics

this


drawPolygon

Abstract drawPolygon(x, array, start?, end?): Graphics

Draw and fill polygon. If fill style is null then it draws outline only.

Parameters

Name Type Description
xnumber[]array of x coordinates of points
arraynumber[]of y coordinates of points
Optional startnumberindex of the first point in the array
Optional endnumberindex of the last point in the array

Returns

Graphics

this


drawPolyline

Abstract drawPolyline(x, y, start?, end?, multiDirection?): Graphics

Draw polyline

Parameters

Name Type Description
xnumber[]array of x coordinates of points
ynumber[]array of y coordinates of points
Optional startnumberindex of the first point in the array
Optional endnumberindex of the last point in the array
Optional multiDirectionbooleanfalse for one direction array

Returns

Graphics

this


drawRectangle

Abstract drawRectangle(x, y?, width?, height?): Graphics

Draw and fill rectangle with the current style. If fill style is null then it draws outline only.

Parameters

Name Type Description
xnumber | RectX coordinate of the start point
Optional ynumberY coordinate of the start point
Optional widthnumberWidth of rectangle
Optional heightnumberHeight of rectangle

Returns

Graphics

this


drawText

Abstract drawText(x, y, text): Graphics

Draw text

Parameters

Name Type Description
xnumberx anchor position
ynumbery anchor position
textstringtext to draw

Returns

Graphics

this


fillPath

Abstract fillPath(): Graphics

Fill all the subpaths of the current path, using fillStyle, and using the non-zero winding number rule. Open subpaths will be implicitly closed when being filled (without affecting the actual subpaths).

Returns

Graphics

this


lineTo

Abstract lineTo(x, y): Graphics

Draw line from the current position to the specified position

Parameters

Name Type Description
xnumberx position
ynumbery position

Returns

Graphics

this


moveTo

Abstract moveTo(x, y): Graphics

Move current position to x,y. Create a new subpath with the specified point as its first (and only) point.

Parameters

Name Type Description
xnumberx position
ynumbery position

Returns

Graphics

this


setClip

Abstract setClip(geometry, operation?, isModel?, evenOdd?): Graphics

Sets clipping

Parameters

Name Type Description
geometryRect | GraphicsPath | Regiongeometry to clip
Optional operationGeometryOperationoperation to be applied for a new clipping
Optional isModelbooleanmodel coordinates flag
Optional evenOddbooleanDefines if clipping to apply is even-odd

Returns

Graphics

this


setFillPattern

Abstract setFillPattern(pattern): Graphics

Set fill pattern

Parameters

Name Type Description
patternPatternpattern to fill the area

Returns

Graphics

this


setFillStyle

Abstract setFillStyle(style, area?): Graphics

Set fill style

Parameters

Name Type Description
styleFillStylefill style
Optional areaRectarea

Returns

Graphics

this


setLineStyle

Abstract setLineStyle(style, area?): Graphics

Set line style

Parameters

Name Type Description
styleLineStyle | GradientStylea line style
Optional areaRectarea to apply fill property of line style

Returns

Graphics

this


setTextStyle

Abstract setTextStyle(textStyle): Graphics

Set text style

Parameters

Name Type Description
textStyleTextStylestyle

Returns

Graphics

this


stroke

Abstract stroke(): Graphics

Calculate the strokes of all the subpaths of the current path

Returns

Graphics

this