imageDrawLine

Draws a single line defined by two sets of x and y coordinates on a ColdFusion image.

imageDrawLine(name, x1, y1, x2, y2) → returns void

Member Function Syntax

someImage.drawLine(x1, y1, x2, y2)

Argument Reference

name string
Required

The image on which this operation is performed.

x1 numeric
Required

The x coordinate for the start point of the line.

y1 numeric
Required

The y coordinate for the start point of the line.

x2 numeric
Required

The x coordinate for the end point of the line.

y2 numeric
Required

The y coordinate for the end point of the line.

Examples
Sample code invoking the imageDrawLine function

This example shows how to draw a square bisected by a diagonal line.

<!--- Use the imageNew function to create a 100x100-pixel image. ---> 
 <cfset myImage=imageNew("",100,100)> 
 <!--- Turn on antialiasing to improve image quality. ---> 
 <cfset imageSetAntialiasing(myImage,"on")> 
 <!--- Draw a diagonal line that bisects the square. ---> 
 <cfset imageDrawLine(myImage,0,0,100,100)> 
 <!--- Display the image in a browser. ---> 
 <cfimage source="#myImage#" action="writeToBrowser"> 

CF 11+ Lucee 4.5+ Create a new image and with this image draw a diagonal line from the top left (0,0) to the bottom right (152,152)

imgObj = imageNew("",152,152,"rgb","149c82");
imgObj.drawLine(0,0,152,152);
cfimage (action="writeToBrowser", source=imgObj);

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub