14eh Chaotic Grid

(meta linear-colour-space: 1)

(define
  num-squares-to-render 15 ~ (gen/int min: 2 max: 20)
  gap-size 30 ~ (gen/int min: 5 max: 50)
  num-squares (+ 2 num-squares-to-render)
  num-gaps (+ num-squares 1)
  square-size (/ (- canvas/width (* gap-size num-gaps)) num-squares)
  base-colour (col/rgb r: 1.0 ~ (gen/scalar)
                       g: 0.0 ~ (gen/scalar)
                       b: 0.3 ~ (gen/scalar)
                       alpha: 1.0)
  background-colour (col/rgb r: 1.0 g: 1.0 b: 0.9))

(wash variation: 40
      line-width: 25
      line-segments: 5
      colour: background-colour)

(loop (y from: 1 to: (- num-squares 1))
  (loop (x from: 1 to: (- num-squares 1))
    (define
      x-pos (map-to-position at: x)
      y-pos (map-to-position at: y)
      distance-from-centre (math/distance
                            vec1: [500 ~ (gen/int min:0 max: canvas/width)
                                       800 ~ (gen/int min:0 max: canvas/height)]
                            vec2: [x-pos y-pos])
      volatility (math/clamp from: (/ (- (/ canvas/width 2)
                                          distance-from-centre)
                                      12 ~ (gen/int min:5 max: 50))
                             min: 0
                             max: 50))

    (stroked-bezier-rect position: [x-pos y-pos]
                         colour-volatility: 20 ~ (gen/int min: 2 max: 40)
                         volatility: volatility
                         seed: (+ x (* y num-squares))
                         width: square-size
                         height: square-size
                         colour: base-colour)))

(fn (map-to-position at: 0)
    (+ (* (+ gap-size square-size) at) (/ square-size 2) gap-size))

(fn (stroked-bezier-rect position: [0 0]
                         width: 10
                         height: 10
                         colour: (col/rgb r: 0.0 g: 1.0 b: 0.0 alpha: 0.5)
                         colour-volatility: 0
                         volatility: 0
                         overlap: 3
                         iterations: 10
                         seed: 343)
    (define
      [x y] position
      third-width (/ width 3)
      third-height (/ height 3)
      vol volatility

      start-x (- x (/ width 2))
      start-y (- y (/ height 2))

      h-delta (/ height iterations)
      h-strip-width (/ height iterations)
      half-h-strip-width (/ h-strip-width 2)

      v-delta (/ width iterations)
      v-strip-width (/ width iterations)
      half-v-strip-width (/ v-strip-width 2)

      rng (prng/build min: -1 max: 1 seed: seed)

      half-alpha (/ (col/alpha from: colour) 2)
      lab-colour (col/set-alpha from: (col/convert format: LAB from: colour)
                                value: half-alpha))

    ; horizontal strips
    (loop (i to: iterations)
      (define
        [rx1 ry1 rx2 ry2 rx3 ry3 rx4 ry4] (prng/values num: 8 from: rng)
        lightness (+ (col/e2 from: lab-colour)
                     (* colour-volatility (prng/value from: rng)))
        current-colour (col/set-e2 from: lab-colour value: lightness))
      (bezier tessellation: 10
              line-width: (+ overlap h-strip-width)
              coords: [[(+ (+ (* rx1 vol) start-x)
                           (* 0 third-width))
                        (+ (+ (* i h-delta) (* ry1 vol) start-y)
                           half-h-strip-width)]

                       [(+ (+ (* rx2 vol) start-x)
                           (* 1 third-width))
                        (+ (+ (* i h-delta) (* ry2 vol) start-y)
                           half-h-strip-width)]

                       [(+ (+ (* rx3 vol) start-x)
                           (* 2 third-width))
                        (+ (+ (* i h-delta) (* ry3 vol) start-y)
                           half-h-strip-width)]

                       [(+ (+ (* rx4 vol) start-x)
                           (* 3 third-width))
                        (+ (+ (* i h-delta) (* ry4 vol) start-y)
                           half-h-strip-width)]]
              colour: current-colour))
    ; vertical strips
    (loop (i to: iterations)
      (define
        [rx1 ry1 rx2 ry2 rx3 ry3 rx4 ry4] (prng/values num: 8 from: rng)
        lightness (+ (col/e2 from: lab-colour)
                     (* colour-volatility (prng/value from: rng)))
        current-colour (col/set-e2 from: lab-colour value: lightness))
      (bezier tessellation: 10
              line-width: (+ overlap v-strip-width)
              coords: [[(+ (+ (* i v-delta) (* rx1 vol) start-x)
                           half-v-strip-width)
                        (+ (+ (* ry1 vol) start-y)
                           (* 0 third-height))]

                       [(+ (+ (* i v-delta) (* rx2 vol) start-x)
                           half-v-strip-width)
                        (+ (+ (* ry2 vol) start-y)
                           (* 1 third-height))]

                       [(+ (+ (* i v-delta) (* rx3 vol) start-x)
                           half-v-strip-width)
                        (+ (+ (* ry3 vol) start-y)
                           (* 2 third-height))]

                       [(+ (+ (* i v-delta) (* rx4 vol) start-x)
                           half-v-strip-width)
                        (+ (+ (* ry4 vol) start-y)
                           (* 3 third-height))]]
              colour: current-colour)))

(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))))