<!--- Create a new canvas. ---> <cfset objImage = ImageNew( "", 400, 200, "rgb", "##F5F5F5" ) /> <!--- Turn on anti aliasing. We are going to be drawing some rounded rectangles, so we want the edges to be smoother. ---> <cfset ImageSetAntiAliasing( objImage, "on" ) /> <!--- Now, set the drawing color. This should set the color for all susequent drawing actions until the color is explicitly changed (dark blue). ---> <cfset ImageSetDrawingColor( objImage, "##4B4B9A" ) /> <!--- Now, we are going to loop over this image three times. For the first two rectangles, we are going to just draw to the image. For the third one, we are going to write the image to the browser first, then draw the rectangle. ---> <cfloop index="intI" from="1" to="3" step="1"> <!--- For the third iteration, we are going to first write the image to the browser. ---> <cfif (intI EQ 3)> <cfimage action="writetobrowser" source="#objImage#" /> </cfif> <!--- Pick a random X and Y coordinate at which to start the rectangle (all rectangles will be 100 x 50. ---> <cfset ImageDrawRoundRect( objImage, RandRange( 10, 290 ), RandRange( 10, 140 ), 100, 50, 30, 30, true ) /> </cfloop> <br /> <!--- Draw the image with three rectangles to the browser. ---> <cfimage action="writetobrowser" source="#objImage#" />