3. Janet Loader
The janet fbm functions are loaded with
monolith_janet_fbm
.
<<janet_loader>>=
/* not currently included in the janet header file */
JANET_API void janet_cfuns_prefix(JanetTable *env,
const char *regprefix,
const JanetReg *cfuns);
<<janfuncs>>
static const JanetReg cfuns[] = {
{"fbm", j_fbm,
"(monolith/fbm x y oct)\n\n"
"Computes fractional brownian motion, given a normalized xy "
"coordinate and an octave level."
}
};
void monolith_janet_fbm(JanetTable *env)
{
janet_cfuns_prefix(env, "monolith", cfuns);
}
<<janfuncs>>=
float monolith_fbm(float x, float y, int oct);
static Janet j_fbm(int32_t argc, Janet *argv)
{
float x, y;
int oct;
float amp;
janet_fixarity(argc, 3);
x = janet_unwrap_number(argv[0]);
y = janet_unwrap_number(argv[1]);
oct = janet_unwrap_integer(argv[2]);
amp = monolith_fbm(x, y, oct);
return janet_wrap_number(amp);
}
prev | home | next