Page 1 of 1

[2D Draw] ability to draw arc rather full circle/ellipse

Posted: Tue Dec 11, 2012 5:28 pm
by Golfy
On Atari ST, GFA Basic had created circle x, y, r, start-angle, end-angle
It would be nice to have these kind of parameters (in degre)

Thanks !

Re: [2D Draw] ability to draw arc rather full circle/ellipse

Posted: Fri Dec 14, 2012 4:47 pm
by Lothar Schirm
Try this:

Code: Select all

Procedure arc(x.i, y.i, r.i, color.i, phimin.d, phimax.d, aspect.d = 1)
  ; draws an arc (circle or ellipse). Parameters:
  ; - x, y = coordinates of the circle's center
  ; - r = radius
  ; - color = color
  ; - phimin, phimax = starting and ending angle in radians
  ;- aspect = aspect ratio (ratio of the y radius over the x radius), default = 1 (circle)
  
  Protected.i i
  Protected.d dphi, phi1, phi2, x1, y1, x2, y2 
  
  dphi = (phimax - phimin) / 100
  
  For i = 0 To 99
    phi1 = phimin + i * dphi
    x1 = x + r * Cos(phi1)
    y1 = y - r * aspect * Sin(phi1)    
    phi2 = phi1 + dphi
    x2 = x + r * Cos(phi2)
    y2 = y - r * aspect * Sin(phi2)    
    LineXY(x1, y1, x2, y2, color)
  Next
  
EndProcedure
I use this code, with starting and ending angle in radians, but I think you can easily modify it with angles in degree.

Re: [2D Draw] ability to draw arc rather full circle/ellipse

Posted: Mon Jan 07, 2013 1:49 pm
by Golfy
Thanks Lothar :)

I've tried your code (with degree to radian conversion : rad = deg * PI / 180) and it seems to works.

However, the suggestion goes far deeper than only drawing arc because integrated commands are faster than our compilated codes and as you see in the following example, I can't fill easely a large arc.

It's a good workaround but not enough :(

Example in GFABasic (3.0, from year 1991) :

Code: Select all

CIRCLE x,y,r [,phi0,phi1]
DEFFILL [col,][style,][pattern]
DRAW x1,y1 TO x2,y2 [TO x3,y3 ...] 
ELLIPSE x,y,rx,ry [,phi0,phi1]
FILL x,y
LINE x,y,xx,yy

; Plain Box, circle, ellipse...
PBOX x,y,xx,yy
PCIRCLE x,y,r [,phi0,phi1]
PELLIPSE z,y,rx,ry [,phi0,phi1]
PRBOX x,y,xx,yy

POLYLINE n,x(),y() [OFFSET xx,yy]
POLYFILL n,x(),y() [OFFSET xx,yy]
POLYMARK n,x(),y() [OFFSET xx,yy]

RBOX x,y,xx,yy       (rounded box)
Polyfill could be a great workaround :|
Full reference here : http://www.geocities.ws/slaszcz/mup/gfaframe.html

Current graphics functions could be included like bezier or other S-curve, etc.

GFABasic :

Code: Select all

CURVE x0,y0,x1,y1,x2,y2 ,x3,y3