;Draws a sequence of Koch “C” curves. The size of the curve is determined by n≤256; its position in the sequence by p≥0.
;The embedded, tabbed routine, kc, below is a “daemon”, which actually draws the curve. The daemon draws the p=0 curve directly, and the (p+1)th curve by replacing the line segments of the p=1 curve with scaled-down pth curves ( p≥0).
;The main kcurve-routine, “wrapped around” the daemon, merely positions the drawing-point so that the curve appears in the centre of the page. It also colours the sub-curves of the curve to show how the Koch “C” curve is constructed.
;Run the script in LibreOffice by accessing the LOGO-toolbar and hitting the green triangle button
;lines preceded by a “;” are ignored by logo
CLEARSCREEN
HOME
HIDETURTLE
To kcurve :n :p
GLOBAL c
c=SQRT 2
TO kc :n :p
IF :p=0 [ FD :n ] [
LT 45
kc :n/c :p-1
RT 90
kc :n/c :p-1
LT 45 ]
END
PU BK :n/2 LT 90 BK (3*:n)/8 RT 90 PS 4 PD
IF :p=0 [ PC [5] FD :n PC [0] ] [
LT 45
PC [5] kc :n/c :p-1 PC [0]
RT 90
PC [8] kc :n/c :p-1 PC [0]
LEFT 45 ]
PU RT 90 BK (3*:n)/8 LT 90 BK :n/2 PD PS 1
END
;”Groups” the components of the curve drawn by the command ‘kcurve (256, 10)’ “
PICTURE [ kcurve (256, 10) ]
;Exports an .svg-image of the curve (on a white background) to the folder containing the script
;PICTURE “LibreLogoKochCurve.svg” [ PU POS [0, 0] PD POS [PAGESIZE[0], 0] POS [PAGESIZE[0], (SQRT 2)*PAGESIZE[0]] POS [0, (SQRT 2)*PAGESIZE[0]] POS [0,0] PU HOME PD FILLCOLOR [3] FILL kcurve (256, 10) ]
;this .svg-image can be opened in LibreOffice and then “exported” as .png or .jpg
This was the script mentioned in my report:
;KOCH C
;Draws a sequence of Koch “C” curves. The size of the curve is determined by n≤256; its position in the sequence by p≥0.
;The embedded, tabbed routine, kc, below is a “daemon”, which actually draws the curve. The daemon draws the p=0 curve directly, and the (p+1)th curve by replacing the line segments of the p=1 curve with scaled-down pth curves ( p≥0).
;The main kcurve-routine, “wrapped around” the daemon, merely positions the drawing-point so that the curve appears in the centre of the page. It also colours the sub-curves of the curve to show how the Koch “C” curve is constructed.
;Run the script in LibreOffice by accessing the LOGO-toolbar and hitting the green triangle button
;lines preceded by a “;” are ignored by logo
CLEARSCREEN
HOME
HIDETURTLE
To kcurve :n :p
GLOBAL c
c=SQRT 2
TO kc :n :p
IF :p=0 [ FD :n ] [
LT 45
kc :n/c :p-1
RT 90
kc :n/c :p-1
LT 45 ]
END
PU BK :n/2 LT 90 BK (3*:n)/8 RT 90 PS 4 PD
IF :p=0 [ PC [5] FD :n PC [0] ] [
LT 45
PC [5] kc :n/c :p-1 PC [0]
RT 90
PC [8] kc :n/c :p-1 PC [0]
LEFT 45 ]
PU RT 90 BK (3*:n)/8 LT 90 BK :n/2 PD PS 1
END
;”Groups” the components of the curve drawn by the command ‘kcurve (256, 10)’ “
PICTURE [ kcurve (256, 10) ]
;Exports an .svg-image of the curve (on a white background) to the folder containing the script urve.svg” [ PU POS [0, 0] PD POS [PAGESIZE[0], 0] POS [PAGESIZE[0], (SQRT 2)*PAGESIZE[0]] POS [0, (SQRT 2)*PAGESIZE[0]] POS [0,0] PU HOME PD FILLCOLOR [3] FILL kcurve (256, 10) ]
;PICTURE “LibreLogoKochC
;this .svg-image can be opened in LibreOffice and then “exported” as .png or .jpg