This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(background "#C5F1E5") | |
(style (fill "#EABC7B") | |
(ellipse [0 0] | |
(vec2/size [120 80] 0.6667))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(background "snow") | |
(style (stroke "#D6D6D6" 2 :dash [10 4 4 4]) | |
(def A (circle [0 0] 100)) | |
(def B (circle [65 35.3125] 100))) | |
(style (fill "crimson") | |
(for [pt (path/intersections A B)] | |
(circle pt 10))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn test | |
{:params | |
[{:label "Number" :type "number"} | |
{:label "Slider" :type "number" :ui "slider"} | |
{:label "Point" :type "vec2"} | |
{:label "Rect" :type "rect2d"} | |
{:label "Matrix" :type "mat2d"} | |
{:label "Color" :type "string" :ui "color"} | |
{:label "Text" :type "string"} | |
{:label "Select" :type "string" :ui "dropdown" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(style [(fill "#EFEFEF") (stroke "pink" 3)] | |
(def path (path/offset | |
10 | |
(path/unite | |
(circle [0 0] 100) | |
(rect [-150 -50 300 100]))))) | |
(defn vec2/clamp-by-path | |
[pos path] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar x -129.3333740234375) | |
(style (fill "skyblue") | |
(ngon [x (const -100)] 40 4)) | |
(style (fill "crimson") | |
(circle [(clamp x 0 100) (const 0)] 40)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn vec2/clamp | |
{:doc "Clamp `v` between two vec2's" | |
:params [{:label "v" :type "vec2"} | |
{:label "Min" :type "vec2"} | |
{:label "Max" :type "vec2"}] | |
:handles {:draw (fn [{:params [v vmin vmax]}] | |
[{:type "path" :class "dashed" | |
:guide true | |
:path (line vmin [(.x vmax) (.y vmin)])} | |
{:type "path" :class "dashed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(style (stroke "pink" 3) | |
(def path (path/unite | |
(circle [0 0] 100) | |
(rect [-150 -50 300 100])))) | |
(defn vec2/clamp-by-path | |
[pos path] | |
(if (path/inside? pos path) | |
pos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro centered-square | |
{:handles | |
{:draw (fn {:params [center width] :return path} | |
[{:type "path" :class "dashed" | |
:guide true :path path} | |
{:id :center | |
:type "translate" | |
:pos center} | |
{:id :width | |
:type "arrow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def dur 4) | |
(deftime time 0.5026750000251923 :duration dur) | |
(def t (/ time dur)) | |
(def n 5) | |
(defn sin2 [x] | |
(fit01 (cubic-bezier (abs (inc (* -2 (to-turn x)))) 0.40000000000000047 0 0 1) | |
-1 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn semicircle | |
{:handles | |
{:draw (fn [{:params [a b] | |
:return ret}] | |
[{:type "path" :guide true | |
:class "dashed" :path ret} | |
{:id 0 :type "point" :pos a} | |
{:id 1 :type "point" :pos b}]) | |
:drag (fn [{:params params | |
:id idx :pos p}] |