Circle
10 COLOUR_QL
12 ch = FOPEN("con_")
14 xs% = SCR_XLIM(#ch): ys% = SCR_YLIM(#ch)
16 WINDOW#ch; xs%, ys%, 0, 0
18 CLS#ch
20 dt = DATE
22 xs% = xs% / 2: ys% = ys% / 2
24 FOR s% = 1 TO 250
26 Circ#ch; xs%, ys%, s%, 1, RND(0 TO 7), 0
28 END FOR s%
30 PRINT#ch; DATE - dt; 's'
32 PAUSE#ch: CLOSE
34 IF JOBID: QUIT: ELSE : STOP
36 :
38 :
100 rem + ------------------------------------------------------------------------ +
102 rem |< Circle >|
104 rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
106 rem | Draw filled or empty ellipse using pixel coordinates |
108 rem | |
110 rem | ch% = channel number |
112 rem | x%, y% = centre coordinates |
114 rem | r% = radius |
116 rem | s = "squash". Round QPC2 etc: 1, QL etc: 0.75 |
118 rem | c = colour |
120 rem | f = fill; 1 => fill, 0 => empty |
122 rem + ------------------------------------------------------------------------ +
124 rem | V0.00, pjw, Apr 1996, using graphics scale |
126 rem | V0.01, pjw, Apr 1996, SINus table |
128 rem | V0.02, pjw, Jun 1999, for ASCII art |
130 rem | V0.04, pjw, Jun 2003, Screen coordinates (BLOCK) |
132 rem | V0.05, pjw, Oct 2006, as above, speedup |
134 rem | V0.06, pjw, Jan 2018, optimised density, added squash |
136 rem | V0.06, pjw, 2022 Nov 13, Tidied and added header |
138 rem + ------------------------------------------------------------------------ +
140 :
142 DEFine PROCedure Circ(ch%, x%, y%, r%, s, c, f)
144 LOCal i, tx%, ty%, n%
146 n% = 1
148 BLOCK#ch%; n%, n%, x%, y%, c
150 IF f THEN
152 FOR i = 0 TO PI / 2 STEP 5 / (2 * PI * r%)
154 tx% = COS(i) * r%: ty% = SIN(i) * r% * s
156 BLOCK#ch%; tx% + tx%, n%, x% - tx%, y% + ty%, c
158 BLOCK#ch%; tx% + tx%, n%, x% - tx%, y% - ty%, c
160 END FOR i
162 ELSE
164 FOR i = 0 TO PI / 2 STEP 16 / (2 * PI * r%)
166 tx% = COS(i) * r%: ty% = SIN(i) * r% * s
168 BLOCK#ch%; n%, n%, x% + tx%, y% + ty%, c
170 BLOCK#ch%; n%, n%, x% - tx%, y% + ty%, c
172 BLOCK#ch%; n%, n%, x% - tx%, y% - ty%, c
174 BLOCK#ch%; n%, n%, x% + tx%, y% - ty%, c
176 END FOR i
178 END IF
180 END DEFine
182 :
Generated with sb2htm on 2022 Nov 16
©pjwitte 2oo1 - 2o22
QL Software
