imageDrawLines
Description
Draws a sequence of connected lines defined by arrays of x and y coordinates.
Categories
Related
imageDrawBeveledRect imageDrawCubicCurve imageDrawLine imageDrawRect imageDrawRoundRect imageSetAntialiasing imageSetDrawingColor imageSetDrawingStroke isImageFile
History
ColdFusion
8: Added this function.
Syntax
ImageDrawLines(name, xcoords, ycoords [, isPolygon, filled])
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| filled | Optional. Specify whether the polygon is filled: yes: The polygon is filled with the specified drawing color. no: Only the outline of the polygon is drawn (default). | ||
| isPolygon | Optional. Specify whether the lines form a polygon: yes: The lines are connected to form a polygon. no: The lines do not form a polygon (default). | ||
| name | Required. The ColdFusion image on which this operation is performed. | ||
| xcoords | Required. A CFML array of x coordinates. | ||
| ycoords | Required. A CFML array of y coordinates. |
Returns
Nothing.
Usage
Each pair of (x,y) coordinates defines a point.
To draw a polygon, set isPolygon to yes. The start point cannot be the same value as the end point. If isPolygon is yes, a line joining start point and the end point is drawn to complete a polygon. If isPolygon is no, line completing the polygon is not drawn.
Set the isPolygon and filled parameters to yes to draw a polygon filled with the current drawing color.
Use the ImageSetDrawingColor and ImageSetDrawingStroke functions to control the color and line attributes. Use the ImageSetAntialiasing function to improve the quality of the rendered image.
To draw a polygon, set isPolygon to yes. The start point cannot be the same value as the end point. If isPolygon is yes, a line joining start point and the end point is drawn to complete a polygon. If isPolygon is no, line completing the polygon is not drawn.
Set the isPolygon and filled parameters to yes to draw a polygon filled with the current drawing color.
Use the ImageSetDrawingColor and ImageSetDrawingStroke functions to control the color and line attributes. Use the ImageSetAntialiasing function to improve the quality of the rendered image.
Example
<!--- This example shows how to draw a zigzag line. --->
<!--- Use the ImageNew function to create a 250x250-pixel image. --->
<cfset myImage=ImageNew("",250,250)>
<!--- Set the drawing color to cyan. --->
<cfset ImageSetDrawingColor(myImage,"cyan")>
<!--- Turn on antialiasing to improve image quality. --->
<cfset ImageSetAntialiasing(myImage,"on")>
<!--- Create arrays for the x and y coordinates. --->
<cfset x = ArrayNew(1)>
<cfset y = ArrayNew(1)>
<!--- Set the values for the x and y coordinates for three connected line segments: the first segment begins at (100,50) and ends at (50,100). The second segment begins at (50, 100) and ends at (200,100). The third segment begins at (200,100) and ends at (100,200). --->
<cfset x[1] = "100">
<cfset x[2] = "50">
<cfset x[3] = "200">
<cfset x[4] = "100">
<cfset y[1] = "50">
<cfset y[2] = "100">
<cfset y[3] = "100">
<cfset y[4] = "200">
<!--- Draw the lines on the image. --->
<cfset ImageDrawLines(myImage,x,y)>
<!--- Display the image in a browser. --->
<cfimage source=#myImage# action="writeToBrowser">