Re: makeLine w/ center coord rather than x1,y1,x2,y2?
Posted by dscho on Jul 17, 2007; 9:53pm
URL: http://imagej.273.s1.nabble.com/makeLine-w-center-coord-rather-than-x1-y1-x2-y2-tp3698838p3698841.html
Hi,
On Tue, 17 Jul 2007, Robert Barton wrote:
> When writing a macro, is it possible to draw a line based upon the
> center point of that line? IOW, rather than using
> makeLine(156,197,356,197), could I create a line by specifying the
> center point (256,197 in this case) and then specifying how long the
> line should be?
First, you'd need the angle, too. Second, it is easy to write a (macro)
function which does that:
-- snip --
function makeLine2(centerX, centerY, length, angle)
{
angle = -angle * PI / 180;
dX = cos(angle) * length / 2;
dY = sin(angle) * length / 2;
makeLine(centerX - dX, centerY - dY, centerX + dX, centerY + dY);
}
-- snap --
Ciao,
Dscho