Jump to content
ikoon

Custom vex function with optional chramp input

Recommended Posts

I would like to define custom vex function and use it in my wrangles.
It will just return interpolated 0-1 value, a fade in a time range.

My problem is, that I would like to define it in a duplicate way (and that I am too newbie to do it).

float fade(float actualtime, float fromtime, float endtime, string mode="linear")
float fade(float actualtime, float fromtime, float endtime, string mode="nameofchramp")

The mode="nameofchramp" ... I mean for example UI chramp name "my_bezier_ease_out".
Please, can the function read from "external UI" chramp? How should I define this duplicity in the custom .h/.vfl file?


I dont mind if I have to create the ramp manually.

Share this post


Link to post
Share on other sites

We can't define default parameters for non-context functions from VEX, but it is possible to workaround this too.

float fade(float actualtime, fromtime, endtime)
{
    return 444;
}
float fade(float actualtime, fromtime, endtime; string ramp)
{
    return chramp(ramp, .5);
}
float fade(float actualtime, fromtime, endtime; string ramp)
{
    if (ramp == "linear")
        return 444;
    return chramp(ramp, .5);
}
float fade(float actualtime, fromtime, endtime)
{
     return fade(actualtime, fromtime, endtime, "linear");
}

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×