Add contextual function precision.
This commit is contained in:
@@ -213,6 +213,8 @@ namespace Cryville.Crtr {
|
|||||||
_ctxops.Add(IdentifierManager.Shared.Request("ease_out"), new func_cubic_bezier_fixed(0f, 0f, 0.58f, 1f, () => ContextSelfValue));
|
_ctxops.Add(IdentifierManager.Shared.Request("ease_out"), new func_cubic_bezier_fixed(0f, 0f, 0.58f, 1f, () => ContextSelfValue));
|
||||||
_ctxops.Add(IdentifierManager.Shared.Request("ease_in_out"), new func_cubic_bezier_fixed(0.42f, 0f, 0.58f, 1f, () => ContextSelfValue));
|
_ctxops.Add(IdentifierManager.Shared.Request("ease_in_out"), new func_cubic_bezier_fixed(0.42f, 0f, 0.58f, 1f, () => ContextSelfValue));
|
||||||
|
|
||||||
|
_ctxops.Add(IdentifierManager.Shared.Request("precision"), new func_precision(() => ContextSelfValue));
|
||||||
|
|
||||||
_ctxops.Add(IdentifierManager.Shared.Request("interval"), new func_interval(() => ContextSelfValue));
|
_ctxops.Add(IdentifierManager.Shared.Request("interval"), new func_interval(() => ContextSelfValue));
|
||||||
_ctxops.Add(IdentifierManager.Shared.Request("circle"), new func_sphere(() => ContextSelfValue));
|
_ctxops.Add(IdentifierManager.Shared.Request("circle"), new func_sphere(() => ContextSelfValue));
|
||||||
_ctxops.Add(IdentifierManager.Shared.Request("sphere"), new func_sphere(() => ContextSelfValue));
|
_ctxops.Add(IdentifierManager.Shared.Request("sphere"), new func_sphere(() => ContextSelfValue));
|
||||||
@@ -643,6 +645,28 @@ namespace Cryville.Crtr {
|
|||||||
.SetNumber(CubicBezier.Evaluate(time, x1, y1, x2, y2, 1e-3f));
|
.SetNumber(CubicBezier.Evaluate(time, x1, y1, x2, y2, 1e-3f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class func_precision : PdtOperator {
|
||||||
|
readonly Func<PropSrc> _ctxcb;
|
||||||
|
public func_precision(Func<PropSrc> ctxcb) : base(2) {
|
||||||
|
_ctxcb = ctxcb;
|
||||||
|
}
|
||||||
|
protected override unsafe void Execute() {
|
||||||
|
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||||
|
float v, p;
|
||||||
|
switch (LoadedOperandCount) {
|
||||||
|
case 1:
|
||||||
|
v = oputil.AsNumber(_ctxcb());
|
||||||
|
p = GetOperand(0).AsNumber(); break;
|
||||||
|
case 2:
|
||||||
|
v = GetOperand(0).AsNumber();
|
||||||
|
p = GetOperand(1).AsNumber(); break;
|
||||||
|
default: throw new ArgumentException("Argument count not 1 or 2");
|
||||||
|
}
|
||||||
|
double pp = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(p))) + 1);
|
||||||
|
double dp = pp * Math.Round(p / pp, 7);
|
||||||
|
ret.SetNumber((float)(Math.Round((double)v / dp) * dp));
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Area Functions
|
#region Area Functions
|
||||||
class func_interval : PdtOperator {
|
class func_interval : PdtOperator {
|
||||||
|
|||||||
Reference in New Issue
Block a user