diff --git a/10print.ld b/10print.ld index 422ed58..bcc37fe 100644 --- a/10print.ld +++ b/10print.ld @@ -1,64 +1,49 @@ -penup! () -goto! (150, 150) & should be (-150, -150) -right! (0.25) +let cell_size = 10 +let slash_length = mult(cell_size, sqrt(2)) +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! () -> { - print! (:up) - penup! () - forward! (cell_size) - left! (0.125) - pendown! () - back! (line_length) - penup! () - forward! (line_length) - right! (0.125) +penwidth!(3) + +fn forward_slash! () -> { + pd!() + rt!(0.125) + fd!(slash_length) + pu!() + bk!(slash_length) + lt!(0.125) } -fn downstroke! () -> { - print! (:down) - pendown! () - right! (0.125) - forward! (line_length) - left! (0.375) - penup! () - forward! (cell_size) - right! (0.25) +fn back_slash! () -> { + pu!() + fd!(cell_size) + pd!() + rt!(0.375) + fd!(slash_length) + pu!() + lt!(0.125) + bk!(cell_size) + lt!(0.25) } -fn up_or_down! () -> { - let rand = random () - if lt? (rand, 0.5) - then upstroke! () - else downstroke! () +fn next_cell! () -> { + pu!() + rt!(0.25) + fd!(cell_size) + lt!(0.25) } -fn newline! () -> { - penup! () - back! (mult (grid_size, cell_size)) - right! (0.25) - forward! (cell_size) - left! (0.25) -} +repeat rows { + repeat cols { + if random([true, false]) + then forward_slash!() + else back_slash!() -let grid_size = 20 - -fn randcolor! () -> pencolor! ((random (0, 255), random (0, 255), random (0, 255))) - - - - repeat grid_size { - randcolor! () - up_or_down! () + next_cell!() } - -& repeat grid_size { - -& newline! () -& } - - - + lt!(0.25) + fd!(mult(cols, cell_size)) + rt!(0.25) + back!(cell_size) +}