Draws a rectangle.

imageDrawRect(name, x, y, width, height [, filled]) → returns void

Member Function Syntax

someImage.drawRect(x, y, width, height [, filled])

Argument Reference

name string

The image on which this operation is performed.

x numeric

The x coordinate of the rectangle.

y numeric

The y coordinate of the rectangle.

width numeric

The width of the rectangle.

height numeric

The height of the rectangle.

filled boolean
Default: false

Specify whether the rectangle is filled

Sample code invoking the imageDrawRect function

This example shows how to draw a rectangle.

<!--- Use the imageNew function to create a ColdFusion image that is 150 pixels wide and 200 pixels high. ---> 
 <cfset myImage=imageNew("",150,200)> 
 <!--- Set the drawing color for the image to yellow. ---> 
 <cfset imageSetDrawingColor(myImage,"yellow")> 
 <!--- Turn on antialiasing to improve image quality. ---> 
 <cfset imageSetAntialiasing(myImage,"on")> 
 <!--- Draw a filled yellow rectangle on the image. ---> 
 <cfset imageDrawRect(myImage,25,45,100,20,"yes")> 
 <!--- Display the image in a browser. ---> 
 <cfimage source="#myImage#" action="writeToBrowser"> 

CF 11+ Lucee 4.5+ Create a new image. With the new image draw filled rectangle (width=70, height=50) starting at point (x=40,y=50)

imgObj = imageNew("",152,152,"rgb","149c82");
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