imageDrawText
Description
Draws a text string on a ColdFusion image with the baseline of the first character positioned at (x,y) in the image.
Categories
Related
imageDrawArc imageDrawBeveledRect imageDrawCubicCurve imageDrawLine imageDrawLines imageDrawOval imageDrawQuadraticCurve imageDrawRect imageDrawRoundRect imageSetAntialiasing imageSetDrawingColor imageTranslateDrawingAxis isImageFile
History
ColdFusion
8: Added this function.
Syntax
ImageDrawText(name, str, x, y [, attributeCollection])
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| attributeCollection | Optional. The structure used to specify the text characteristics. See the Usage section. | ||
| name | Required. The ColdFusion image on which this operation is performed. | ||
| str | Required. The text string to draw. | ||
| x | Required. The x coordinate for the start point of the string. | ||
| y | Required. The y coordinate for the start point of the string. |
Returns
Nothing.
Usage
Specify all the optional key-value pairs in an attributeCollection structure. To specify the text color, use the ImageSetDrawingColor function.
Example
Example
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">