imageDrawRect

Draws a rectangle.

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

Member Function Syntax

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

imageDrawRect Argument Reference

name
Required

The image on which this operation is performed.

x
Required

The x coordinate of the rectangle.

y
Required

The y coordinate of the rectangle.

width
Required

The width of the rectangle.

height
Required

The height of the rectangle.

filled
Default: false

Specify whether the rectangle is filled

Examples sample code invoking the imageDrawRect function


Tag Syntax

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

Using drawRect member function

CF 11+ Lucee 4.5+ Create an 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");
imgObj.drawRect(40,50,70,50,"yes");
cfimage (action="writeToBrowser", source=imgObj);

Fork me on GitHub