Mercurial > hg > dmlib
view src/dmcurves.h @ 2208:90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
lib64util for handling external palette file options and add support for
specifying one of the "internal" palettes or external (.act) palette file to
gfxconv and 64vw.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 14 Jun 2019 05:01:12 +0300 |
parents | 67f5c9d60c72 |
children |
line wrap: on
line source
/* * DMLib * -- Curve and spline functions * Programmed and designed by Matti 'ccr' Hamalainen * (C) Copyright 2015 Tecnic Software productions (TNSP) */ #ifndef DMCURVES_H #define DMCURVES_H #include "dmlib.h" #include "dmvecmat.h" #ifdef __cplusplus extern "C" { #endif /* Generic parameter interpolation */ #define DMM_S_CURVE(t) ((t) * (t) * (3.0f - 2.0f * (t))) #define DMM_LERP(t, a, b) ((a) + (t) * ((b) - (a))) typedef struct { DMFloat start, end, nsteps; } DMLerpContext; void dmLerpInit(DMLerpContext *ctx, DMFloat start, DMFloat end, DMFloat nsteps); DMFloat dmCatmullRom(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3); static inline DMFloat dmLerpSCurve(DMLerpContext *ctx, const DMFloat step) { const DMFloat n = step / ctx->nsteps; const DMFloat v = DMM_S_CURVE(n); return DMM_LERP(v, ctx->start, ctx->end); } static inline DMFloat dmLerpSCurveClamp(DMLerpContext *ctx, const DMFloat step) { const DMFloat n = dmClamp10(step / ctx->nsteps); const DMFloat v = DMM_S_CURVE(n); return DMM_LERP(v, ctx->start, ctx->end); } static inline DMFloat dmLerp1(DMLerpContext *ctx, const DMFloat step) { const DMFloat v = step / ctx->nsteps; return DMM_LERP(v, ctx->start, ctx->end); } static inline DMFloat dmLerp1Clamp(DMLerpContext *ctx, const DMFloat step) { const DMFloat v = dmClamp10(step / ctx->nsteps); return DMM_LERP(v, ctx->start, ctx->end); } static inline DMFloat dmCatmullRomClamp(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3) { return dmCatmullRom(dmClamp10(t), p0, p1, p2, p3); } static inline int dmBSplineGetNPoints(const int npoints, const int slod) { return npoints * slod; } int dmBSplineGenerateAlloc(DMVector **dst, int *ndst, const DMVector *points, const int npoints, const int slod); int dmBSplineGenerateArray(DMVector *dst, const int ndst, const DMVector *points, const int npoints, const int slod); int dmBSplineGenerate(const DMVector *points, const int npoints, const int slod, int (*callback)(void *data, const int ndst, const int nc, float x, float y, float z), void *data, const int ndst); #ifdef __cplusplus } #endif #endif // DMCURVES_H