Highlighted

CFimagedrawlines example

New Here ,
May 11, 2016

Copy link to clipboard

Copied

I am still using CF8 and love it, but here's my question.

Can someone show me an example of cfimagedrawlines

that draws a left sloping rectangle?

Terry

Views

134

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

CFimagedrawlines example

New Here ,
May 11, 2016

Copy link to clipboard

Copied

I am still using CF8 and love it, but here's my question.

Can someone show me an example of cfimagedrawlines

that draws a left sloping rectangle?

Terry

Views

135

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 11, 2016 0
LEGEND ,
May 12, 2016

Copy link to clipboard

Copied

Google.

Adobe ColdFusion 9 * ImageDrawLine

HTH,

^_^

UPDATE:  Basically you provide the name of the image that you are affecting, the x/y coordinates of the start of the line, and the x/y coordinates of the end of the line.

You will need four of these to create a left-slanted rectangle.

UPDATE2: Okay.. played around with it.  imageDrawLineS() uses between three and five arguments: image name; array of X; array of Y; isPolygon; isFilled.

<cfset myImage = imageNew('','500','500','argb','white') />

<cfset imageSetAntiAliasing(myImage,'on') />

<cfset imageSetDrawingColor(myImage, 'black') />

<cfset attr = StructNew() />

<cfset attr.width = 1 />

<cfset attr.endcaps = "round" />

<cfset imageSetDrawingStroke(myImage,attr) />

<cfset x[1] = "10" /><cfset x[2] = "400" /><cfset x[3] = "480" /><cfset x[4] = "90" />

<cfset y[1] = "10" /><cfset y[2] = "10" /><cfset y[3] = "400" /><cfset y[4] = "400" />

<cfset imageDrawLines(myImage,x,y,true,false) />

<cfimage action="writetobrowser" source="#myImage#" format="png" />

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 12, 2016 1
New Here ,
May 12, 2016

Copy link to clipboard

Copied

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

  <title>Untitled</title>

</head>

<body>

<cfparam default=10 name="X1">

<cfparam default=20 name="X2">

<cfparam default=30 name="X3">

<cfparam default=40 name="X4">

<cfparam default=10 name="Y1">

<cfparam default=20 name="Y2">

<cfparam default=30 name="Y3">

<cfparam default=40 name="Y4">

<table><tr>

<cfoutput><cfform action="SQUARE2.CFM" method="post" preservedata="Yes">

<td>X1<input type="text" name="X1" value="#X1#" size="3" maxlength="3"><br>

X2<input type="text" name="X2" value="#X2#" size="3" maxlength="3"><br>

X3<input type="text" name="X3" value="#X3#" size="3" maxlength="3"><br>

X4<input type="text" name="X4" value="#X4#" size="3" maxlength="3"><br>

</td>

<td>Y1<input type="text" name="Y1" value="#Y1#" size="3" maxlength="3"><br>

Y2<input type="text" name="Y2" value="#Y2#" size="3" maxlength="3"><br>

Y3<input type="text" name="Y3" value="#Y3#" size="3" maxlength="3"><br>

Y4<input type="text" name="Y4" value="#Y4#" size="3" maxlength="3"><br>

</td>

<td>

</td>

<input type="submit" name="X" value="SUBMIT">

</cfform></cfoutput></tr>

</table>

<cfset myImage=ImageNew("",400,250,"grayscale","GREEN")>

<!--- Set the drawing color to cyan. --->

<cfset ImageSetDrawingColor(myImage,"black")>

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

<cfset ImageSetAntialiasing(myImage,"on")>

<!--- Create arrays for the x and y coordinates. --->

<cfset x = ArrayNew(1)>

<cfset y = ArrayNew(1)>

<!--- Set the values for the x and y coordinates for three connected line segments: the first

segment begins at (100,50) and ends at (50,100). The second segment begins at (50, 100) and

ends at (200,100). The third segment begins at (200,100) and ends at (100,200). --->

<cfset x[1] = "#X1#">

<cfset x[2] = "#X2#">

<cfset x[3] = "#X3#">

<cfset x[4] = "#X4#">

<!--- <cfset x[5] = "#X5#"> --->

<cfset y[1] = "#Y1#">

<cfset y[2] = "#Y2#">

<cfset y[3] = "#Y3#">

<cfset y[4] = "#Y4#">

<!--- <cfset y[5] = "#Y5#"> --->

<!--- Draw the lines on the image. --->

<cfset ImageDrawLines(myImage,x,y,"yes")>

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

<cfoutput><br>

</cfoutput>

<cfimage source=#myImage# action="writeToBrowser">

</body>

</html>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 12, 2016 0
LEGEND ,
May 12, 2016

Copy link to clipboard

Copied

I don't typically write code for others - I'm pretty staunch about those seeking help write their own and then I/we can help troubleshoot.

But I've never even HEARD of imageDrawLines() until your question, and had to see how to work it.  So.. at that point, why NOT provide it? 

Glad to see you got it working.

V/r,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 12, 2016 0