Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
54
Task/Pentagram/XPL0/pentagram.xpl0
Normal file
54
Task/Pentagram/XPL0/pentagram.xpl0
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
proc FillArea(X, Y, C0, C); \Replace area colored C0 with color C
|
||||
int X, Y, \starting coordinate for flood fill algorithm
|
||||
C0, C; \initial color, and color to replace it with
|
||||
def S=8000; \size of queue (must be an even number)
|
||||
int Q(S), \queue (FIFO)
|
||||
F, E; \fill and empty indexes
|
||||
|
||||
proc EnQ(X, Y); \Enqueue coordinate
|
||||
int X, Y;
|
||||
[Q(F):= X;
|
||||
F:= F+1;
|
||||
Q(F):= Y;
|
||||
F:= F+1;
|
||||
if F >= S then F:= 0;
|
||||
]; \EnQ
|
||||
|
||||
proc DeQ; \Dequeue coordinate
|
||||
[X:= Q(E);
|
||||
E:= E+1;
|
||||
Y:= Q(E);
|
||||
E:= E+1;
|
||||
if E >= S then E:= 0;
|
||||
]; \DeQ
|
||||
|
||||
[if C0 = C then return;
|
||||
F:= 0; E:= 0;
|
||||
EnQ(X, Y);
|
||||
while E # F do
|
||||
[DeQ;
|
||||
if ReadPix(X, Y) = C0 then
|
||||
[Point(X, Y, C);
|
||||
EnQ(X+1, Y); \enqueue adjacent pixels
|
||||
EnQ(X-1, Y);
|
||||
EnQ(X, Y+1);
|
||||
EnQ(X, Y-1);
|
||||
];
|
||||
];
|
||||
]; \FillArea
|
||||
|
||||
def Size = 200.;
|
||||
def Pi = 3.141592654;
|
||||
def Deg144 = 4.*Pi/5.;
|
||||
int X, Y, N;
|
||||
[SetVid($12); \set 640x480x4 VGA graphics
|
||||
for Y:= 0 to 480-1 do \fill screen
|
||||
[Move(0, Y); Line(640-1, Y, $F\white\)];
|
||||
for N:= 0 to 5 do \draw pentagram
|
||||
[X:= fix(Size*Sin(float(N)*Deg144));
|
||||
Y:= fix(Size*Cos(float(N)*Deg144));
|
||||
if N = 0 then Move(X+320, 240-Y)
|
||||
else Line(X+320, 240-Y, 4\red\);
|
||||
];
|
||||
FillArea(0, 0, $F, 1); \replace white (F) with blue (1)
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue