Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
|
|
@ -3,7 +3,7 @@ F sierpinski_square(fname, size, length, order)
|
|||
V y = Float(length)
|
||||
V angle = 0.0
|
||||
|
||||
V outfile = File(fname, ‘w’)
|
||||
V outfile = File(fname, WRITE)
|
||||
outfile.write(‘<svg xmlns='http://www.w3.org/2000/svg' width='’size‘' height='’size"'>\n")
|
||||
outfile.write("<rect width='100%' height='100%' fill='white'/>\n")
|
||||
outfile.write(‘<path stroke-width='1' stroke='black' fill='none' d='’)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
BEGIN # Sierpinski Square Curve in SVG - SVG generation translated from the #
|
||||
# FreeBASIC sample (which is a translation of C++) #
|
||||
# uses the RC Algol 68 L-System library for the L-System evaluation & #
|
||||
# interpretation #
|
||||
|
||||
PR read "lsystem.incl.a68" PR # include L-System utilities #
|
||||
|
||||
PROC sierpinski square curve = ( STRING fname, INT size, length, order )VOID:
|
||||
IF FILE svg file;
|
||||
BOOL open error := IF open( svg file, fname, stand out channel ) = 0
|
||||
THEN
|
||||
# opened OK - file already exists and #
|
||||
# will be overwritten #
|
||||
FALSE
|
||||
ELSE
|
||||
# failed to open the file #
|
||||
# - try creating a new file #
|
||||
establish( svg file, fname, stand out channel ) /= 0
|
||||
FI;
|
||||
open error
|
||||
THEN # failed to open the file #
|
||||
print( ( "Unable to open ", fname, newline ) );
|
||||
stop
|
||||
ELSE # file opened OK #
|
||||
|
||||
REAL x := ( size - length ) / 2;
|
||||
REAL y := length;
|
||||
INT angle := 0;
|
||||
put( svg file, ( "<svg xmlns='http://www.w3.org/2000/svg' width='"
|
||||
, whole( size, 0 ), "' height='", whole( size, 0 ), "'>"
|
||||
, newline, "<rect width='100%' height='100%' fill='white'/>"
|
||||
, newline, "<path stroke-width='1' stroke='black' fill='none' d='"
|
||||
, newline, "M", whole( x, 0 ), ",", whole( y, 0 ), newline
|
||||
)
|
||||
);
|
||||
|
||||
LSYSTEM ssc = ( "F+XF+F+XF"
|
||||
, ( "X" -> "XF-F+F-XF+F+XF-F+F-X"
|
||||
)
|
||||
);
|
||||
STRING curve = ssc EVAL order;
|
||||
curve INTERPRET ( ( CHAR c )VOID:
|
||||
IF c = "F" THEN
|
||||
x +:= length * cos( angle * pi / 180 );
|
||||
y +:= length * sin( angle * pi / 180 );
|
||||
put( svg file, ( " L", whole( x, 0 ), ",", whole( y, 0 ), newline ) )
|
||||
ELIF c = "+" THEN
|
||||
angle +:= 90 MODAB 360
|
||||
ELIF c = "-" THEN
|
||||
angle +:= 270 MODAB 360
|
||||
FI
|
||||
);
|
||||
|
||||
put( svg file, ( "'/>", newline, "</svg>", newline ) );
|
||||
close( svg file )
|
||||
FI # sierpinski square # ;
|
||||
|
||||
sierpinski square curve( "sierpinski_square.svg", 635, 5, 5 )
|
||||
|
||||
END
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
proc lsysexp level . axiom$ rules$[] .
|
||||
for l to level
|
||||
an$ = ""
|
||||
for c$ in strchars axiom$
|
||||
for i = 1 step 2 to len rules$[]
|
||||
if rules$[i] = c$
|
||||
c$ = rules$[i + 1]
|
||||
break 1
|
||||
.
|
||||
.
|
||||
an$ &= c$
|
||||
.
|
||||
swap axiom$ an$
|
||||
.
|
||||
.
|
||||
proc lsysdraw axiom$ x y ang lng . .
|
||||
linewidth 0.3
|
||||
move x y
|
||||
for c$ in strchars axiom$
|
||||
if c$ = "F"
|
||||
x += cos dir * lng
|
||||
y += sin dir * lng
|
||||
line x y
|
||||
elif c$ = "-"
|
||||
dir -= ang
|
||||
elif c$ = "+"
|
||||
dir += ang
|
||||
.
|
||||
.
|
||||
.
|
||||
axiom$ = "F+XF+F+XF"
|
||||
rules$[] = [ "X" "XF-F+F-XF+F+XF-F+F-X" ]
|
||||
lsysexp 4 axiom$ rules$[]
|
||||
lsysdraw axiom$ 50 10 90 1.4
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
#define pi 4 * Atn(1)
|
||||
|
||||
Sub sierpinski_square(fname As String, size As Integer, length As Integer, order As Integer)
|
||||
Dim As Single x = (size - length) / 2
|
||||
Dim As Single y = length
|
||||
Dim As Single angle = 0.0
|
||||
|
||||
Dim As Integer i, j
|
||||
Dim As String t, s = "F+XF+F+XF"
|
||||
|
||||
For i = 1 To order
|
||||
t = ""
|
||||
For j = 1 To Len(s)
|
||||
Select Case Mid(s, j, 1)
|
||||
Case "X"
|
||||
t += "XF-F+F-XF+F+XF-F+F-X"
|
||||
Case Else
|
||||
t += Mid(s, j, 1)
|
||||
End Select
|
||||
Next j
|
||||
s = t
|
||||
Next i
|
||||
|
||||
Open fname For Output As #1
|
||||
Print #1, "<svg xmlns='http://www.w3.org/2000/svg' width='" ; size ; "' height='" ; size ; "'>"
|
||||
Print #1, "<rect width='100%' height='100%' fill='white'/>"
|
||||
Print #1, "<path stroke-width='1' stroke='black' fill='none' d='";
|
||||
|
||||
Print #1, "M" ; x ; "," ; y;
|
||||
For i = 1 To Len(s)
|
||||
Select Case Mid(s, i, 1)
|
||||
Case "F"
|
||||
x += length * Cos(angle * pi / 180)
|
||||
y += length * Sin(angle * pi / 180)
|
||||
Print #1, " L" ; x ; "," ; y;
|
||||
Case "+"
|
||||
angle = (angle + 90) Mod 360
|
||||
Case "-"
|
||||
angle = (angle - 90 + 360) Mod 360
|
||||
End Select
|
||||
Next i
|
||||
|
||||
Print #1, "'/>"
|
||||
Print #1, "</svg>"
|
||||
Close #1
|
||||
End Sub
|
||||
|
||||
sierpinski_square("sierpinski_square.svg", 635, 5, 5)
|
||||
Windowtitle "Hit any key to end program"
|
||||
Loading…
Add table
Add a link
Reference in a new issue