Skip to: Site menu | Main content

Groovy 

      Download | Documentation | Developers | Community

An agile dynamic language for the Java Platform

GraphicsBuilder - Shapes - Path Add comment to Wiki View in Wiki Edit Wiki page Printable Version

Draws an arbitrary geometric path. Paths are described by a series of pathOperations:

Operation Description
moveTo[x,y] adds a point to the path by moving to the specified coordinates (x,y)
lineTo[x,y] adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates (x,y)
curveTo[x1,y1,x2,y2,x3,y3] adds a curved segment, defined by three new points, to the path by drawing a Bézier curve that intersects both the current coordinates and the specified coordinates (x3,y3), using the specified points (x1,y1) and (x2,y2) as Bézier control points
quadTo[x1,y1,x2,y2] adds a curved segment, defined by two new points, to the path by drawing a Quadratic curve that intersects both the current coordinates and the specified coordinates (x2,y2), using the specified point (x1,y1) as a quadratic parametric control point
hline[x] adds a point to the path by drawing an horizontal line to the specified coordinates (x,current.y)
vline[y] adds a point to the path by drawing a vertical line to the specified coordinates (current.x,y)
shapeTo[shape,connect] appends the geometry of the specified Shape, shape operation or outline operation to the path, possibly connecting the new geometry to the existing path segments with a line segment
close closes the current subpath by drawing a straight line back to the coordinates of the last moveTo

The first operation must be a moveTo.

Example

path( borderColor: 'darkBlue', fill: 'blue', borderWidth: 4 ){
   moveTo( x: 50, y: 50 )
   quadTo( x1: -30, y1: 100, x2: 50, y2: 150 )
   quadTo( x1: 100, y1: 230, x2: 150, y2: 150 )
   quadTo( x1: 230, y1: 100, x2: 150, y2: 50 )
   quadTo( x1: 100, y1: -30, x2: 50, y2: 50 )
}