1648 Chalk Boxes

(meta linear-colour-space: 1)

(on-matrix-stack
  (scale scalar: 1.1)
  (rotate angle: 3)
  (wash colour: (col/rgb r: 0.567 g: 0.142 b: 0.461 alpha: 0.151) ~ (gen/col)))

(on-matrix-stack
  (scale scalar: 1.05)
  (tri-hsl alpha: 0.361 ~ (gen/scalar))
  (tri-lab alpha: 0.174 ~ (gen/scalar)))

(define
  ra (prng/build seed: 42
                 min: -8.272 ~ (gen/stray from: -8.272 by: 8)
                 max: 14.468 ~ (gen/stray from: 14.468 by: 6))
  sc 0.721 ~ (gen/scalar min: 0.3 max: 1.1)
  w 50 ~ (gen/int min: 20 max: 80)
  h 48 ~ (gen/int min: 20 max: 70))

(fn (left x: 0 y: 0 w: 0 h: 0 colour: red)
  (poly coords: [[(- x w) (+ y h h)]
                 [(+ x w) (+ y h)]
                 [(- x w) (+ y 0)]
                 [(+ x w) (- y h)]]
        colours: [colour colour colour colour]))

(fn (right x: 0 y: 0 w: 0 h: 0 colour: red)
  (poly coords: [[(+ x w) (+ y h h)]
                 [(- x w) (+ y h)]
                 [(+ x w) (+ y 0)]
                 [(- x w) (- y h)]]
        colours: [colour colour colour colour]))

(fn (left-side x: 0 y: 0 w: 0 h: 0 colour: red)
  (on-matrix-stack
    (translate vector: [x y])
    (rotate angle: (prng/value from: ra))
    (left x: 0 y: 0 w: w h: h colour: colour)
    (scale scalar: sc)
    (rotate angle: (prng/value from: ra))
    (left x: 0 y: 0 w: w h: h colour: colour)
    (scale scalar: sc)
    (rotate angle: (prng/value from: ra))
    (left x: 0 y: 0 w: w h: h colour: colour)
    (scale scalar: sc)
    (rotate angle: (prng/value from: ra))
    (left x: 0 y: 0 w: w h: h colour: colour)))

(fn (right-side x: 0 y: 0 w: 0 h: 0 colour: red)
  (on-matrix-stack
    (translate vector: [x y])
    (rotate angle: (prng/value from: ra))
    (right x: 0 y: 0 w: w h: h colour: colour)
    (scale scalar: sc)
    (rotate angle: (prng/value from: ra))
    (right x: 0 y: 0 w: w h: h colour: colour)
    (scale scalar: sc)
    (rotate angle: (prng/value from: ra))
    (right x: 0 y: 0 w: w h: h colour: colour)
    (scale scalar: sc)
    (rotate angle: (prng/value from: ra))
    (right x: 0 y: 0 w: w h: h colour: colour)))

(fn (tri-lab alpha: 1)
  (define
    y 400
    r (prng/build min: 0 max: 1 seed: 231)
    colour-scale 758 ~ (gen/int min: 700 max: 900)
    colour-offset (prng/build min: -1 max: 1)
    li (interp/build from: [0 1]
                     to: [89 ~ (gen/int min: 40 max: 120)
                             36 ~ (gen/int min: 0 max: 70)])
    rma (interp/build from: [0 canvas/width]
                      to: [15 ~ (gen/int min: -10 max: 30)
                              9 ~ (gen/int min: -10 max: 30)])
    rmb (interp/build from: [0 canvas/height]
                      to: [94 ~ (gen/int min: 60 max: 120)
                              32 ~ (gen/int min: 0 max: 60)]))

  (loop (y from: 0 upto: canvas/height inc: (* 2 h))
    (loop (x from: 0 to: canvas/width inc: (* 4 w))
       (define
         b (interp/value from: rmb t: (+ y (* (prng/value from: colour-offset) colour-scale)))
         col-1 (col/lab l: (interp/value from: li t: (prng/value from: r))
                        a: (interp/value from: rma t: (+ x (* (prng/value from: colour-offset) colour-scale)))
                        b: b
                        alpha: alpha)
         col-2 (col/lab l: (interp/value from: li t: (prng/value from: r))
                        a: (interp/value from: rma t: (+ x w (* (prng/value from: colour-offset) colour-scale)))
                        b: b
                        alpha: alpha))
       (left-side  x: x         y: y w: w h: h colour: col-1)
       (right-side x: (+ x w w) y: y w: w h: h colour: col-2))))

(fn (tri-hsl alpha: 1)
  (define
    colour-scale 504 ~ (gen/int min: 400 max: 600)
    colour-offset (prng/build min: -1 max: 1)
    fn-h (interp/build from: [0 canvas/width]
                       to: [311 ~ (gen/int min: 200 max: 360)
                                177 ~ (gen/int min: 100 max: 300)])
    fn-l (interp/build from: [0 canvas/height]
                       to: [0.284 ~ (gen/scalar min: 0.2 max: 0.4)
                                  0.904 ~ (gen/scalar min: 0.7 max: 1)]))

  (loop (y from: 0 upto: canvas/height inc: (* 2 h))
     (loop (x from: 0 to: canvas/width inc: (* 4 w))
       (define
         b  (interp/value from: fn-l t: (+ y (* (prng/value from: colour-offset) colour-scale)))
         col-1 (col/hsl h: (interp/value from: fn-h t: (+ x (* (prng/value from: colour-offset) colour-scale)))
                        s: 1 l: b alpha: alpha)
         col-2 (col/hsl h: (interp/value from: fn-h t: (+ x w (* (prng/value from: colour-offset) colour-scale)))
                        s: 1 l: b alpha: alpha))
       (left-side  x: x         y: y w: w h: h colour: col-1)
       (right-side x: (+ x w w) y: y w: w h: h colour: col-2))))


(fn (wash vol: 200
          line-width: 70
          line-segments: 5
          colour: (col/rgb r: 0.627 g: 0.627 b: 0.627 alpha: 0.4)
          seed: 272)
  (define
    w/3 (/ canvas/width 3)
    h/3 (/ canvas/height 3))
  (loop (d from: -20 to: 1020 inc: 20)
    (bezier tessellation: line-segments
            line-width: line-width
            coords: [[0            (wash-n x: 0            d: d seed: seed vol: vol)]
                     [w/3          (wash-n x: w/3          d: d seed: seed vol: vol)]
                     [(* w/3 2)    (wash-n x: (* w/3 2)    d: d seed: seed vol: vol)]
                     [canvas/width (wash-n x: canvas/width d: d seed: seed vol: vol)]]
            colour: colour)

    (bezier tessellation: line-segments
            line-width: line-width
            coords: [[(wash-n x: 0             d: d seed: seed vol: vol) 0]
                     [(wash-n x: h/3           d: d seed: seed vol: vol) h/3]
                     [(wash-n x: (* h/3 2)     d: d seed: seed vol: vol) (* h/3 2)]
                     [(wash-n x: canvas/height d: d seed: seed vol: vol) canvas/height]]
            colour: colour)))

(fn (wash-n x: 0 d: 0 seed: 0 vol: 1)
  (+ d (* vol (prng/perlin x: x y: d z: seed))))