Bezier Curves
What if you need something smoother than a line of straight segments?
Bezier curves? We got 'em
(bez-curve [[0 1] [-1.5 -0.5] [-0.5 -1.5] [0 0]] {:stroke (p-color 255 128 64), :stroke-weight 4})
Perhaps we can use this to make smoothly curved corners for a frame
Note : framed is a Layout that takes three arguments :
- a list of corner pieces (which it reflects appropriately),
- a list of edge pieces (which it rotates appropriately)
- and a single centre (NOT a list, just a single group which it fills the middle.)
(let [orange {:stroke (p-color 255 128 64), :stroke-weight 2} blue {:stroke (p-color 100 100 200), :stroke-weight 2}] (framed 9 (repeat (bez-curve [[0.9 -0.9] [-1.4 -0.9] [-0.9 -1.4] [-0.9 0.9]] orange)) (repeat [{:style orange, :points [[-0.9 -1] [-0.9 -1] [-0.9 1]]}]) (->> (drunk-line 10 0.1 blue) (clock-rotate 7))))
Framed can be used to generate various bordered patterns
(let [corner (stack (square {:fill (p-color 255 0 0 100)}) (poly 0 0 0.9 4 {:fill (p-color 240 100 240)})) edge (stack (square {:fill (p-color 0 0 255)}) (poly 0 0 0.5 8 {:fill (p-color 150 150 255)})) centre (poly 0 0 0.9 30 {:fill (p-color 150 255 140)})] (framed 7 (repeat corner) (repeat edge) centre))