Page 1 of 1

Confused on the -draw option

Posted: 2007-02-10T11:13:25-07:00
by Scott.Prog
Okay, I've been staring at this and trying various parameters and can't make heads or tails of how or why this:

Code: Select all

    convert -size 100x60 xc:skyblue -fill white -stroke black \
            -draw "circle 50,30 40,10"          draw_circle.gif
Generates this:

Image

I can certainly see how the starting point of the draw operation is centered at 50,30. When I find the center of the image, it is at 50,30. I can even make quasi- sense of the 40 value being that the left and right edges of the circle are approximately 20 pixels (1/2) left and right, at 20, 70 (if that assumption is even valid).

The number 10 is throwing me. The top edge of the circle is *approximately* at y-axis 10 but that use doesn't make sense to me to have the second parameter (10) be an axis position when the first parameter (40) looks to be an offset value.

Feel to flame my n00bery, tell me to read the manual (which I have), insult my family lineage, etc. but I just don't get it. Explain please? Thanks in advance.

Re: Confused on the -draw option

Posted: 2007-02-10T11:22:06-07:00
by Bonzo
From memory :
Center point of the circle from top left corner in X = 50
Center point of the circle from top left corner in Y = 30

Start point of the circle from top left corner in X = 40
Start point of the circle from top left corner in Y = 10

Re: Confused on the -draw option

Posted: 2007-02-10T11:41:05-07:00
by Scott.Prog
Thank you for responding. That is also what I would have assumed and would be intuitive. However, the top left corner of the image is at 30,10, not 40,10. Here is a the same graphic with a bounding box drawn centered on the circle and the corner positions annotated:

Image

What am I missing?

Re: Confused on the -draw option

Posted: 2007-02-10T12:15:42-07:00
by el_supremo
"circle 50,30 40,10"
The first coordinate is that of the centre of the circle. The second is the coordinate of a point on the circumference.

Pete

Re: Confused on the -draw option

Posted: 2007-02-10T12:17:49-07:00
by Bonzo
The second 2 numbers are where the cicle is drawn from; I would have written it like:

Code: Select all

"circle 50,30 50,10"
This would give you a circle with the center at X50 Y30 and the radius would be 30 - 10 = 20

Th radius in the original example would have been 22.36 ?

Re: Confused on the -draw option

Posted: 2007-02-10T12:23:33-07:00
by Scott.Prog
Bonzo wrote: The second 2 numbers are where the cicle is drawn from; I would have written it like:

Code: Select all

"circle 50,30 50,10"
This would give you a circle with the center at X50 Y30 and the radius would be 30 - 10 = 20


Alright, I suppose that helps some. There are really only three data points in use then? The location of the center point of the circle and a radius value? What, if any, is the purpose of the 3rd value, in your example "circle 50,30 50,10"?

The example I had provided came from Anthony's examples page:

http://www.imagemagick.org/Usage/draw/#intro

Re: Confused on the -draw option

Posted: 2007-02-10T12:29:04-07:00
by Scott.Prog
The property must have some effect. Changing the original example from 40 to 50 results in a smaller circle:

Orig Image "circle 50,30 40,10"
New Image "circle 50,30 50,10"

Re: Confused on the -draw option

Posted: 2007-02-10T12:30:21-07:00
by Bonzo
The point on the circumferance ( as el_supremo says ) needs fixing in the X and Y direction.
Center point of the circle from top left corner in X = 50
Center point of the circle from top left corner in Y = 30

Start point of the circle from top left corner in X = 40
Start point of the circle from top left corner in Y = 10

I normaly use the same position in the X for both the X coordinates as it simplys things and just set the radius in the Y.

Re: Confused on the -draw option

Posted: 2007-02-10T12:36:24-07:00
by Bonzo
Perhaps I have it the wrong way around and the second set of numbers is the distance from the center of the circle to a point on the circumferance - I have only used circle once before !

That means: circle 50,30 40,10 has a rad of 22.36
and circle: 50,30 50,10 has a rad of 10

That looks better; its a long time since I went to school but you use Pythagoras' Theorem

Re: Confused on the -draw option

Posted: 2007-02-10T13:49:55-07:00
by Scott.Prog
Ok, I finally understand. Sometimes you look at a problem too long and get lost in a particular track of thinking. This works more like a real world compass for drawing circles. You place the compass point at a specific point on the page which becomes your first two values, the center point of the circle. After spreading the calipers, the point on the page where you place the pencil point becomes the two second values which are not offset from the center point and do not represent a radius value, per se. Instead, they are absolute coordinates from which ImageMagick calculates the radius value and draws the circle.

Counterintuitive at first and perhaps contrary to the "bounding box" principal of Photoshop and others but very usable once understanding the principals.

Thanks to all who responded as you got me out of my thinking rut. Your input is appreciated.

Re: Confused on the -draw option

Posted: 2007-02-10T20:37:23-07:00
by anthony
I am glad you have all worked it out...

If you want to define a circle in terms of a bounding box use ellipse. If you want it in terms of a one point to another point use the 'path' circle method.
All three are given in IM examples, drawing page.