ColdFusion 9.0 Resources |
ImageDrawTextDescriptionDraws a text string on a ColdFusion image with the baseline of the first character positioned at (x,y) in the image. See alsoImageDrawArc, ImageDrawBeveledRect, ImageDrawCubicCurve, ImageDrawLine, ImageDrawLines, ImageDrawOval, ImageDrawQuadraticCurve, ImageDrawRect, ImageDrawRoundRect, ImageSetAntialiasing, ImageSetDrawingColor, ImageTranslateDrawingAxis, IsImageFile Parameters
UsageSpecify all the optional key-value pairs in an attributeCollection structure. To specify the text color, use the ImageSetDrawingColor function. attributeCollection
ExampleExample 1 <!--- This example shows how to create a text string image. ---> <!--- Use the ImageNew function to create a 200x100-pixel image. ---> <cfset myImage=ImageNew("",200,100)> <!--- Set the drawing color to green. ---> <cfset ImageSetDrawingColor(myImage,"green")> <!--- Specify the text string and the start point for the text. ---> <cfset ImageDrawText(myImage,"It's not easy being green.",10,50)> <!--- Display the image in a browser. ---> <cfimage source="#myImage#" action="writeToBrowser"> Example 2 <!--- This example shows how to draw three text strings with different text attributes. ---> <!--- Use the ImageNew function to create a 400x400-pixel image. ---> <cfset myImage=ImageNew("",400,400)> <!--- Set the text attributes. ---> <cfset attr = StructNew()> <cfset attr.underline = "yes"> <cfset attr.size = 25> <cfset attr.style = "bold"> <cfset ImageSetDrawingColor(myImage,"yellow")> <!--- Draw the text string "ColdFusion Rocks!" starting at (100,150). ---> <cfset ImageDrawText(myImage,"ColdFusion Rocks!",100,150,attr)> <!--- Set new text attributes. ---> <cfset attr=StructNew()> <cfset attr.size = 18> <cfset attr.strikethrough = "yes"> <cfset attr.style = "bolditalic"> <cfset ImageSetDrawingColor(myImage,"red")> <!--- Draw the text string "Powered by ColdFusion" starting at (100,200). ---> <cfset ImageDrawText(myImage,"Powered by ColdFusion",110,200,attr)> <!--- Set new text attributes. ---> <cfset attr = StructNew()> <cfset attr.font="Arial"> <cfset attr.style="italic"> <cfset attr.size=15> <cfset ImageSetDrawingColor(myImage,"white")> <!--- Draw the text string "Coming in 2007" starting at (150,250). ---> <cfset ImageDrawText(myImage,"We've arrived",150,250,attr)> <!--- Display the text image in a browser. ---> <cfimage source="#myImage#" action="writeToBrowser"> |