B
This commit is contained in:
parent
e5e8880e41
commit
518da4a923
1019 changed files with 15877 additions and 0 deletions
|
|
@ -0,0 +1,43 @@
|
|||
Width% = 200
|
||||
Height% = 200
|
||||
|
||||
REM Set window size:
|
||||
VDU 23,22,Width%;Height%;8,16,16,128
|
||||
|
||||
REM Draw circles:
|
||||
PROCcircle(100,100,40, 0,0,0)
|
||||
PROCcircle(100,100,80, 255,0,0)
|
||||
END
|
||||
|
||||
DEF PROCcircle(cx%,cy%,r%,R%,G%,B%)
|
||||
LOCAL f%, x%, y%, ddx%, ddy%
|
||||
f% = 1 - r% : y% = r% : ddy% = - 2*r%
|
||||
PROCsetpixel(cx%, cy%+r%, R%,G%,B%)
|
||||
PROCsetpixel(cx%, cy%-r%, R%,G%,B%)
|
||||
PROCsetpixel(cx%+r%, cy%, R%,G%,B%)
|
||||
PROCsetpixel(cx%-r%, cy%, R%,G%,B%)
|
||||
WHILE x% < y%
|
||||
IF f% >= 0 THEN
|
||||
y% -= 1
|
||||
ddy% += 2
|
||||
f% += ddy%
|
||||
ENDIF
|
||||
x% += 1
|
||||
ddx% += 2
|
||||
f% += ddx% + 1
|
||||
PROCsetpixel(cx%+x%, cy%+y%, R%,G%,B%)
|
||||
PROCsetpixel(cx%-x%, cy%+y%, R%,G%,B%)
|
||||
PROCsetpixel(cx%+x%, cy%-y%, R%,G%,B%)
|
||||
PROCsetpixel(cx%-x%, cy%-y%, R%,G%,B%)
|
||||
PROCsetpixel(cx%+y%, cy%+x%, R%,G%,B%)
|
||||
PROCsetpixel(cx%-y%, cy%+x%, R%,G%,B%)
|
||||
PROCsetpixel(cx%+y%, cy%-x%, R%,G%,B%)
|
||||
PROCsetpixel(cx%-y%, cy%-x%, R%,G%,B%)
|
||||
ENDWHILE
|
||||
ENDPROC
|
||||
|
||||
DEF PROCsetpixel(x%,y%,r%,g%,b%)
|
||||
COLOUR 1,r%,g%,b%
|
||||
GCOL 1
|
||||
LINE x%*2,y%*2,x%*2,y%*2
|
||||
ENDPROC
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
void raster_circle(
|
||||
image img,
|
||||
unsigned int x0,
|
||||
unsigned int y0,
|
||||
unsigned int radius,
|
||||
color_component r,
|
||||
color_component g,
|
||||
color_component b );
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#define plot(x, y) put_pixel_clip(img, x, y, r, g, b)
|
||||
|
||||
void raster_circle(
|
||||
image img,
|
||||
unsigned int x0,
|
||||
unsigned int y0,
|
||||
unsigned int radius,
|
||||
color_component r,
|
||||
color_component g,
|
||||
color_component b )
|
||||
{
|
||||
int f = 1 - radius;
|
||||
int ddF_x = 0;
|
||||
int ddF_y = -2 * radius;
|
||||
int x = 0;
|
||||
int y = radius;
|
||||
|
||||
plot(x0, y0 + radius);
|
||||
plot(x0, y0 - radius);
|
||||
plot(x0 + radius, y0);
|
||||
plot(x0 - radius, y0);
|
||||
|
||||
while(x < y)
|
||||
{
|
||||
if(f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x + 1;
|
||||
plot(x0 + x, y0 + y);
|
||||
plot(x0 - x, y0 + y);
|
||||
plot(x0 + x, y0 - y);
|
||||
plot(x0 - x, y0 - y);
|
||||
plot(x0 + y, y0 + x);
|
||||
plot(x0 - y, y0 + x);
|
||||
plot(x0 + y, y0 - x);
|
||||
plot(x0 - y, y0 - x);
|
||||
}
|
||||
}
|
||||
#undef plot
|
||||
Loading…
Add table
Add a link
Reference in a new issue