ColdFusion 9.0 Resources |
ImageSetDrawingStrokeSee alsoImageDrawText, ImageSetAntialiasing, ImageSetBackgroundColor, ImageSetDrawingColor, ImageSetDrawingTransparency, IsImageFile Parameters
UsageUse the ImageSetDrawingStroke function to control the line attributes of all subsequent drawing objects in a ColdFusion image. For example, you can use this function to set the drawing stroke to a dash pattern once, and then create a rectangle, two ovals, and five lines with that pattern. If a blank or no attribute structure is passed, the drawing stroke is reset to the default values. attributeCollection
ExampleExample 1 <!--- This example shows how to create an attribute collection for the ImageSetDrawingStroke function and draws a line with those attributes. ---> <!--- Use the ImageNew function to create a ColdFusion image. ---> <cfset myImage=ImageNew("",200,200)> <!--- Create an attribute collection to pass to the ImageSetDrawingStroke function. Create a stroke that is 10-pixels wide, has round endcaps, and has a dash pattern of (8,4). ---> <cfset attr = StructNew()> <cfset attr.width = 2> <cfset attr.endcaps = "round"> <cfset dashPattern = ArrayNew(1)> <cfset dashPattern[1] = 8> <cfset dashPattern[2] = 4> <cfset attr.dashArray = dashPattern> <!--- Apply the attribute collection to the ImageSetDrawingStroke function for the image. ---> <cfset ImageSetDrawingStroke(myImage,attr)> <!--- Draw a line on the ColdFusion image with the drawing stroke attributes. ---> <cfset ImageDrawLine(myImage,20,20,40,150)> <!--- Display the image in a browser. ---> <cfimage source="#myImage#" action="writeToBrowser"> Example 2 <!--- Use the ImageNew function to create a ColdFusion image. ---> <cfset myImage=ImageNew("",500,500)> <!-- Set the drawing color of the image to cyan. ---> <cfset ImageSetDrawingColor(myImage,"cyan")> <!--- Draw a line from (30,40) to (200,190). ---> <cfset ImageDrawLine(myImage,30,30,200,200)> <!--- Create the attribute collection for the drawing stroke. ---> <cfset attr = StructNew()> <cfset attr.width = 1> <cfset attr.endcaps = "round"> <cfset dashPattern = ArrayNew(1)> <cfset dashPattern[1] = 3> <cfset dashPattern[2] = 4> <cfset dashPattern[3] = 8> <cfset attr.dashArray = dashPattern> <!--- Pass the attribute collection as an argument to the set drawing stroke function. ---> <cfset ImageSetDrawingStroke(myImage,attr)> <!-- Set the drawing color of the image to yellow. ---> <cfset ImageSetDrawingColor(myImage,"yellow")> <!--- Draw a rectangle with the drawing stroke specified. ---> <cfset ImageDrawRect(myImage,200,50,210,200)> <!-- Reset the drawing stroke. --> <cfset ImageSetDrawingStroke(myImage)> <!--- Draw a green quadratic curve. ---> <cfset ImageSetDrawingColor(myImage,"green")> <cfset ImageDrawQuadraticCurve(myImage,120,320,5,15,380,280)> <!--- Display the image in a browser. ---> <cfimage source="#myImage#" action="writeToBrowser"> |