161g Grid Flow

(meta linear-colour-space: 1)

(define
  ;; fade out any lines which are far away from the focal points
  interest (interp/build from: [0.2 1.5] to: [0 1] clamping: true))

;; call 'fun' for every point on a nXn grid on the canvas
(fn (grid n: 10 fun: 1)
    (define
      remap-x (interp/build from: [0 (- n 1)] to: [0 canvas/width])
      remap-y (interp/build from: [0 (- n 1)] to: [0 canvas/height]))
    (loop (y from: 0 to: n)
          (loop (x from: 0 to: n)
                (fn-call (fun position: [(interp/value from: remap-x t: x)
                                         (interp/value from: remap-y t: y)])))))

;; render the background grid
(define
  focal-bg-a (focal/build-point position: [587 ~ (gen/int min: 400 max: 600)
                                           323 ~ (gen/int min: 100 max: 400)]
                                distance: 820 ~ (gen/int min: 700 max: 1000)
                                falloff: linear)
  focal-bg-b (focal/build-point position: [545 ~ (gen/int min: 400 max: 600)
                                           830 ~ (gen/int min: 600 max: 900)]
                                distance: 730 ~ (gen/int min: 700 max: 1000)
                                falloff: linear)
  col-fn-bg (col/build-bezier a: (col/rgb r: 0.666 g: 0.618 b: 0.220 alpha: 0.510) ~ (gen/col)
                              b: (col/rgb r: 0.919 g: 0.641 b: 0.994 alpha: 0.307) ~ (gen/col)
                              c: (col/rgb r: 0.286 g: 0.472 b: 0.934 alpha: 0.476) ~ (gen/col)
                              d: (col/rgb r: 0.202 g: 0.294 b: 0.926 alpha: 0.428) ~ (gen/col)))

(fn (draw-element-bg position: [0 0])
    (define
      interest-a (focal/value from: focal-bg-a position: position)
      interest-b (focal/value from: focal-bg-b position: position)
      combined-interest (+ interest-a interest-b)
      alpha (interp/value from: interest t: combined-interest))
    (on-matrix-stack
      (translate vector: position)
      (rotate angle: (* combined-interest 348 ~ (gen/int min: 300 max: 400)))
      (circle position: [0 0]
              colour: (col/set-alpha from: (col/value from: col-fn-bg t: interest-a) value: alpha)
              width: 54 ~ (gen/int min: 30 max: 60)
              height: 467 ~ (gen/int min: 400 max: 500))))

(grid n: 33 ~ (gen/int min: 30 max: 40)
      fun: (address-of draw-element-bg))

;; render the foreground
(define
  focal-fg-a (focal/build-point position: [655 446] ~ (gen/int min: 0 max: 1000)
                                distance: 342 ~ (gen/int min: 0 max: 500)
                                falloff: linear)
  focal-fg-b (focal/build-point position: [889 337] ~ (gen/int min: 0 max: 1000)
                                distance: 574 ~ (gen/int min: 0 max: 600)
                                falloff: linear)
  col-fn-fg (col/build-bezier a: (col/rgb r: 0.648 g: 0.717 b: 0.807 alpha: 0.141) ~ (gen/col)
                              b: (col/rgb r: 0.857 g: 0.432 b: 0.853 alpha: 0.628) ~ (gen/col)
                              c: (col/rgb r: 0.890 g: 0.001 b: 0.561 alpha: 0.571) ~ (gen/col)
                              d: (col/rgb r: 0.912 g: 0.793 b: 0.294 alpha: 0.060) ~ (gen/col)))

(fn (draw-element-fg position: [0 0])
    (define
      interest-a (focal/value from: focal-fg-a position: position)
      interest-b (focal/value from: focal-fg-b position: position)
      combined-interest (+ interest-a interest-b)
      alpha (interp/value from: interest t: combined-interest))
    (on-matrix-stack
      (translate vector: position)
      (rotate angle: (* combined-interest 112 ~ (gen/int min: 1 max: 200)))
      (circle position: [0 0]
              colour: (col/set-alpha from: (col/value from: col-fn-fg t: interest-a) value: alpha)
              width: 21 ~ (gen/int min: 10 max: 30)
              height: 239 ~ (gen/int min: 100 max: 300))))

(grid n: 36 ~ (gen/int min: 30 max: 40)
      fun: (address-of draw-element-fg))