Skip to content

Instantly share code, notes, and snippets.

View nariakiiwatani's full-sized avatar

nariakiiwatani nariakiiwatani

View GitHub Profile
@nariakiiwatani
nariakiiwatani / splatoon2_20200710
Created July 10, 2020 16:03
スプラトゥーンリーグマッチをやりながら自分の声だけ音声認識した結果
幸運
-
それがばれない方がいいな
-
野良でやってて 重ねられた時の
-
キツネ
@nariakiiwatani
nariakiiwatani / set opacity by layer makers
Last active January 15, 2021 05:12
AfterEffects Expression Utils
// 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))
(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
(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)))))
(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}]
}
(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)
(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))
)
(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))
)
(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}]