FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DRAWING

Draw arcs into regions


Tha I produced my own Arc routine made up of LINETOs which will definitely be included into a region.

Code is below

Andy

'My Arc - Allows Arcs to be drawn in regions
'parameters: rect coordinates, startpos (absolute), spread (relative)
'(for easy conversion from Mac ARC toolbox calls)
'Draws in current pen state and colour
LOCAL FN myarc(x1 ,y1 ,x2 ,y2 ,startangle,spread)
  DIM a,b,stepper,angle!,radspread!,rotc!,numberofpoints,i,x,y,oldx,oldy
'DIM rect.8 'only needed if you want to see the rect
  DIM resolution
'you may want different (probably finer) resolutions
  resolution=36
'point drawn every 10degrees
  a =(x2 -x1)/2 'Oval's a
  b =(y2 -y1)/2 'Oval's b
'CALL SETRECT(rect,x1,y1,x2,y2)
'CALL FRAMERECT(rect)
  angle!=(startangle)/57.3
'degrees to radians
  x=a*SIN(angle!)
'start x position
  y=b-b*COS(angle!)
'position inverted due to Mac pixel coordinate
  radspread!=(startangle+spread)/57.3
'relative spread of arc turned to absolute radians
  rotc!=2*3.14159/resolution
'rotation constant depending on resolution
  numberofpoints=(radspread!-angle!)/rotc!
'we're only sampling - we want this to be quick
  stepper=1
'usually clockwise
  IF numberofpoints<0 THEN stepper=-1
'negative values are anti-clockwise
  FOR i=0TO numberofpoints STEP stepper
    oldx=x
'set up old x and y
    oldy=y
    angle!=angle!+rotc!*stepper
    x=a*SIN(angle!)
'Oval formulae
    y=b-b*COS(angle!)
'(but corrected for Mac pixel coordinates)
    CALL MOVETO (x1+a+oldx ,y1+oldy) 'Gworld friendly
    CALL LINETO (x1+a+x,y1+y) '(PLOT isn't!)
  NEXT i
END FN

CLS
COORDINATE WINDOW
COLOR _zblack
FN myarc(20,20,200,100,0,45)
COLOR _zyellow
FN myarc(20,20,200,100,90,90)
COLOR _zred
FN myarc(20,20,200,100,180,90)
COLOR _zgreen
FN myarc(20,20,200,100,270,90)
COLOR _zblue
FN myarc(20,20,200,100,360,-90)
DO
UNTIL INKEY$<>""