summaryrefslogtreecommitdiff
path: root/fractiform.js
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-07-27 12:17:46 -0400
committerpommicket <pommicket@gmail.com>2023-07-27 12:17:46 -0400
commita45f81492924f420a2e7c231dc09deb8ccecf9d0 (patch)
tree70abd2a285aa9575daab524e7be875e9c61b2829 /fractiform.js
parent58caa01f453eaac73b1ff1eb5b5dbb509198059d (diff)
funcitons!!
Diffstat (limited to 'fractiform.js')
-rw-r--r--fractiform.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/fractiform.js b/fractiform.js
index 54278f5..14ae762 100644
--- a/fractiform.js
+++ b/fractiform.js
@@ -411,6 +411,57 @@ ${type} remap(${type} x, ${type} a1, ${type} b1, ${type} a2, ${type} b2) {
${type} smoothst(${type} t, ${type} t1, ${type} t2, ${type} out1, ${type} out2) {
return mix(out1, out2, smoothstep(t1, t2, t));
}
+`).join('\n'),
+ `
+//! .name: Arctangent
+//! .id: arctan2
+//! .category: math
+//! .description: The arctangent function (radians) with 2 parameters (set x = 1 for normal arctangent)
+//! y.id: y
+//! x.id: x
+//! x.default: 1
+
+` + ['float', 'vec2', 'vec3', 'vec4'].map((type) => `
+${type} arctan2(${type} y, ${type} x) {
+ return atan(y, x);
+}
+`).join('\n'),
+ `
+//! .name: Tangent
+//! .id: tan
+//! .category: math
+//! .description: The tangent function (radians)
+
+` + ['float', 'vec2', 'vec3', 'vec4'].map((type) => `
+${type} tang(${type} x) {
+ return tan(x);
+}
+`).join('\n'),
+ `
+//! .name: Arcsine
+//! .id: arcsin
+//! .category: math
+//! .description: The arcsine function (radians) — input will be clamped to [−1, 1]
+
+` + ['float', 'vec2', 'vec3', 'vec4'].map((type) => `
+${type} arcsin(${type} x) {
+ return asin(clamp(x, -1.0, 1.0));
+}
+`).join('\n'),
+ `
+//! .name: Sigmoid
+//! .id: sigmoid
+//! .category: curves
+//! .description: The sigmoid function — smoothly maps the interval (−∞, ∞) to (a, b)
+//! x.description: input value
+//! a.description: output value for very negative inputs
+//! b.description: output value for very positive inputs
+//! sharpness.description: scale factor for input value — higher = quicker transition from a to b
+
+` + ['float', 'vec2', 'vec3', 'vec4'].map((type) => `
+${type} sigmoid(${type} x, ${type} a, ${type} b, ${type} sharpness) {
+ return mix(a, b, 1.0 / (1.0 + exp(-sharpness * x)));
+}
`).join('\n')
];