Skip to content

Instantly share code, notes, and snippets.

View baku89's full-sized avatar
🍡

Baku 麦 baku89

🍡
View GitHub Profile
(background "#C5F1E5")
(style (fill "#EABC7B")
(ellipse [0 0]
(vec2/size [120 80] 0.6667)))
(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)))
(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"
(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]
(defvar x -129.3333740234375)
(style (fill "skyblue")
(ngon [x (const -100)] 40 4))
(style (fill "crimson")
(circle [(clamp x 0 100) (const 0)] 40))
(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"
(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
(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"
(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))
(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}]