KSeExpr  4.0.4.0
Classes | Namespaces | Macros | Typedefs | Functions | Variables
ExprBuiltins.cpp File Reference
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <limits>
#include <algorithm>
#include <cfloat>
#include <random>
#include "ExprFunc.h"
#include "ExprNode.h"
#include "Vec.h"
#include "Curve.h"
#include "ExprBuiltins.h"
#include "Noise.h"
#include "Interpreter.h"

Go to the source code of this file.

Classes

class  KSeExpr::RandFuncX
 
struct  KSeExpr::RandFuncX::Data
 
struct  KSeExpr::VoronoiPointData
 
class  KSeExpr::CachedVoronoiFunc
 
struct  KSeExpr::CurveData< T >
 
class  KSeExpr::CurveFuncX
 
class  KSeExpr::CCurveFuncX
 
class  KSeExpr::GetVar
 
struct  KSeExpr::GetVar::Data
 
struct  KSeExpr::GetVar::Assign< d >
 
class  KSeExpr::PrintFuncX
 
struct  KSeExpr::PrintFuncX::Data
 
class  KSeExpr::SPrintFuncX
 
struct  KSeExpr::SPrintFuncX::StringData
 

Namespaces

 KSeExpr
 

Macros

#define _USE_MATH_DEFINES
 
#define FUNCADOC(name, func)   define3(name, ExprFunc(::func), func##_docstring)
 
#define FUNCDOC(func)   define3(#func, ExprFunc(::func), func##_docstring)
 
#define FUNCDOC(func)   define3(#func, ExprFunc(KSeExpr::func), func##_docstring)
 
#define FUNCNDOC(func, min, max)   define3(#func, ExprFunc(KSeExpr::func, min, max), func##_docstring)
 

Typedefs

using VoronoiFunc = Vec3d(VoronoiPointData &, int, const Vec3d *)
 

Functions

double KSeExpr::compress (double x, double lo, double hi)
 
double KSeExpr::expand (double x, double lo, double hi)
 
double KSeExpr::fit (double x, double a1, double b1, double a2, double b2)
 
double KSeExpr::gamma (double x, double g)
 
double KSeExpr::bias (double x, double b)
 
double KSeExpr::contrast (double x, double c)
 
double KSeExpr::boxstep (double x, double a)
 
double KSeExpr::linearstep (double x, double a, double b)
 
double KSeExpr::smoothstep (double x, double a, double b)
 
double KSeExpr::gaussstep (double x, double a, double b)
 
double KSeExpr::remap (double x, double source, double range, double falloff, double interp)
 
double KSeExpr::mix (double x, double y, double alpha)
 
Vec3d KSeExpr::hsiAdjust (const Vec3d &rgb, double h, double s, double i)
 
Vec3d KSeExpr::hsi (int n, const Vec3d *args)
 
Vec3d KSeExpr::midhsi (int n, const Vec3d *args)
 
Vec3d KSeExpr::rgbtohsl (const Vec3d &rgb)
 
static double KSeExpr::hslvalue (double x, double y, double H)
 
Vec3d KSeExpr::hsltorgb (const Vec3d &hsl)
 
static Vec3d KSeExpr::saturate (const Vec3d &Cin, double amt)
 
Vec3d KSeExpr::saturate (int n, const Vec3d *args)
 
double KSeExpr::hash (int n, double *args)
 
double KSeExpr::noise (int n, const Vec3d *args)
 
double KSeExpr::snoise (const Vec3d &p)
 
Vec3d KSeExpr::vnoise (const Vec3d &p)
 
Vec3d KSeExpr::cnoise (const Vec3d &p)
 
double KSeExpr::snoise4 (int, const Vec3d *args)
 
Vec3d KSeExpr::vnoise4 (int, const Vec3d *args)
 
Vec3d KSeExpr::cnoise4 (int n, const Vec3d *args)
 
double KSeExpr::turbulence (int n, const Vec3d *args)
 
Vec3d KSeExpr::vturbulence (int n, const Vec3d *args)
 
Vec3d KSeExpr::cturbulence (int n, const Vec3d *args)
 
double KSeExpr::fbm (int n, const Vec3d *args)
 
Vec3d KSeExpr::vfbm (int n, const Vec3d *args)
 
double KSeExpr::fbm4 (int n, const Vec3d *args)
 
Vec3d KSeExpr::vfbm4 (int n, const Vec3d *args)
 
Vec3d KSeExpr::cfbm (int n, const Vec3d *args)
 
Vec3d KSeExpr::cfbm4 (int n, const Vec3d *args)
 
double KSeExpr::cellnoise (const Vec3d &p)
 
Vec3d KSeExpr::ccellnoise (const Vec3d &p)
 
double KSeExpr::pnoise (const Vec3d &p, const Vec3d &period)
 
static Vec3d * KSeExpr::voronoi_points (VoronoiPointData &data, const Vec3d &cell, double jitter)
 
static void KSeExpr::voronoi_f1_3d (VoronoiPointData &data, const Vec3d &p, double jitter, double &f1, Vec3d &pos1)
 
static void KSeExpr::voronoi_f1f2_3d (VoronoiPointData &data, const Vec3d &p, double jitter, double &f1, Vec3d &pos1, double &f2, Vec3d &pos2)
 
Vec3d KSeExpr::voronoiFn (VoronoiPointData &data, int n, const Vec3d *args)
 
Vec3d KSeExpr::cvoronoiFn (VoronoiPointData &data, int n, const Vec3d *args)
 
Vec3d KSeExpr::pvoronoiFn (VoronoiPointData &data, int n, const Vec3d *args)
 
KSeExpr::CachedVoronoiFunc ExprFuncSimple KSeExpr::voronoi (voronoiFn)
 
 CachedVoronoiFunc (VoronoiFunc *vfunc) noexcept
 
ExprType prep (ExprFuncNode *node, bool, ExprVarEnvBuilder &envBuilder) const override
 
ExprFuncNode::Data * evalConstant (const ExprFuncNode *, ArgHandle) const override
 
void eval (ArgHandle args) override
 
KSeExpr::CachedVoronoiFunc ExprFuncSimple KSeExpr::cvoronoi (cvoronoiFn)
 
KSeExpr::CachedVoronoiFunc ExprFuncSimple KSeExpr::pvoronoi (pvoronoiFn)
 
double KSeExpr::dist (const Vec3d &a, const Vec3d &b)
 
double KSeExpr::length (const Vec3d &v)
 
double KSeExpr::hypot (double x, double y)
 
double KSeExpr::dot (const Vec3d &a, const Vec3d &b)
 
Vec3d KSeExpr::norm (const Vec3d &a)
 
Vec3d KSeExpr::cross (const Vec3d &a, const Vec3d &b)
 
double KSeExpr::angle (const Vec3d &a, const Vec3d &b)
 
Vec3d KSeExpr::ortho (const Vec3d &a, const Vec3d &b)
 
Vec3d KSeExpr::rotate (int n, const Vec3d *args)
 
Vec3d KSeExpr::up (const Vec3d &P, const Vec3d &upvec)
 
double KSeExpr::cycle (double index, double loRange, double hiRange)
 
double KSeExpr::pick (int n, double *params)
 
double KSeExpr::swatch (int n, double *params)
 
double KSeExpr::choose (int n, double *params)
 
double KSeExpr::wchoose (int n, double *params)
 
double KSeExpr::spline (int n, double *params)
 
void KSeExpr::defineBuiltins (ExprFunc::Define, ExprFunc::Define3 define3)
 

Variables

static const char * KSeExpr::fabs_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float abs(float x)\nabsolute value of x")
 
static const char * KSeExpr::deg_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float deg(float angle)\nradians to degrees")
 
static const char * KSeExpr::rad_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float rad(float angle)\ndegrees to radians")
 
static const char * KSeExpr::cosd_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float cosd(float angle)\ncosine in degrees")
 
static const char * KSeExpr::sind_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float sind(float angle)\nsine in degrees")
 
static const char * KSeExpr::tand_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float tand(float angle)\ntangent in degrees")
 
static const char * KSeExpr::acosd_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float acosd(float value)\narc cosine in degrees")
 
static const char * KSeExpr::asind_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float asind(float value)\narc sine in degrees")
 
static const char * KSeExpr::atand_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float atand(float value)\narc tangent in degrees")
 
static const char * KSeExpr::atan2d_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float atan2d(float y,float x)\narc tangent in degrees of y/x between -180 and 180")
 
static const char * KSeExpr::cos_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float cos(float angle)\ncosine in radians")
 
static const char * KSeExpr::sin_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float sin(float angle)\nsine in radians")
 
static const char * KSeExpr::tan_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float tan(float angle)\ntangent in radians")
 
static const char * KSeExpr::acos_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float acos(float value)\narc cosine in radians")
 
static const char * KSeExpr::asin_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float asin(float value)\narc sine in radians")
 
static const char * KSeExpr::atan_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float atan(float value)\narc tangent in radians")
 
static const char * KSeExpr::atan2_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float atan2(float y,float x)\narc tangent in radians of y/x between -PI and PI")
 
static const char * KSeExpr::cosh_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float cosh(float angle)\nhyperbolic cosine in radians")
 
static const char * KSeExpr::sinh_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float sinh(float angle)\nhyperbolic sine in radians")
 
static const char * KSeExpr::tanh_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float tanh(float angle)\nhyperbolic tangent in radians")
 
static const char * KSeExpr::acosh_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float acosh(float value)\nhyperbolic arc cosine in radians")
 
static const char * KSeExpr::asinh_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float asinh(float value)\nhyperbolic arc sine in radians")
 
static const char * KSeExpr::atanh_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float atanh(float value)\nhyperbolic arc tangent in radians")
 
static const char * KSeExpr::clamp_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float clamp(float x,float lo,float hi)\nconstrain x to range [lo,hi]")
 
static const char * KSeExpr::round_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float round(float x)\nnearest integer to x")
 
static const char * KSeExpr::max_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float max(float a,float b)\ngreater of a and b")
 
static const char * KSeExpr::min_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float min(float a,float b)\nlesser of a and b")
 
static const char * KSeExpr::trunc_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float trunc(float a)\nnearest integer towards zero")
 
static const char * KSeExpr::floor_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float floor(float a)\nnext lower integer")
 
static const char * KSeExpr::ceil_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float ceil(float a)\nnext higher integer")
 
static const char * KSeExpr::invert_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float invert(float a)\nDefined as 1-x")
 
static const char * KSeExpr::cbrt_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float cbrt(float x)\ncube root")
 
static const char * KSeExpr::sqrt_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float sqrt(float x)\nsquare root")
 
static const char * KSeExpr::exp_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float exp(float x)\nE raised to the x power")
 
static const char * KSeExpr::pow_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float pow(float x, float y)\nx to the y power, also available as ^")
 
static const char * KSeExpr::log_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float log(float x)\nNatural logarithm")
 
static const char * KSeExpr::log10_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float log10(float x)\nBase 10 logarithm")
 
static const char * KSeExpr::fmod_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float fmod(float x,float y)\nremainder of x/y (also available as % operator)")
 
static const char * KSeExpr::turbulence_docstring
 
static const char * KSeExpr::cturbulence_docstring
 
static const char * KSeExpr::vturbulence_docstring
 
static const char * KSeExpr::compress_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float compress(float x,float lo,float hi)\nRemaps x in [0,1] to [lo,hi]")
 
static const char * KSeExpr::expand_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float expand(float x,float lo,float hi)\nRemaps x in [lo,hi] to [0,1]")
 
static const char * KSeExpr::fit_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float fit(float x,float a1,float b1,float a2,float b2)\nLinearly remaps x in [a1,b1] to [a2,b2]")
 
static const char * KSeExpr::gamma_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float gamma(float x, float g)\nGamma correction of x with gamma factor g")
 
static const char * KSeExpr::bias_docstring
 
static const char * KSeExpr::contrast_docstring
 
static const char * KSeExpr::boxstep_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "float boxstep(float x,float a)\n if x < a then 0 otherwise 1")
 
static const char * KSeExpr::linearstep_docstring
 
static const char * KSeExpr::smoothstep_docstring
 
static const char * KSeExpr::gaussstep_docstring
 
static const char * KSeExpr::remap_docstring
 
static const char * KSeExpr::mix_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "mix(float a,float b,float alpha)\nBlend of a and b according to alpha.")
 
static const char * KSeExpr::hsi_docstring
 
static const char * KSeExpr::midhsi_docstring
 
static const char * KSeExpr::rgbtohsl_docstring
 
static const char * KSeExpr::hsltorgb_docstring
 
static const char * KSeExpr::saturate_docstring
 
KSeExpr::RandFuncX KSeExpr::rand
 
static const char * KSeExpr::rand_docstring
 
static const char * KSeExpr::hash_docstring
 
static const char * KSeExpr::noise_docstring
 
static const char * KSeExpr::snoise_docstring
 
static const char * KSeExpr::vnoise_docstring
 
static const char * KSeExpr::cnoise_docstring
 
static const char * KSeExpr::snoise4_docstring
 
static const char * KSeExpr::vnoise4_docstring
 
static const char * KSeExpr::cnoise4_docstring
 
static const char * KSeExpr::fbm_docstring
 
static const char * KSeExpr::vfbm_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "vector vfbm(vector vint octaves=6,float lacunarity=2,float gain=.5)")
 
static const char * KSeExpr::fbm4_docstring
 
static const char * KSeExpr::vfbm4_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "vector vfbm4(vector v,float time,int octaves=6,float lacunarity=2,float gain=.5)")
 
static const char * KSeExpr::cfbm_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "color cfbm(vector vint octaves=6,float lacunarity=2,float gain=.5)")
 
static const char * KSeExpr::cfbm4_docstring = QT_TRANSLATE_NOOP_UTF8("builtin", "color cfbm4(vector v,float time,int octaves=6,float lacunarity=2,float gain=.5)")
 
static const char * KSeExpr::cellnoise_docstring
 
static const char * KSeExpr::ccellnoise_docstring
 
static const char * KSeExpr::pnoise_docstring
 
static const char * KSeExpr::voronoi_docstring
 
static const char * KSeExpr::cvoronoi_docstring
 
static const char * KSeExpr::pvoronoi_docstring
 
VoronoiFunc_vfunc
 
static const char * KSeExpr::dist_docstring
 
static const char * KSeExpr::length_docstring
 
static const char * KSeExpr::hypot_docstring
 
static const char * KSeExpr::dot_docstring
 
static const char * KSeExpr::norm_docstring
 
static const char * KSeExpr::cross_docstring
 
static const char * KSeExpr::angle_docstring
 
static const char * KSeExpr::ortho_docstring
 
static const char * KSeExpr::rotate_docstring
 
static const char * KSeExpr::up_docstring
 
static const char * KSeExpr::cycle_docstring
 
static const char * KSeExpr::pick_docstring
 
static const char * KSeExpr::swatch_docstring
 
static const char * KSeExpr::choose_docstring
 
static const char * KSeExpr::wchoose_docstring
 
static const char * KSeExpr::spline_docstring
 
KSeExpr::CurveData KSeExpr::voronoi
 
KSeExpr::CurveFuncX KSeExpr::curve
 
static const char * KSeExpr::curve_docstring
 
KSeExpr::CCurveFuncX KSeExpr::ccurve
 
static const char * KSeExpr::ccurve_docstring
 
KSeExpr::GetVar KSeExpr::getVar
 
static const char * KSeExpr::getVar_docstring
 
KSeExpr::PrintFuncX KSeExpr::printf
 
static const char * KSeExpr::printf_docstring
 
KSeExpr::SPrintFuncX KSeExpr::sprintf
 
static const char * KSeExpr::sprintf_docstring
 

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

Definition at line 8 of file ExprBuiltins.cpp.

◆ FUNCADOC

#define FUNCADOC (   name,
  func 
)    define3(name, ExprFunc(::func), func##_docstring)

◆ FUNCDOC [1/2]

#define FUNCDOC (   func)    define3(#func, ExprFunc(::func), func##_docstring)

◆ FUNCDOC [2/2]

#define FUNCDOC (   func)    define3(#func, ExprFunc(KSeExpr::func), func##_docstring)

◆ FUNCNDOC

#define FUNCNDOC (   func,
  min,
  max 
)    define3(#func, ExprFunc(KSeExpr::func, min, max), func##_docstring)

Typedef Documentation

◆ VoronoiFunc

using VoronoiFunc = Vec3d(VoronoiPointData &, int, const Vec3d *)

Definition at line 1 of file ExprBuiltins.cpp.

Function Documentation

◆ CachedVoronoiFunc()

voronoi::CachedVoronoiFunc ( VoronoiFunc vfunc)
noexcept

Definition at line 2 of file ExprBuiltins.cpp.

◆ eval()

void voronoi::eval ( ArgHandle  args)
override

Definition at line 29 of file ExprBuiltins.cpp.

◆ evalConstant()

ExprFuncNode::Data* voronoi::evalConstant ( const ExprFuncNode *  ,
ArgHandle   
) const
override

Definition at line 24 of file ExprBuiltins.cpp.

◆ prep()

ExprType voronoi::prep ( ExprFuncNode *  node,
bool  ,
ExprVarEnvBuilder &  envBuilder 
) const
override

Definition at line 8 of file ExprBuiltins.cpp.

Variable Documentation

◆ _vfunc

VoronoiFunc* _vfunc
private

Definition at line 46 of file ExprBuiltins.cpp.