Exemple #1
0
int plugin_init_math(void)
{
    /* set some handy constants */
    SetVariableNumeric("Pi", M_PI);
    SetVariableNumeric("e", M_E);

    /* register some basic math functions */
    AddFunction("sqrt", 1, my_sqrt);
    AddFunction("exp", 1, my_exp);
    AddFunction("ln", 1, my_ln);
    AddFunction("log", 1, my_log);
    AddFunction("sin", 1, my_sin);
    AddFunction("cos", 1, my_cos);
    AddFunction("tan", 1, my_tan);

    /* min, max */
    AddFunction("min", 2, my_min);
    AddFunction("max", 2, my_max);

    /* floor, ceil */
    AddFunction("floor", 1, my_floor);
    AddFunction("ceil", 1, my_ceil);

    /* decode */
    AddFunction("decode", -1, my_decode);

    return 0;
}
Exemple #2
0
int scope_run(SuperScopePrivate *priv, ScopeRunnable runnable)
{

    RESULT result;

    SetVariableNumeric("n", priv->n);
    SetVariableNumeric("b", priv->b);
    SetVariableNumeric("x", priv->x);
    SetVariableNumeric("y", priv->y);
    SetVariableNumeric("i", priv->i);
    SetVariableNumeric("v", priv->v);
    SetVariableNumeric("w", priv->w);
    SetVariableNumeric("h", priv->h);
    SetVariableNumeric("red", priv->red);
    SetVariableNumeric("green", priv->green);
    SetVariableNumeric("blue", priv->blue);
    SetVariableNumeric("linesize", priv->linesize);
    SetVariableNumeric("skip", priv->skip);
    SetVariableNumeric("drawmode", priv->drawmode);
    SetVariableNumeric("t", priv->t);
    SetVariableNumeric("d", priv->d);

    switch(runnable) {
        case SCOPE_RUNNABLE_INIT:
		Eval(priv->init, &result);
	break;
	case SCOPE_RUNNABLE_BEAT:
		Eval(priv->beat, &result);
	break;
	case SCOPE_RUNNABLE_FRAME:
		Eval(priv->frame, &result);
	break;
	case SCOPE_RUNNABLE_POINT:
		Eval(priv->point, &result);
	break;
    }

    //(FindVariable("n"))->value = NULL;
    VARIABLE var;
    var.value = NULL;
    priv->n = R2N(FindVariable("n")->value);
    priv->b = R2N(FindVariable("b")->value);
    priv->x = R2N(FindVariable("x")->value);
    priv->y = R2N(FindVariable("y")->value);
    priv->i = R2N(FindVariable("i")->value);
    priv->v = R2N(FindVariable("v")->value);
    priv->w = R2N(FindVariable("w")->value);
    priv->h = R2N(FindVariable("h")->value);
    priv->red = R2N(FindVariable("red")->value);
    priv->green = R2N(FindVariable("green")->value);
    priv->blue = R2N(FindVariable("blue")->value);
    priv->linesize = R2N(FindVariable("linesize")->value);
    priv->skip = R2N(FindVariable("skip")->value);
    priv->drawmode = R2N(FindVariable("drawmode")->value);
    priv->t = R2N(FindVariable("t")->value);
    priv->d = R2N(FindVariable("d")->value);

    return 0;
}