forked from QB64-Phoenix-Edition/QB64pe
-
Notifications
You must be signed in to change notification settings - Fork 0
Alternative circle routine
github-actions[bot] edited this page Jun 16, 2022
·
7 revisions
Circle.BI Include file or SUB to use when using PAINT with pie charts or arc slices:
st! = s! ' copy start radian to local variable
en! = e! ' copy end radian to local variable
asp! = a! ' copy aspect ratio to local variable
IF asp! <= 0 THEN asp! = 1 ' keep aspect ratio between 0 and 4
IF asp! > 4 THEN asp! = 4
IF asp! < 1 THEN xr! = r! * asp! * 4 ELSE xr! = r! ' calculate x/y radius based on aspect ratio
IF asp! > 1 THEN yr! = r! * asp! ELSE yr! = r!
IF st! < 0 THEN s% = -1: st! = -st! ' remember if line needs drawn from center to start radian
IF en! < 0 THEN e% = -1: en! = -en! ' remember if line needs drawn from center to end radian
IF s% THEN ' draw line from center to start radian?
nx% = cx% + xr! * COS(st!) ' yes, compute starting point on circle's circumference
ny% = cy% + yr! * -SIN(st!)
LINE (cx%, cy%)-(nx%, ny%), c~& ' draw line from center to radian
END IF
IF en! <= st! THEN en! = en! + 6.2831852 ' come back around to proper location (draw counterclockwise)
stepp! = 0.159154945806 / r!
c! = st! ' cycle from start radian to end radian
DO
nx% = cx% + xr! * COS(c!) ' compute next point on circle's circumfrerence
ny% = cy% + yr! * -SIN(c!)
PSET (nx%, ny%), c~& ' draw the point
c! = c! + stepp!
LOOP UNTIL c! >= en!
IF e% THEN LINE -(cx%, cy%), c~& ' draw line from center to end radian if needed
'''END SUB'''
|
Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page