69 lines
1.0 KiB
Plaintext
69 lines
1.0 KiB
Plaintext
// Rosetta Code problem: http://rosettacode.org/wiki/Simple_turtle_graphics
|
|
// Adapted from Python to Yabasic by Galileo, 01/2022
|
|
|
|
import turtle
|
|
|
|
sub rectang(width, height)
|
|
local i
|
|
|
|
for i = 1 to 2
|
|
move(height)
|
|
turn(-90)
|
|
move(width)
|
|
turn(-90)
|
|
next
|
|
end sub
|
|
|
|
sub square(size)
|
|
rectang(size, size)
|
|
end sub
|
|
|
|
sub triang(size)
|
|
local i
|
|
|
|
for i = 1 to 3
|
|
move(size)
|
|
turn(120)
|
|
next
|
|
end sub
|
|
|
|
sub house(size)
|
|
turn(180)
|
|
square(size)
|
|
triang(size)
|
|
turn(180)
|
|
end sub
|
|
|
|
sub barchart(lst$, size)
|
|
local t$(1), t(1), n, m, i, scale, width
|
|
|
|
n = token(lst$, t$())
|
|
redim t(n)
|
|
|
|
for i = 1 to n
|
|
t(i) = val(t$(i))
|
|
if t(i) > m m = t(i)
|
|
next
|
|
|
|
scale = size/m
|
|
width = size/n
|
|
for i = 1 to n
|
|
rectang(t(i)*scale, width)
|
|
pen(false)
|
|
move(width)
|
|
pen(true)
|
|
next
|
|
pen(false)
|
|
move(-size)
|
|
pen(true)
|
|
end sub
|
|
|
|
startTurtle()
|
|
color 255, 255, 255
|
|
turn(90)
|
|
house(150)
|
|
pen(false)
|
|
move(10)
|
|
pen(true)
|
|
barchart("0.5 0.333 2 1.3 0.5", 200)
|