ImageXORDrawingMode

Description

Sets the paint mode of the image to alternate between the image’s current color and the new specified color.

Returns

Nothing.

Function syntax

ImageXORDrawingMode(name, c1)

History

ColdFusion 8: Added this function.

Parameters

Parameter

Description

name

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

c1

Required. XOR alternation color:

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

  • String value of color (for example, "black", "red", "green").

Usage

This function alternates pixels between the current color and a new specified XOR (exclusive Or) color.

When drawing operations are performed, pixels that are the current color are changed to the specified color, and vice versa.

Pixels that are of colors other than current color or the new specified color are changed in an unpredictable but reversible manner. If the same figure is drawn twice, all pixels are restored to their original values.

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 draw rectangles with alternating colors where they overlap. ---> 
<!--- Use the ImageNew function to create a 300x200-pixel image in RGB format. ---> 
<cfset myImage = ImageNew("",300,200,"rgb")> 
<!--- Turn on antialiasing to improve image quality. ---> 
<cfset ImageSetAntialiasing(myImage)> 
<!--- Set the drawing color to white. ---> 
<cfset ImageSetDrawingColor(myImage,"white")> 
<!--- Draw a white filled rectangle that is the size of the original image. ---> 
<cfset ImageDrawRect(myImage,0,0,300,200,"yes")> 
<!--- Set the XOR drawing mode to white. ---> 
<cfset ImageXORDrawingMode(myImage,"white")> 
<!--- Set the drawing color to red. ---> 
<cfset ImageSetDrawingColor(myImage,"red")> 
<!--- Draw a filled red rectangle. ---> 
<cfset ImageDrawRect(myImage,50,50,150,100,"yes")> 
<!--- Translate the drawing axis to (25,25). ---> 
<cfset ImageTranslateDrawingAxis(myImage,25,25)> 
<!--- Set the drawing color to blue. ---> 
<cfset ImageSetDrawingColor(myImage,"blue")> 
<!--- Draw a blue filled rectangle at the offset location. ---> 
<cfset ImageDrawRect(myImage,50,50,150,100,"yes")> 
<!--- Save the ColdFusion image as a PNG file. ---> 
<cfset ImageWrite(myImage,"xortest.png")> 
<!--- Display the PNG file.---> 
<img src="xortest.png">