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
幸運 | |
- | |
それがばれない方がいいな | |
- | |
野良でやってて 重ねられた時の | |
- | |
キツネ |
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
// demo: https://twitter.com/nariakiiwatani/status/1280689913202016256 | |
const fadeIn = 0.2, fadeOut = 0.4, | |
lerp = (x, x0, x1, y0, y1) => (y0 + (y1 - y0) * (x - x0) / (x1 - x0)), | |
off = 0, | |
on = 1, | |
calcAlpha = (time, from, to, fadeIn, fadeOut) => (clamp(Math.min(lerp(time, from, from+fadeIn, off, on), lerp(time, to-fadeOut, to, on, off)),off,on)); | |
([...Array(marker.numKeys).keys()] | |
.map(i=>marker.key(i+1)) | |
.reduce((acc, m) => acc+calcAlpha(time, m.time, m.time+m.duration, fadeIn, fadeOut), 0)) |
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 ccd-ik-root | |
{:inverse (fn [[target edge] [pos length angle out]] | |
(let [p0 pos | |
diffAngle (- (vec2/angle (vec2/- target p0)) (vec2/angle (vec2/- edge p0))) | |
newAngle (+ angle diffAngle) | |
p1 (vec2/+ p0 (vec2/dir newAngle length)) | |
] | |
[pos length newAngle {:p0 p0 :p1 p1}]))} | |
[pos length angle out] | |
(let [p0 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
(defn ccd-ik-root | |
{:inverse (fn [[target edge] [pos length angle]] | |
(let [p0 pos | |
diffAngle (- (vec2/angle (vec2/- target p0)) (vec2/angle (vec2/- edge p0))) | |
newAngle (+ angle diffAngle)] | |
[pos length newAngle]))} | |
[pos length angle] | |
(let [p0 pos | |
p1 (vec2/+ p0 (vec2/dir angle length))] | |
{:p0 p0 :p1 p1 :angle angle |
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 limb | |
{:params [{:label "p0" :type "vec2"} | |
{:label "p1" :type "vec2"} | |
& | |
{:label "children" :type "any"}] | |
:handles | |
{:draw (get (get (meta line) :handles) :draw) | |
:drag (fn [{:id id :pos p :prev-pos pp :params [p0 p1 & children]}] | |
(let [d (vec2/- p pp)] | |
(concat [(vec2/+ p0 d) (vec2/+ p1 d)] (repeat d (count children))))) |
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 fix-distance | |
[base desire distance] | |
(let [angle (vec2/angle (vec2/- desire base))] | |
(vec2/rotate base angle (vec2/+ base [distance 0])))) | |
(defn make-chain | |
{:params [{:label "src" :type "any"} | |
{:label "step" :type "number"} | |
{:overwrap "overwrap" :type "number" :default 0}] | |
} |
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
(import "https://raw.githubusercontent.com/nariakiiwatani/My-GLISP-Snippets/master/arcjoined.cljs") | |
(import "https://raw.githubusercontent.com/nariakiiwatani/My-GLISP-Snippets/master/ik-nodes.glisp") | |
:start-sketch | |
(style (stroke "salmon" 10) | |
(map (fn [[a b]] (let [ | |
center (vec2/scale (vec2/+ a b) 0.5) | |
sub (vec2/- b a) | |
angle (vec2/angle sub) |
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
(import "https://raw.githubusercontent.com/nariakiiwatani/My-GLISP-Snippets/master/arcjoined.cljs") | |
(import "https://raw.githubusercontent.com/nariakiiwatani/My-GLISP-Snippets/master/ik-nodes.glisp") | |
:start-sketch | |
(style (stroke "salmon" 10) | |
(map (fn [[a b c]] (circumarc a b c)) (make-chain (ik-nodes [0 0] [99.99999999999989 (deg -61.400063941137134)] [90.00000000000048 (deg -141.29935260314733)] [80.0000000000006 (deg 2.1000062471690617)] [59.999999999999766 (deg 101.42036011281115)] [50.0000000000001 (deg -7.03886215752964)] [29.999999999999776 (deg 170.16303252962462)]) 3 2)) | |
) |
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
(import "https://raw.githubusercontent.com/nariakiiwatani/My-GLISP-Snippets/master/arcjoined.cljs") | |
(import "https://raw.githubusercontent.com/nariakiiwatani/My-GLISP-Snippets/master/ik-nodes.glisp") | |
:start-sketch | |
(style (stroke "salmon" 10) | |
(map (fn [[a b c]] (circumarc a b c)) (make-chain (ik-nodes [0 0] [99.99999999999989 (deg -61.400063941137134)] [90.00000000000048 (deg -141.29935260314733)] [80.0000000000006 (deg 2.1000062471690617)] [59.999999999999766 (deg 101.42036011281115)] [50.0000000000001 (deg -7.03886215752964)] [29.999999999999776 (deg 170.16303252962462)]) 3 2)) | |
) |
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 fix-distance | |
[base desire distance] | |
(let [angle (vec2/angle (vec2/- desire base))] | |
(vec2/rotate base angle (vec2/+ base [distance 0])))) | |
(defn make-chain | |
{:params [{:label "src" :type "any"} | |
{:label "step" :type "number"} | |
{:overwrap "overwrap" :type "number" :default 0}] |