Jump to content

Custom vex function with optional chramp input


ikoon

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.

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...