Page 1 of 1

circle parameters

Posted: 2008-05-24T05:28:14-07:00
by rmabry
One can use -draw to make a circle.

circle x0,y0 x1,y1

The first point x0,y0 is the center, the second point x1,y1 is any other point on the circle, this being used to calculate a radius. But there are many times when it is more convenient to simply specify a radius. (It is also pretty standard). How hard/dangerous would it be to allow an overloading of the syntax, in order to use this?

circle x0,y0 r


Rick

Re: circle parameters

Posted: 2008-06-05T18:54:53-07:00
by anthony
Would be nice... A cross between a 'point' and a 'circle'
Perhaps dot x,y,r

However as a solution try drawing a stroke with an appropriate stroke width and line end caps.

Code: Select all

    convert -size 100x100 xc: \
            -draw 'fill none  stroke black stroke-linecap round
                stroke-width 40    line 50,40 50,40.0001' \
         x:
And you have a circle that is 40 pixels in diameter!!!!

Note that you must draw a line of some distance even if it is very very tiny sub-pixel length, or IM will draw NOTHING!!

This use of very wide stroke-widths is examples in IM examples
http://imagemagick.org/Usage/draw/#simple

I found them interesting, but have not push them as a drawing technique.

Re: circle parameters

Posted: 2008-06-05T20:06:45-07:00
by rmabry
anthony wrote:Would be nice... A cross between a 'point' and a 'circle'
Perhaps dot x,y,r
Why not overload circle? For one thing, "dot" implies a fill, but I'd want to get a stroked and/or filled circle as a result.

It's hardly a big deal, since one can use "circle x,y, x+r,y", for example. It's just the principle of the thing. (Which principle it is, I cannot say.)
However as a solution try drawing a stroke with an appropriate stroke width and line end caps.

Code: Select all

    convert -size 100x100 xc: \
            -draw 'fill none  stroke black stroke-linecap round
                stroke-width 40    line 50,40 50,40.0001' \
         x:
And you have a circle that is 40 pixels in diameter!!!!

Note that you must draw a line of some distance even if it is very very tiny sub-pixel length, or IM will draw NOTHING!!
Heh, heh. Cute. And I suppose you can use another one on top of it with a different color to fake a stroke.

So Anthony, you must be finally getting caught up on your IM messages if you can look at this one. :-)

Thanks,
Rick

Re: circle parameters

Posted: 2008-06-05T20:26:34-07:00
by fmw42
in a shell script you could do:

radius=40
x0=some value
y0=some value
x1=`expr $x0 + $radius`
y1=$y0

convert ... -draw "circle $x0,$y0 $x1,$y1" ...

Re: circle parameters

Posted: 2008-06-05T20:53:26-07:00
by anthony
After mail, I have been doing about a page of User forum messages every few days (from oldest to newest), and today I caught up with that, so now I did the developers forum, where I can skip a lot more messages.

I have now caught up with both forums. But it is a long weekend here so it is only short lived.

I did add an announcement forum page, listing the major additions to IM examples, since I got back. Some I found very interesting. Fred also has been very busy too, considering the number of scripts he now has.

Re: circle parameters

Posted: 2008-06-06T03:20:17-07:00
by rmabry
fmw42 wrote:in a shell script you could do
Sure, lucky *nixers. I'm more inclined to PerlMagick these days, so it is not an issue even for my Windows-bound self.

But I guess I should have made it more clear that I was not looking for a way to do this, just kvetching at the syntax. Look at SVG, for instance. Almost every programmable package that does graphics I've seen uses (x,y), r.

So my question remains, why not allow both syntaxes?

Rick

Re: circle parameters

Posted: 2008-06-06T12:12:21-07:00
by fmw42
Yes, I would love to see that also. It makes sense to me, too.

But the IM developers are very busy with backlog of things to do. It would be great if there were other software developers willing to contribute some time to such development.

Re: circle parameters

Posted: 2008-06-09T17:34:27-07:00
by anthony
hint, hint. nudge, nudge. wink, wink!

Re: circle parameters

Posted: 2008-07-25T03:12:38-07:00
by anthony
First the parameters are floating point. But remember that strokewidth is also a parameter, and is stroke color is set the circle make be stroke width wider that what you specify using x1,y1.

The radius can be set using either a x or y axis difference for the calculating the x1,y1 point.

And yes I would agree that being able to specify a radius instead of x1,y1 would make a lot more sense in a lot more situations. However if you are going to specify it in that way a different operational method would be needed.

However there is a work around. Specify stroke-width as the diameter of the circle wanted, then draw a line from x0,y0 to x0,y1 where y1=y0+epsilon where epsilon is VERY VERY small.

EG: Blue circle by 'diameter'

Code: Select all

  convert -size 100x100 xc: -stroke blue -strokewidth 50 \
                -draw 'stroke-linecap round line 50,50 50,50.00001'
                blue_circle.png
No it isn't a great solution either.

Re: circle parameters

Posted: 2008-10-20T00:52:53-07:00
by anthony
Depend on the method chosen.

As a result of the above OLD discussion I generated a drawing circles section in Draw. Some require calculation, others do not for a fixed radius.
http://www.imagemagick.org/Usage/draw/#circles

See also the section above this on Symols
http://www.imagemagick.org/Usage/draw/#symbols