Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Hilbert-curve/XPL0/hilbert-curve.xpl0
Normal file
35
Task/Hilbert-curve/XPL0/hilbert-curve.xpl0
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
def Order=5, Size=15; \length of line segment
|
||||
int Dir, X, Y;
|
||||
|
||||
proc GoFwd;
|
||||
[case Dir&3 of
|
||||
0: X:= X+Size;
|
||||
1: Y:= Y+Size;
|
||||
2: X:= X-Size;
|
||||
3: Y:= Y-Size
|
||||
other [];
|
||||
Line(X, Y, \white\7);
|
||||
];
|
||||
|
||||
proc Hilbert(Lev, Ang);
|
||||
int Lev, Ang;
|
||||
[if Lev then
|
||||
[Dir:= Dir+Ang;
|
||||
Hilbert(Lev-1, -Ang);
|
||||
GoFwd;
|
||||
Dir:= Dir-Ang;
|
||||
Hilbert(Lev-1, Ang);
|
||||
GoFwd;
|
||||
Hilbert(Lev-1, Ang);
|
||||
Dir:= Dir-Ang;
|
||||
GoFwd;
|
||||
Hilbert(Lev-1, -Ang);
|
||||
Dir:= Dir+Ang;
|
||||
];
|
||||
];
|
||||
|
||||
[SetVid($12); \640x480 graphics
|
||||
Dir:= 0; X:= 0; Y:= 0;
|
||||
Move(X, Y);
|
||||
Hilbert(Order, 1);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue