Playing with CF8 Image Functions

On December 12, 2007, in ColdFusion, by Anuj Gakhar

Here is what I did with the new CF8 image functions. This is actually drawn to the canvas and not just some text.

CFimage magic

Here is the code :-

[xml]<cfset myImage=ImageNew("",550,100,"rgb","3366aa")>

<!— Set the drawing color to white. —>

<cfset ImageSetDrawingColor(myImage,"white")>

<!— Turn on antialiasing to improve image quality. —>

<cfset ImageSetAntialiasing(myImage,"on")>

<!— drawing attributes —>

<cfset attr = StructNew()>

<cfset attr.width = 4>

<cfset attr.endcaps = "round">

<cfset attr.lineJoins = "round">

<cfset ImageSetDrawingStroke(myImage,attr)>

<!— draw the C —>

<cfset ImageDrawArc(myImage,10,10,110,80,105,145,"no")>

<!— draw the F —>

<cfset ImageDrawLine(myImage,70,10,70,88)>

<cfset ImageDrawLine(myImage,70,10,120,10)>

<cfset ImageDrawLine(myImage,70,40,120,40)>

<!— == sign —>

<cfset ImageDrawLine(myImage,150,40,190,40)>

<cfset ImageDrawLine(myImage,150,60,190,60)>

<!— C again—>

<cfset ImageDrawArc(myImage,210,10,110,80,105,145,"no")>

<!– O’s —>

<cfset ImageDrawOval(myImage,250,10,90,80,"no")>

<cfset ImageDrawOval(myImage,350,10,90,80,"no")>

<!— L—>

<cfset ImageDrawLine(myImage,450,10,450,90)>

<cfset ImageDrawLine(myImage,450,90,480,90)>

<!— exclamation sign—>

<cfset ImageDrawLine(myImage,510,10,510,80)>

<!— change the width for the dot—>

<cfset attr = StructNew()>

<cfset attr.width = 6>

<cfset attr.endcaps = "round">

<cfset ImageSetDrawingStroke(myImage,attr)>

<cfset ImageDrawPoint(myImage,510,90)>

<!— Display the image in a browser. —>

<cfimage source="#myImage#" action="writeToBrowser">[/xml]

Tagged with:  

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 446 other subscribers

© 2011 Anuj Gakhar
%d bloggers like this: