vpRamp(3)

πŸ“¦ version 1.0c7, in fedora 43, fedora 44

πŸ’– vpRamp(3) πŸ’–

okay bestie, pull up a chair, because this one is from the Library Functions Manual and it's genuinely so useful. it's called vpRamp and it's giving "i make ramps" energy. let's get into it 🫢


✨ NAME ✨

vpRamp β€” initialize an array with a piecewise-linear ramp

yes. that's the whole job. she fills your array with a ramp. iconic behavior honestly πŸ’…


🌸 SYNOPSIS 🌸

#include <volpack.h>

vpResult
vpRamp(array, stride, num_points, ramp_x, ramp_y)
    float *array;
    int stride;
    int num_points;
    int *ramp_x;
    float *ramp_y;

look at her. five arguments. no notes. 🌈


πŸŽ€ ARGUMENTS πŸŽ€

  • array β€” the output array, aka where the magic lands. this is what gets filled up. ✨
  • stride β€” how many bytes you hop from one array element to the next. your lil step size between elements.
  • num_points β€” how many entries are chillin' in the input arrays (ramp_x and ramp_y). count 'em.
  • ramp_x β€” input array holding the indices into array. these are your X coordinates.
  • ramp_y β€” input array holding the values that get stored into array. these are your Y coordinates.

πŸ¦‹ DESCRIPTION πŸ¦‹

so vpRamp is a utility routine β€” a lil helper bestie β€” for initializing linear arrays of floating-point numbers with piecewise-linear ramps. and yes, that sounds like a lot, but it's literally just drawing connect-the-dots. πŸ–οΈ

a ramp is defined by a set of (x, y) pairs. the X coordinates are integers that index entries in the array argument, and the Y coordinates are floating-point values that get stored into the array. and the elements in between two of the X values? those get linearly-interpolated Y values. so no gaps, no drama, just smooth vibes. πŸ“ˆβœ¨

⚠️ the values in ramp_x must be strictly increasing. no going backwards. no duplicates. she does not play about that.

the stride argument may be used to skip array elements, or to initialize arrays with a non-standard stride. if your output array is a simple linear array of type float, then the stride should be sizeof(float). periodt. πŸ’…

and bestie, this function is so useful for creating lookup tables used for opacity transfer functions (peep vpSetClassifierTable(3)) and shading functions (peep vpSetLookupShader(3)). iykyk πŸ‘‘


πŸ’€ ERRORS πŸ’€

the normal return value is VP_OK. but sometimes she's not okay, and here's the one error return value that's possible:

  • VPERROR_BAD_VALUE β€” this happens when the number of points is less than one, or the X values are not strictly increasing. 😭 so like… give her at least one point and keep those X's ascending, fr fr.

🌟 SEE ALSO 🌟


and that's the whole page, bestie!! go forth and ramp responsibly πŸ§šπŸ’œ

signed off from the VolPack library, page vpRamp(3) β€” mwah, slay, bye πŸ‘‘πŸ’–

πŸ“¦ where this page comes from