updated 10 print example from fall class
This commit is contained in:
parent
88d9e3b2e3
commit
fc4b8dae8b
93
10print.ld
93
10print.ld
|
@ -1,64 +1,49 @@
|
||||||
penup! ()
|
let cell_size = 10
|
||||||
goto! (150, 150) & should be (-150, -150)
|
let slash_length = mult(cell_size, sqrt(2))
|
||||||
right! (0.25)
|
let cols = 20
|
||||||
|
let rows = 4
|
||||||
|
|
||||||
let root_2 = 1.414213562
|
|
||||||
let cell_size = 15
|
|
||||||
let line_length = mult (root_2, cell_size)
|
|
||||||
|
|
||||||
fn upstroke! () -> {
|
penwidth!(3)
|
||||||
print! (:up)
|
|
||||||
penup! ()
|
fn forward_slash! () -> {
|
||||||
forward! (cell_size)
|
pd!()
|
||||||
left! (0.125)
|
rt!(0.125)
|
||||||
pendown! ()
|
fd!(slash_length)
|
||||||
back! (line_length)
|
pu!()
|
||||||
penup! ()
|
bk!(slash_length)
|
||||||
forward! (line_length)
|
lt!(0.125)
|
||||||
right! (0.125)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn downstroke! () -> {
|
fn back_slash! () -> {
|
||||||
print! (:down)
|
pu!()
|
||||||
pendown! ()
|
fd!(cell_size)
|
||||||
right! (0.125)
|
pd!()
|
||||||
forward! (line_length)
|
rt!(0.375)
|
||||||
left! (0.375)
|
fd!(slash_length)
|
||||||
penup! ()
|
pu!()
|
||||||
forward! (cell_size)
|
lt!(0.125)
|
||||||
right! (0.25)
|
bk!(cell_size)
|
||||||
|
lt!(0.25)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn up_or_down! () -> {
|
fn next_cell! () -> {
|
||||||
let rand = random ()
|
pu!()
|
||||||
if lt? (rand, 0.5)
|
rt!(0.25)
|
||||||
then upstroke! ()
|
fd!(cell_size)
|
||||||
else downstroke! ()
|
lt!(0.25)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn newline! () -> {
|
repeat rows {
|
||||||
penup! ()
|
repeat cols {
|
||||||
back! (mult (grid_size, cell_size))
|
if random([true, false])
|
||||||
right! (0.25)
|
then forward_slash!()
|
||||||
forward! (cell_size)
|
else back_slash!()
|
||||||
left! (0.25)
|
|
||||||
}
|
|
||||||
|
|
||||||
let grid_size = 20
|
next_cell!()
|
||||||
|
|
||||||
fn randcolor! () -> pencolor! ((random (0, 255), random (0, 255), random (0, 255)))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
repeat grid_size {
|
|
||||||
randcolor! ()
|
|
||||||
up_or_down! ()
|
|
||||||
}
|
}
|
||||||
|
lt!(0.25)
|
||||||
& repeat grid_size {
|
fd!(mult(cols, cell_size))
|
||||||
|
rt!(0.25)
|
||||||
& newline! ()
|
back!(cell_size)
|
||||||
& }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user