2025 Plum Blossom
(define
title "2025-plum-blossom"
description "The flower of Wuhan"
coords1 [[286.373 101.725]
[286.002 468.477]
[-58.454 404.905]
[220.833 -173.231]] ~
(gen/2d min: -500 max: 500)
coords2 [[1.531 340.057]
[-120.674 -108.640]
[399.163 321.554]
[-127.347 163.723]] ~
(gen/2d min: -500 max: 500)
coords3 [[-334.990 61.234]
[231.617 -267.342]
[26.874 -325.802]
[-383.545 213.553]] ~
(gen/2d min: -500 max: 500)
col-fn-1 (col/build-procedural a: [0.518 0.495 0.619] ~ (gen/scalar)
b: [0.980 0.237 0.203] ~ (gen/scalar)
c: [0.730 0.338 0.560] ~ (gen/scalar)
d: [0.124 0.567 0.445] ~ (gen/scalar)
alpha: 0.08)
col-fn-2 (col/build-procedural a: [0.334 0.875 0.663] ~ (gen/scalar)
b: [0.401 0.013 0.646] ~ (gen/scalar)
c: [0.069 0.860 0.241] ~ (gen/scalar)
d: [0.940 0.123 0.942] ~ (gen/scalar)
alpha: 0.08))
(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)
tessellation line-segments)
(loop (d from: -20 to: 1020 inc: 20)
(bezier tessellation
line-width
coords: [[0 (wash-n x: 0 d seed vol)]
[w/3 (wash-n x: w/3 d seed vol)]
[(* w/3 2) (wash-n x: (* w/3 2) d seed vol)]
[canvas/width (wash-n x: canvas/width d seed vol)]]
colour)
(bezier tessellation
line-width
coords: [[(wash-n x: 0 d seed vol) 0]
[(wash-n x: h/3 d seed vol) h/3]
[(wash-n x: (* h/3 2) d seed vol) (* h/3 2)]
[(wash-n x: canvas/height d seed vol) canvas/height]]
colour)))
(fn (wash-n x: 0 d: 0 seed: 0 vol: 1)
(+ d (* vol (prng/perlin x y: d z: seed))))
(fn (interesting-circle position: [500 500]
colour: red
seed: 123
radius: 300)
(define
rng (prng/build min: 0 max: 1 seed: seed)
srng (prng/build min: -1 max: 1 seed: seed))
(on-matrix-stack
(translate vector: position)
(scale scalar: (/ radius 210))
(loop (i to: 8)
(on-matrix-stack
(define
outer-exterior (+ (* (rng.prng/value) 40) 170)
outer-interior (+ (* (rng.prng/value) 90) 80)
inner-exterior (+ (* (rng.prng/value) 50) 100)
inner-interior (+ (* (rng.prng/value) 100) 0))
(rotate angle: (* 360 (rng.prng/value)))
;; outer ring
(circle-slice tessellation: 80
position: [0 0]
colour: (col/lighten from: colour
value: (* 85 ~ (gen/int min: 20 max: 600) (srng.prng/value)))
angle-start: 0
angle-end: 320
width: outer-exterior
inner-width: outer-interior
height: outer-exterior
inner-height: outer-interior)
;; inner ring
(circle-slice tessellation: 50
position: [0 0]
colour: (col/lighten from: colour
value: (* 54 ~ (gen/int min: 10 max: 400) (srng.prng/value)))
angle-start: 0
angle-end: 320
width: inner-exterior
inner-width: inner-interior
height: inner-exterior
inner-height: inner-interior)))
;; centre fill
(circle-slice tessellation: 50
position: [0 0]
colour: (col/lighten from: colour
value: (* 66 ~ (gen/int min: 5 max: 200) (srng.prng/value)))
angle-start: 0
angle-end: 360
radius: 30)))
(fn (flowery)
(loop (t from: 0 upto: 1 inc: (/ 1 199))
(poly coords: [(interp/bezier t: t coords: coords1)
(interp/bezier t: t coords: coords2)
(interp/bezier t: t coords: coords3)]
colours: [(col/value from: col-fn-1 t: t)
(col/value from: col-fn-2 t: (- 1 t))
(col/value from: col-fn-1 t: t)])))
(fn (fg1)
(on-matrix-stack
(translate vector: [(/ canvas/width 2) 0])
(scale scalar: 1.587 ~ (gen/scalar min: 1.2 max: 1.7))
(rotate angle: 190 ~ (gen/int max: 360))
(repeat/rotate-mirrored fn: (address-of flowery)
copies: 8 ~ (gen/int min: 1 max: 10))))
(fn (bg2)
(define
seed-radius 6.520 ~ (gen/scalar min: 6 max: 8)
scale-factor 4
phi (/ (sqrt 5.428 ~ (gen/scalar min: 4 max: 6)) 8.036 ~ (gen/scalar min: 8 max: 10))
seeds 200
focalpoint (focal/build-point ~ (gen/select from: '(focal/build-point
focal/build-hline
focal/build-vline))
position: [430 ~ (gen/int max: canvas/width)
533 ~ (gen/int max: canvas/height)]
distance: 651 ~ (gen/int min: (/ canvas/width 2) max: canvas/width)))
(on-matrix-stack
(translate vector: [500 0])
(scale scalar: 20)
(loop (i from: 0 to: seeds) ;todo
(define
theta (/ (* (- seeds i) math/TAU) phi)
r (* scale-factor (sqrt (- seeds i)))
position [(* r (math/cos from: theta))
(* r (math/sin from: theta))]
colour (col/set-alpha from: (col/value from: col-fn-1 t: (focal/value from: focalpoint position: position))
value: 0.4))
;; don't render some of the offscreen circles
(if (> (get-y from: position) -10)
(interesting-circle position: position
radius: seed-radius
colour: colour
seed: (- seeds i))))))
(wash colour: (col/value from: col-fn-1 t: 0.1))
(bg2)
(fg1)