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




Image functions

Function syntax

ImageXORDrawingMode(image, color)

See also



ColdFusion (2018 release): Introduced named parameters.

ColdFusion 8: Added this function.





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


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


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.


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

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy