function"cubic-bezier" arguments: 1x,1y, 2x, 2y, t return value: y starting point: (0,0) first control point:(1x,1y) second control point:(2x,2y) ending point: (1,1) The y-coordinate of the intersection of the cubic Bezier curve determined by the above parameters and the line with x=t is assigned to the variable “cubic-bezier”. (t also parameter) usage: e.g. Projects requiring complex easing movements By calling the function while transitioning t from 0 to 1 (1 to 0), the return value will transition according to the function parameter settings(see the define"1roop" in sprite"draw") The mechanism is only explained in Japanese.
関数"cubic-bezier" 引数: 1x,1y, 2x, 2y, t 返り値: y 始点: (0,0) 1つ目の制御点:(1x,1y) 2つ目の制御点:(2x,2y) 終点: (1,1) 上記のパラメーターによって決定される三次ベジェ曲線と x=t である直線の交点のY座標が変数"cubic-bezier"に代入される。 (tもパラメーター) 用途/使い方: 複雑な緩和動作(滑らかな動き)を要するプロジェクト等 tを0から1へ(1から0へ)遷移させながら関数を呼び出すことで返り値が関数のパラメーター設定に従って遷移する。 (スプライト"draw"の定義"1roop"を参照) 仕組み: 三次ベジェ曲線を描画する際に (1-t)**3*P_0+3*(1-t)**2*t*P_1+3*(1-t)*t**2*P_2+t**3*P_3 という式 (tは時間と一致しない媒介変数(0≤t≤1), P_0は始点, P_1,P_2は制御点, P_3は終点) を使用して描画する。 P_*に各点のx座標を代入した式に於いてtを三次方程式の解を求める形で算出し、再び上記の式を使用してy座標を求める。 余談: 最初は三次方程式の解を求める方法を敬遠して二分法で求めようとしていましたが二分法で挫折してこの形になりました v1.0.0 25/05/09