RoestVrijStaal / grafx2

Automatically exported from code.google.com/p/grafx2
0 stars 0 forks source link

Rotated ellipses #472

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Idea suggested by Dawnbringer.
Possible implementation:
http://www.geometrictools.com/Documentation/IntegerBasedEllipseDrawing.pdf

Workflow : first draw an aligned ellipse with the current method. Then allow to 
rotate it similar to brush-rotate tool.

Original issue reported on code.google.com by pulkoma...@gmail.com on 8 Jan 2012 at 2:23

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Post-rotate? Use an algorithm that draws the actual ellpise at any angle. Let 
the user set the size first, then rotate:

--
-- rot: Rotation in degrees
-- stp: Step is # of line segments (more is "better")
-- a & b are axis-radius
function ellipse(x,y,a,b,stp,rot,col) 
 local n,m,rad,al,sa,ca,sb,cb,ox,oy,x1,y1,ast
 m = math; rad = m.pi/180; ast = rad * 360/stp;
 sb = m.sin(-rot * rad); cb = m.cos(-rot * rad)
 for n = 0, stp, 1 do
  ox = x1; oy = y1;
  sa = m.sin(ast*n) * b; ca = m.cos(ast*n) * a
  x1 = x + ca * cb - sa * sb
  y1 = y + ca * sb + sa * cb
  if (n > 0) then drawline(ox,oy,x1,y1,col); end
 end
end
--

Original comment by annas...@hotmail.com on 8 Jan 2012 at 2:31

GoogleCodeExporter commented 8 years ago
Yes, the algorithm draw a rotated ellipse.
I was talking about the workflow and steps to carry with the mouse. Which is 
rather annoying to set up the way it's done in GrafX2.

I can play with algorithms, but I'm not so motivated to play with the operation 
stack...

Original comment by pulkoma...@gmail.com on 8 Jan 2012 at 3:07