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)

imageDrawLine Argument Reference

name
Required

The image on which this operation is performed.

x1
Required

The x coordinate for the start point of the line.

y1
Required

The y coordinate for the start point of the line.

x2
Required

The x coordinate for the end point of the line.

y2
Required

The y coordinate for the end point of the line.

Examples sample code invoking the imageDrawLine function


Tag Syntax

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"> 

Using drawline member function

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);

Fork me on GitHub