May 07, 2024, 11:51:50 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Here is an ARC function written by LarryA far long ago ^^

Started by pistol350, September 08, 2007, 06:38:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pistol350


'203  Arc() Function
'LarryA
'03-02-02

'Start angle and end angle are in degrees, not the dreaded and incomprehensible radians.

'Larry

'arcdemo... Ibasic PROGRAM demonstrating arc() funtion to draw arcs, since Ibasic CIRCLE command does not have start and end angle parameters
' Written by L a r r y A d c o c k Feb. 28, 2002 - Credit appreciated... Compensation appreciated even more
'
' The last parameter, arcdrawcolor, is optional... if it has not been stated in an ARC call, it will draw using the FRONTPEN color,
' but once it has been stated, all arcs will be drawn the stated color until explicitly changed
DEF win1:WINDOW
declare arc (arcwin:WINDOW, arcxcenter:DOUBLE, arcycenter:DOUBLE, arcrad:DOUBLE, arcstang:DOUBLE, arcendang:DOUBLE, arcdrawcolor:INT)

run = 1
WINDOW win1,10,10,600,400,@size|@minbox,0, "ARC demo",myhandler
CONTROL win1,"B,OK,10,10,50,20,0,1"


rad=0
for aa=1 to 10
rad=rad+10

arc(win1,150,150,rad,0,90,RGB(0,255,0))
arc(win1,250,150,rad,180,270,rgb(0,0,255))

next aa

'process messages until someone closes us
WAITUNTIL run = 0
CLOSEWINDOW win1
END

'=============================================================
SUB arc (arcwin:WINDOW, arcxcenter:DOUBLE, arcycenter:DOUBLE, arcrad:DOUBLE, arcstang:DOUBLE, arcendang:DOUBLE, arcdrawcolor:INT)
def divi,facet,cw:INT
def facitang,ang,x1,y1,x2,y2:DOUBLE
'if the drawing surface has normal Windows +x right +y down
'set cw=1 for clockwise or cw=-1 for counter-clockwise
cw=-1
divi=int((arcstang-arcendang)/4)
facetang=(arcstang-arcendang)/(cw*divi)
divi=abs(divi)

ang=arcstang
x2=arcxcenter+(rad*cos(ang*0.0174532925199433))
y2=arcycenter+(rad*sin(ang*0.0174532925199433))
for facet= 1 to divi
x1=x2
y1=y2
ang=ang+facetang
x2=arcxcenter+(rad*cos(ang*0.0174532925199433))
y2=arcycenter+(rad*sin(ang*0.0174532925199433))
line arcwin,x1,y1,x2,y2,arcdrawcolor
next facet
RETURN
'=============================================================

'the message handler subroutine for the window
sub myhandler
select @CLASS
case @IDCONTROL
select @CONTROLID
case 1
run=0
endselect
endselect
return
Regards,

Peter B.