ImageSetDrawingColor

Description

Sets the current drawing color for ColdFusion images. All subsequent graphics operations use the specified color.

Returns

Nothing.

Function syntax

ImageSetDrawingColor(name, color)

History

ColdFusion 8: Added this function.

Parameters

Parameter

Description

name

Required. The ColdFusion image on which this operation is performed.

color

Required. Drawing color:

  • Hexadecimal value of RGB color. For example, specify the color white as "##FFFFFF" or "FFFFFF".

  • String value of color (for example, "black", "red", "green"). The default value of the drawing color is "black".

  • List of three numbers for (R,G,B) values. Each value must be in the range 0–255.

Usage

Use the ImageSetDrawingColor function to control the color of all subsequent drawing objects in ColdFusion images. For example, you can use this function to set the drawing color to red once, and then draw a circle, a square, and 10 lines in that color.

If the color value is a string, specify a supported named color; see the list of valid HTML named colors in cfimage. For a hexadecimal value, use the form "##xxxxxx" or "xxxxxx", where x = 0-9 or A-F; use two number signs or none.

Example

<!--- This example shows how to set the drawing color and draw several objects in that color. ---> 
<!--- Use the ImageNew function to create a ColdFusion image. ---> 
<cfset myImage=ImageNew("",200,300)> 
<!--- Turn on antialiasing to improve image quality. ---> 
<cfset ImageSetAntialiasing(myImage)> 
<!--- Set the drawing color to pink. ---> 
<cfset ImageSetDrawingColor(myImage,"pink")> 
<!--- Draw a pink line. ---> 
<cfset ImageDrawLine(myImage,1,1,200,300)> 
<!--- Draw a pink oval. ---> 
<cfset ImageDrawOval(myImage,40,50,80,40)> 
<!--- Draw another pink oval. ---> 
<cfset ImageDrawOval(myImage,15,180,80,40)> 
<!--- Draw a pink rectangle. ---> 
<cfset ImageDrawRect(myImage,100,100,45,65)> 
<!--- Display the image in a browser. ---> 
<cfimage source="#myImage#" action="writeToBrowser">