Page 1 of 1

how to given the input coordinates

Posted: 2011-07-29T21:54:11-07:00
by sin
hi,

can you please tell me how should i give the coordinates of a rectangle in a bash script??

Re: drawing a polygon

Posted: 2011-07-30T01:29:14-07:00
by Bonzo
The points are the ends of the lines and with a polygon it is self closing so the last point has a line to the first point.

http://www.imagemagick.org/script/comma ... s.php#draw
The polyline and polygon primitives require three or more points to define their perimeters. A polyline is simply a polygon in which the final point is not stroked to the start point. When unfilled, this is a polygonal line. If the -stroke setting is none (the default), then a polyline is identical to a polygon.
So you have to calculate each point and can not say for example how many sides you want and the inscribing circle diamter etc.

Re: how to given the input coordinates

Posted: 2011-07-30T04:35:11-07:00
by anthony
A rectangle is given as the positions of two diagonally oppisite corners. Any corners can be used.
See Draw Primatives
http://www.imagemagick.org/Usage/draw/#primitives

If you use a SVG path instead of a polyline or polygon, you can 'close' the path with a Z command.
See Draw SVG Path, moves. lines and closures.
http://www.imagemagick.org/Usage/draw/#lines

Re: how to given the input coordinates

Posted: 2011-08-02T10:51:24-07:00
by sin
how to crop that particular polygon using crop command??

Re: how to given the input coordinates

Posted: 2011-08-02T11:11:19-07:00
by fmw42
sin wrote:how to crop that particular polygon using crop command??

see -trim or -crop

http://www.imagemagick.org/Usage/crop/#trim
http://www.imagemagick.org/Usage/crop/#crop

or explain in more detail what you are trying to do

Re: how to given the input coordinates

Posted: 2011-08-02T11:35:47-07:00
by Bonzo
Crop and trim can only work on rectangles and you want a poygon so I assume you will need to make a mask from the polygon.

Re: how to given the input coordinates

Posted: 2011-08-02T12:18:55-07:00
by sin
okay, thank you.

but the command for polygon/polyline is written in a .bat file and executed, it is not giving the correct picture whereas if it typed directly in the command line it is working.

Re: how to given the input coordinates

Posted: 2011-08-02T12:23:21-07:00
by fmw42
Bonzo,

Perhaps he wants the outside simply transparent rather than cropped. I will leave this one to you as he is on Windows.

Fred

Re: how to given the input coordinates

Posted: 2011-08-02T17:57:32-07:00
by anthony
sin wrote:how to crop that particular polygon using crop command??
Two ways. image processing way as mentioned in to draw teh shape on a solid color canvas (transparent or colored) and trim. Note however that the acual bounds may be one pixel larger all around as -- lines have thickness and anti-alias smoothing

The other way is to get the maximum and minimum of all X and Y coordinates of the polygon. This is actually must faster when you have the coordinates, but may be slower if you don't know the coordinates. It also requires processin outside ImageMagick core library or commands, that is from the controlling API script/program.

Note the bound may not be correct if the shape is not a polygon of straight lines, but contains curves between the 'knot' or control coordinates. In that case a curve may extend beyond the min/max bounds of the input coordinates.


ASIDE: their is something I now consider a bug in drawing, in that the 'fill' will fill shapes as if it also includes a 1/2 pixel stroke width. This is historical, as typically users expect that when no 'stroke' border is included, but it is actually wrong.
See http://www.imagemagick.org/Usage/draw/#bounds

Re: how to give the input coordinates

Posted: 2011-08-04T05:21:37-07:00
by sin
echo "enter HEM_X3"
echo
set /p "E=>"
if %E% == End goto End
if %E% == end goto End
if %E% == "End" goto End
if %E% == "end" goto End

echo "enter HEM_Y3"
echo
set /p "F=>"
if %F% == End goto End
if %F% == end goto End
if %F% == "End" goto End
if %F% == "end" goto End

echo "enter HEM_X4"
echo
set /p "G=>"
if %G% == End goto End
if %G% == end goto End
if %G% == "End" goto End
if %G% == "end" goto End

echo "enter HEM_Y4"
echo
set /p "H=>"
if %H% == End goto End
if %H% == end goto End
if %H% == "End" goto End
if %H% == "end" goto End

convert -size 450x600 xc:black -fill white -stroke white -draw "polyline %G%,%H%,%E%,%F%,E+20,600,G-20,600" dwn.png


this is the .bat file i have written to get a polygon(using polyline). but I'm unable to get that :(