glre 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/dist/addons.cjs +2 -0
- package/dist/addons.cjs.map +1 -0
- package/dist/addons.d.ts +1287 -0
- package/dist/addons.js +2 -0
- package/dist/addons.js.map +1 -0
- package/dist/index.cjs +31 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +187 -323
- package/dist/index.js +31 -43
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +1 -48
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.ts +536 -10
- package/dist/native.js +1 -48
- package/dist/native.js.map +1 -1
- package/dist/node.cjs +69 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.ts +626 -0
- package/dist/node.js +69 -0
- package/dist/node.js.map +1 -0
- package/dist/react.cjs +1 -48
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +524 -4
- package/dist/react.js +1 -48
- package/dist/react.js.map +1 -1
- package/dist/solid.cjs +1 -48
- package/dist/solid.cjs.map +1 -1
- package/dist/solid.d.ts +524 -4
- package/dist/solid.js +1 -48
- package/dist/solid.js.map +1 -1
- package/package.json +64 -11
- package/src/addons/animation/easing/backIn.ts +10 -0
- package/src/addons/animation/easing/backInOut.ts +12 -0
- package/src/addons/animation/easing/backOut.ts +10 -0
- package/src/addons/animation/easing/bounceIn.ts +10 -0
- package/src/addons/animation/easing/bounceInOut.ts +13 -0
- package/src/addons/animation/easing/bounceOut.ts +30 -0
- package/src/addons/animation/easing/circularIn.ts +9 -0
- package/src/addons/animation/easing/circularInOut.ts +11 -0
- package/src/addons/animation/easing/circularOut.ts +9 -0
- package/src/addons/animation/easing/cubicIn.ts +9 -0
- package/src/addons/animation/easing/cubicInOut.ts +11 -0
- package/src/addons/animation/easing/cubicOut.ts +10 -0
- package/src/addons/animation/easing/elasticIn.ts +10 -0
- package/src/addons/animation/easing/elasticInOut.ts +21 -0
- package/src/addons/animation/easing/elasticOut.ts +12 -0
- package/src/addons/animation/easing/exponentialIn.ts +9 -0
- package/src/addons/animation/easing/exponentialInOut.ts +13 -0
- package/src/addons/animation/easing/exponentialOut.ts +9 -0
- package/src/addons/animation/easing/index.ts +33 -0
- package/src/addons/animation/easing/linearIn.ts +9 -0
- package/src/addons/animation/easing/linearInOut.ts +9 -0
- package/src/addons/animation/easing/linearOut.ts +9 -0
- package/src/addons/animation/easing/quadraticIn.ts +9 -0
- package/src/addons/animation/easing/quadraticInOut.ts +10 -0
- package/src/addons/animation/easing/quadraticOut.ts +9 -0
- package/src/addons/animation/easing/quarticIn.ts +9 -0
- package/src/addons/animation/easing/quarticInOut.ts +11 -0
- package/src/addons/animation/easing/quarticOut.ts +10 -0
- package/src/addons/animation/easing/quinticIn.ts +9 -0
- package/src/addons/animation/easing/quinticInOut.ts +11 -0
- package/src/addons/animation/easing/quinticOut.ts +9 -0
- package/src/addons/animation/easing/sineIn.ts +10 -0
- package/src/addons/animation/easing/sineInOut.ts +10 -0
- package/src/addons/animation/easing/sineOut.ts +10 -0
- package/src/addons/color/palette/macbeth.ts +42 -0
- package/src/addons/color/space/cmyk2rgb.ts +12 -0
- package/src/addons/color/space/gamma2linear.ts +19 -0
- package/src/addons/color/space/hsl2rgb.ts +20 -0
- package/src/addons/color/space/hsv2rgb.ts +18 -0
- package/src/addons/color/space/hue2rgb.ts +12 -0
- package/src/addons/color/space/index.ts +29 -0
- package/src/addons/color/space/lab2lch.ts +22 -0
- package/src/addons/color/space/lab2rgb.ts +19 -0
- package/src/addons/color/space/lab2xyz.ts +32 -0
- package/src/addons/color/space/lch2lab.ts +21 -0
- package/src/addons/color/space/lch2rgb.ts +22 -0
- package/src/addons/color/space/linear2gamma.ts +19 -0
- package/src/addons/color/space/oklab2rgb.ts +35 -0
- package/src/addons/color/space/rgb2cmyk.ts +13 -0
- package/src/addons/color/space/rgb2hcv.ts +29 -0
- package/src/addons/color/space/rgb2hsl.ts +23 -0
- package/src/addons/color/space/rgb2hsv.ts +36 -0
- package/src/addons/color/space/rgb2hue.ts +29 -0
- package/src/addons/color/space/rgb2lab.ts +19 -0
- package/src/addons/color/space/rgb2lch.ts +22 -0
- package/src/addons/color/space/rgb2oklab.ts +45 -0
- package/src/addons/color/space/rgb2srgb.ts +34 -0
- package/src/addons/color/space/rgb2xyz.ts +20 -0
- package/src/addons/color/space/rgb2yiq.ts +22 -0
- package/src/addons/color/space/rgb2yuv.ts +32 -0
- package/src/addons/color/space/srgb2rgb.ts +34 -0
- package/src/addons/color/space/xyz2lab.ts +27 -0
- package/src/addons/color/space/xyz2rgb.ts +30 -0
- package/src/addons/color/space/yiq2rgb.ts +22 -0
- package/src/addons/color/space/yuv2rgb.ts +32 -0
- package/src/addons/draw/arrows.ts +75 -0
- package/src/addons/draw/axis.ts +57 -0
- package/src/addons/draw/bridge.ts +81 -0
- package/src/addons/draw/char.ts +30 -0
- package/src/addons/draw/circle.ts +29 -0
- package/src/addons/draw/fill.ts +25 -0
- package/src/addons/draw/flip.ts +45 -0
- package/src/addons/draw/hex.ts +29 -0
- package/src/addons/draw/index.ts +13 -0
- package/src/addons/draw/line.ts +16 -0
- package/src/addons/draw/point.ts +30 -0
- package/src/addons/draw/rect.ts +52 -0
- package/src/addons/draw/stroke.ts +31 -0
- package/src/addons/draw/tri.ts +29 -0
- package/src/addons/generative/cnoise.ts +239 -0
- package/src/addons/generative/curl.ts +64 -0
- package/src/addons/generative/fbm.ts +69 -0
- package/src/addons/generative/gerstnerWave.ts +21 -0
- package/src/addons/generative/gnoise.ts +113 -0
- package/src/addons/generative/index.ts +15 -0
- package/src/addons/generative/noised.ts +139 -0
- package/src/addons/generative/pnoise.ts +249 -0
- package/src/addons/generative/psrdnoise.ts +277 -0
- package/src/addons/generative/random.ts +136 -0
- package/src/addons/generative/snoise.ts +199 -0
- package/src/addons/generative/srandom.ts +90 -0
- package/src/addons/generative/voronoi.ts +134 -0
- package/src/addons/generative/voronoise.ts +69 -0
- package/src/addons/generative/wavelet.ts +77 -0
- package/src/addons/generative/worley.ts +99 -0
- package/src/addons/geometry/aabb/aabb.ts +8 -0
- package/src/addons/geometry/aabb/centroid.ts +10 -0
- package/src/addons/geometry/aabb/contain.ts +19 -0
- package/src/addons/geometry/aabb/diagonal.ts +10 -0
- package/src/addons/geometry/aabb/expand.ts +16 -0
- package/src/addons/geometry/aabb/index.ts +7 -0
- package/src/addons/geometry/aabb/intersect.ts +20 -0
- package/src/addons/geometry/aabb/square.ts +17 -0
- package/src/addons/geometry/index.ts +2 -0
- package/src/addons/geometry/triangle/area.ts +10 -0
- package/src/addons/geometry/triangle/barycentric.ts +50 -0
- package/src/addons/geometry/triangle/centroid.ts +10 -0
- package/src/addons/geometry/triangle/closestPoint.ts +85 -0
- package/src/addons/geometry/triangle/contain.ts +19 -0
- package/src/addons/geometry/triangle/distanceSq.ts +38 -0
- package/src/addons/geometry/triangle/index.ts +10 -0
- package/src/addons/geometry/triangle/intersect.ts +49 -0
- package/src/addons/geometry/triangle/normal.ts +12 -0
- package/src/addons/geometry/triangle/signedDistance.ts +31 -0
- package/src/addons/geometry/triangle/triangle.ts +9 -0
- package/src/addons/index.ts +8 -0
- package/src/addons/lighting/ray.ts +8 -0
- package/src/addons/math/aafloor.ts +13 -0
- package/src/addons/math/aafract.ts +38 -0
- package/src/addons/math/aamirror.ts +12 -0
- package/src/addons/math/aastep.ts +14 -0
- package/src/addons/math/absi.ts +9 -0
- package/src/addons/math/adaptiveThreshold.ts +24 -0
- package/src/addons/math/bump.ts +20 -0
- package/src/addons/math/const.ts +19 -0
- package/src/addons/math/cubic.ts +101 -0
- package/src/addons/math/cubicMix.ts +49 -0
- package/src/addons/math/decimate.ts +12 -0
- package/src/addons/math/dist.ts +143 -0
- package/src/addons/math/fcos.ts +11 -0
- package/src/addons/math/frac.ts +9 -0
- package/src/addons/math/gain.ts +14 -0
- package/src/addons/math/gaussian.ts +14 -0
- package/src/addons/math/grad4.ts +19 -0
- package/src/addons/math/hammersley.ts +54 -0
- package/src/addons/math/highPass.ts +12 -0
- package/src/addons/math/index.ts +63 -0
- package/src/addons/math/inside.ts +68 -0
- package/src/addons/math/invCubic.ts +9 -0
- package/src/addons/math/invQuartic.ts +9 -0
- package/src/addons/math/inverse.ts +9 -0
- package/src/addons/math/lengthSq.ts +10 -0
- package/src/addons/math/map.ts +27 -0
- package/src/addons/math/mirror.ts +12 -0
- package/src/addons/math/mmax.ts +27 -0
- package/src/addons/math/mmin.ts +28 -0
- package/src/addons/math/mmix.ts +47 -0
- package/src/addons/math/mod2.ts +44 -0
- package/src/addons/math/mod289.ts +46 -0
- package/src/addons/math/modi.ts +15 -0
- package/src/addons/math/nyquist.ts +15 -0
- package/src/addons/math/pack.ts +15 -0
- package/src/addons/math/parabola.ts +12 -0
- package/src/addons/math/permute.ts +42 -0
- package/src/addons/math/pow2.ts +10 -0
- package/src/addons/math/pow3.ts +9 -0
- package/src/addons/math/pow5.ts +10 -0
- package/src/addons/math/pow7.ts +12 -0
- package/src/addons/math/powFast.ts +18 -0
- package/src/addons/math/quartic.ts +15 -0
- package/src/addons/math/quat/index.ts +14 -0
- package/src/addons/math/quat/quat2mat3.ts +28 -0
- package/src/addons/math/quat/quat2mat4.ts +16 -0
- package/src/addons/math/quat/quatAdd.ts +18 -0
- package/src/addons/math/quat/quatConj.ts +14 -0
- package/src/addons/math/quat/quatDiv.ts +18 -0
- package/src/addons/math/quat/quatIdentity.ts +9 -0
- package/src/addons/math/quat/quatInverse.ts +17 -0
- package/src/addons/math/quat/quatLength.ts +15 -0
- package/src/addons/math/quat/quatLengthSq.ts +14 -0
- package/src/addons/math/quat/quatLerp.ts +40 -0
- package/src/addons/math/quat/quatMul.ts +38 -0
- package/src/addons/math/quat/quatNeg.ts +14 -0
- package/src/addons/math/quat/quatNorm.ts +16 -0
- package/src/addons/math/quat/quatSub.ts +18 -0
- package/src/addons/math/quintic.ts +16 -0
- package/src/addons/math/rotate2d.ts +16 -0
- package/src/addons/math/rotate3d.ts +37 -0
- package/src/addons/math/rotate3dX.ts +20 -0
- package/src/addons/math/rotate3dY.ts +20 -0
- package/src/addons/math/rotate3dZ.ts +20 -0
- package/src/addons/math/rotate4d.ts +41 -0
- package/src/addons/math/rotate4dX.ts +21 -0
- package/src/addons/math/rotate4dY.ts +16 -0
- package/src/addons/math/rotate4dZ.ts +21 -0
- package/src/addons/math/saturateMediump.ts +11 -0
- package/src/addons/math/scale2d.ts +44 -0
- package/src/addons/math/scale3d.ts +17 -0
- package/src/addons/math/scale4d.ts +50 -0
- package/src/addons/math/smootherstep.ts +16 -0
- package/src/addons/math/taylorInvSqrt.ts +9 -0
- package/src/addons/math/toMat3.ts +14 -0
- package/src/addons/math/toMat4.ts +14 -0
- package/src/addons/math/translate4d.ts +31 -0
- package/src/addons/math/unpack.ts +88 -0
- package/src/addons/sdf/boxSDF.ts +24 -0
- package/src/addons/sdf/circleSDF.ts +20 -0
- package/src/addons/sdf/crossSDF.ts +17 -0
- package/src/addons/sdf/hexSDF.ts +18 -0
- package/src/addons/sdf/index.ts +7 -0
- package/src/addons/sdf/lineSDF.ts +33 -0
- package/src/addons/sdf/rectSDF.ts +46 -0
- package/src/addons/sdf/sphereSDF.ts +20 -0
- package/src/addons/sdf/triSDF.ts +14 -0
- package/src/addons/space/aspect.ts +14 -0
- package/src/addons/space/bracketing.ts +44 -0
- package/src/addons/space/brickTile.ts +44 -0
- package/src/addons/space/cart2polar.ts +20 -0
- package/src/addons/space/center.ts +32 -0
- package/src/addons/space/checkerTile.ts +41 -0
- package/src/addons/space/depth2viewZ.ts +43 -0
- package/src/addons/space/displace.ts +55 -0
- package/src/addons/space/equirect2xyz.ts +17 -0
- package/src/addons/space/eulerView.ts +19 -0
- package/src/addons/space/fisheye2xyz.ts +18 -0
- package/src/addons/space/flipY.ts +25 -0
- package/src/addons/space/hexTile.ts +18 -0
- package/src/addons/space/index.ts +38 -0
- package/src/addons/space/kaleidoscope.ts +48 -0
- package/src/addons/space/linearizeDepth.ts +17 -0
- package/src/addons/space/lookAt.ts +49 -0
- package/src/addons/space/lookAtView.ts +40 -0
- package/src/addons/space/mirrorTile.ts +73 -0
- package/src/addons/space/nearest.ts +13 -0
- package/src/addons/space/orthographic.ts +25 -0
- package/src/addons/space/parallaxMapping.ts +149 -0
- package/src/addons/space/perspective.ts +24 -0
- package/src/addons/space/polar2cart.ts +24 -0
- package/src/addons/space/ratio.ts +14 -0
- package/src/addons/space/rotate.ts +37 -0
- package/src/addons/space/rotateX.ts +54 -0
- package/src/addons/space/rotateY.ts +54 -0
- package/src/addons/space/rotateZ.ts +54 -0
- package/src/addons/space/scale.ts +13 -0
- package/src/addons/space/sprite.ts +16 -0
- package/src/addons/space/sqTile.ts +20 -0
- package/src/addons/space/tbn.ts +26 -0
- package/src/addons/space/translate.ts +12 -0
- package/src/addons/space/triTile.ts +32 -0
- package/src/addons/space/uncenter.ts +32 -0
- package/src/addons/space/unratio.ts +12 -0
- package/src/addons/space/viewZ2depth.ts +25 -0
- package/src/addons/space/windmillTile.ts +58 -0
- package/src/addons/space/xyz2equirect.ts +10 -0
- package/src/index.ts +10 -23
- package/src/node/build.ts +127 -0
- package/src/node/create.ts +76 -0
- package/src/node/index.ts +64 -49
- package/src/node/scope.ts +66 -62
- package/src/node/types.ts +221 -187
- package/src/node/utils/const.ts +74 -13
- package/src/node/utils/index.ts +19 -14
- package/src/node/utils/infer.ts +32 -34
- package/src/node/utils/parse.ts +48 -24
- package/src/node/utils/utils.ts +52 -29
- package/src/types.ts +11 -6
- package/src/utils/helpers.ts +56 -0
- package/src/utils/pipeline.ts +24 -8
- package/src/utils/program.ts +62 -38
- package/src/{webgl.ts → utils/webgl.ts} +46 -30
- package/src/{webgpu.ts → utils/webgpu.ts} +22 -17
- package/src/node/core.ts +0 -121
- package/src/node/node.ts +0 -65
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fn, X } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const cubicInOut = Fn(([t]: [X]): X => {
|
|
4
|
+
const early = t.mul(t).mul(t).mul(4)
|
|
5
|
+
const late = t.mul(2).sub(2).pow(3).div(2).add(1)
|
|
6
|
+
return (early as any).select(late, t.lessThan(0.5))
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'cubicInOut',
|
|
9
|
+
type: 'auto',
|
|
10
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
11
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fn, Float, sin, pow, float } from '../../../node'
|
|
2
|
+
import { HALF_PI } from '../../math/const'
|
|
3
|
+
|
|
4
|
+
export const elasticIn = Fn(([t]: [Float]): Float => {
|
|
5
|
+
return sin(t.mul(13).mul(HALF_PI)).mul(pow(float(2), t.sub(1).mul(10)))
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'elasticIn',
|
|
8
|
+
type: 'float',
|
|
9
|
+
inputs: [{ name: 't', type: 'float' }],
|
|
10
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Fn, Float, sin, pow, float } from '../../../node'
|
|
2
|
+
import { HALF_PI } from '../../math/const'
|
|
3
|
+
|
|
4
|
+
export const elasticInOut = Fn(([t]: [Float]): Float => {
|
|
5
|
+
const t2 = t.mul(2)
|
|
6
|
+
const t2minus1 = t2.sub(1)
|
|
7
|
+
return sin(HALF_PI.mul(13).mul(t2))
|
|
8
|
+
.mul(pow(float(2), t2minus1.mul(10)))
|
|
9
|
+
.div(2)
|
|
10
|
+
.select(
|
|
11
|
+
sin(HALF_PI.mul(-13).mul(t2minus1.add(1)))
|
|
12
|
+
.mul(pow(float(2), t2minus1.mul(-10)))
|
|
13
|
+
.div(2)
|
|
14
|
+
.add(1),
|
|
15
|
+
t.lessThan(0.5)
|
|
16
|
+
)
|
|
17
|
+
}).setLayout({
|
|
18
|
+
name: 'elasticInOut',
|
|
19
|
+
type: 'float',
|
|
20
|
+
inputs: [{ name: 't', type: 'float' }],
|
|
21
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fn, Float, sin, pow, float } from '../../../node'
|
|
2
|
+
import { HALF_PI } from '../../math/const'
|
|
3
|
+
|
|
4
|
+
export const elasticOut = Fn(([t]: [Float]): Float => {
|
|
5
|
+
return sin(float(-13).mul(t.add(1)).mul(HALF_PI))
|
|
6
|
+
.mul(pow(float(2), float(-10).mul(t)))
|
|
7
|
+
.add(1)
|
|
8
|
+
}).setLayout({
|
|
9
|
+
name: 'elasticOut',
|
|
10
|
+
type: 'float',
|
|
11
|
+
inputs: [{ name: 't', type: 'float' }],
|
|
12
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Fn, X } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const exponentialInOut = Fn(([t]: [X]): X => {
|
|
4
|
+
const isZeroOrOne = t.equal(0).or(t.equal(1))
|
|
5
|
+
const early = t.mul(20).sub(10).exp2().div(2)
|
|
6
|
+
const late = t.mul(-20).add(10).exp2().div(-2).add(1)
|
|
7
|
+
const result = (early as any).select(late, t.lessThan(0.5))
|
|
8
|
+
return (t as any).select(result, isZeroOrOne)
|
|
9
|
+
}).setLayout({
|
|
10
|
+
name: 'exponentialInOut',
|
|
11
|
+
type: 'auto',
|
|
12
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
13
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Fn, X } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const exponentialOut = Fn(([t]: [X]): X => {
|
|
4
|
+
return (t as any).select(t.mul(-10).exp2().negate().add(1), t.equal(1))
|
|
5
|
+
}).setLayout({
|
|
6
|
+
name: 'exponentialOut',
|
|
7
|
+
type: 'auto',
|
|
8
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
9
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export * from './backIn'
|
|
2
|
+
export * from './backInOut'
|
|
3
|
+
export * from './backOut'
|
|
4
|
+
export * from './bounceIn'
|
|
5
|
+
export * from './bounceInOut'
|
|
6
|
+
export * from './bounceOut'
|
|
7
|
+
export * from './circularIn'
|
|
8
|
+
export * from './circularInOut'
|
|
9
|
+
export * from './circularOut'
|
|
10
|
+
export * from './cubicIn'
|
|
11
|
+
export * from './cubicInOut'
|
|
12
|
+
export * from './cubicOut'
|
|
13
|
+
export * from './elasticIn'
|
|
14
|
+
export * from './elasticInOut'
|
|
15
|
+
export * from './elasticOut'
|
|
16
|
+
export * from './exponentialIn'
|
|
17
|
+
export * from './exponentialInOut'
|
|
18
|
+
export * from './exponentialOut'
|
|
19
|
+
export * from './linearIn'
|
|
20
|
+
export * from './linearInOut'
|
|
21
|
+
export * from './linearOut'
|
|
22
|
+
export * from './quadraticIn'
|
|
23
|
+
export * from './quadraticInOut'
|
|
24
|
+
export * from './quadraticOut'
|
|
25
|
+
export * from './quarticIn'
|
|
26
|
+
export * from './quarticInOut'
|
|
27
|
+
export * from './quarticOut'
|
|
28
|
+
export * from './quinticIn'
|
|
29
|
+
export * from './quinticInOut'
|
|
30
|
+
export * from './quinticOut'
|
|
31
|
+
export * from './sineIn'
|
|
32
|
+
export * from './sineInOut'
|
|
33
|
+
export * from './sineOut'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fn, X, select } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const quadraticInOut = Fn(([t]: [X]): X => {
|
|
4
|
+
const p = t.mul(t).mul(2)
|
|
5
|
+
return select(p, p.negate().add(t.mul(4)).sub(1), t.lessThan(0.5))
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'quadraticInOut',
|
|
8
|
+
type: 'auto',
|
|
9
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
10
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fn, X, select } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const quarticInOut = Fn(([t]: [X]): X => {
|
|
4
|
+
const early = t.pow(4).mul(8)
|
|
5
|
+
const late = t.sub(1).pow(4).mul(-8).add(1)
|
|
6
|
+
return select(early, late, t.lessThan(0.5))
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'quarticInOut',
|
|
9
|
+
type: 'auto',
|
|
10
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
11
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fn, X } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const quarticOut = Fn(([t]: [X]): X => {
|
|
4
|
+
const it = t.sub(1)
|
|
5
|
+
return it.mul(it).mul(it).mul(t.oneMinus()).add(1)
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'quarticOut',
|
|
8
|
+
type: 'auto',
|
|
9
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
10
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fn, X, select } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const quinticInOut = Fn(([t]: [X]): X => {
|
|
4
|
+
const early = t.pow(5).mul(16)
|
|
5
|
+
const late = t.mul(2).sub(2).pow(5).mul(-0.5).add(1)
|
|
6
|
+
return select(early, late, t.lessThan(0.5))
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'quinticInOut',
|
|
9
|
+
type: 'auto',
|
|
10
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
11
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fn, X, sin } from '../../../node'
|
|
2
|
+
import { HALF_PI } from '../../math/const'
|
|
3
|
+
|
|
4
|
+
export const sineIn = Fn(([t]: [X]): X => {
|
|
5
|
+
return sin(t.sub(1).mul(HALF_PI as any)).add(1)
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'sineIn',
|
|
8
|
+
type: 'auto',
|
|
9
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
10
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fn, X, cos } from '../../../node'
|
|
2
|
+
import { PI } from '../../math/const'
|
|
3
|
+
|
|
4
|
+
export const sineInOut = Fn(([t]: [X]): X => {
|
|
5
|
+
return cos(PI.mul(t)).sub(1).mul(-0.5)
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'sineInOut',
|
|
8
|
+
type: 'auto',
|
|
9
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
10
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fn, X, sin } from '../../../node'
|
|
2
|
+
import { HALF_PI } from '../../math/const'
|
|
3
|
+
|
|
4
|
+
export const sineOut = Fn(([t]: [X]): X => {
|
|
5
|
+
return sin(t.mul(HALF_PI as any))
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'sineOut',
|
|
8
|
+
type: 'auto',
|
|
9
|
+
inputs: [{ name: 't', type: 'auto' }],
|
|
10
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Fn, vec3, Int, Vec3, If, select } from '../../../node'
|
|
2
|
+
|
|
3
|
+
const colors = [
|
|
4
|
+
vec3(0.46017, 0.33059, 0.27477), // DARK_SKIN
|
|
5
|
+
vec3(0.769, 0.576, 0.506), // LIGHT_SKIN
|
|
6
|
+
vec3(0.356, 0.472, 0.609), // BLUE_SKY
|
|
7
|
+
vec3(0.357, 0.427, 0.247), // FOLIAGE
|
|
8
|
+
vec3(0.518, 0.506, 0.694), // BLUE_FLOWER
|
|
9
|
+
vec3(0.384, 0.749, 0.675), // BLUISH_GREEN
|
|
10
|
+
vec3(0.867, 0.487, 0.184), // ORANGE
|
|
11
|
+
vec3(0.290, 0.357, 0.671), // PURPLISH_BLUE
|
|
12
|
+
vec3(0.769, 0.333, 0.384), // MODERATE_RED
|
|
13
|
+
vec3(0.365, 0.231, 0.420), // PURPLE
|
|
14
|
+
vec3(0.624, 0.745, 0.227), // YELLOW_GREEN
|
|
15
|
+
vec3(0.894, 0.635, 0.160), // ORANGE_YELLOW
|
|
16
|
+
vec3(0.176, 0.247, 0.584), // BLUE
|
|
17
|
+
vec3(0.239, 0.588, 0.290), // GREEN
|
|
18
|
+
vec3(0.690, 0.224, 0.227), // RED
|
|
19
|
+
vec3(0.925, 0.784, 0.094), // YELLOW
|
|
20
|
+
vec3(0.749, 0.309, 0.598), // MAGENTA
|
|
21
|
+
vec3(0.000, 0.537, 0.659), // CYAN
|
|
22
|
+
vec3(0.956, 0.956, 0.945), // WHITE
|
|
23
|
+
vec3(0.789, 0.797, 0.797), // NEUTRAL_80
|
|
24
|
+
vec3(0.635, 0.643, 0.643), // NEUTRAL_65
|
|
25
|
+
vec3(0.475, 0.478, 0.478), // NEUTRAL_50
|
|
26
|
+
vec3(0.329, 0.333, 0.337), // NEUTRAL_35
|
|
27
|
+
vec3(0.200, 0.200, 0.204) // BLACK
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
export const macbeth = Fn(([index]: [Int]): Vec3 => {
|
|
31
|
+
let result = vec3(0)
|
|
32
|
+
for (let i = 0; i < colors.length; i++) {
|
|
33
|
+
result = select(result, colors[i], index.equal(i))
|
|
34
|
+
}
|
|
35
|
+
return result
|
|
36
|
+
}).setLayout({
|
|
37
|
+
name: 'macbeth',
|
|
38
|
+
type: 'vec3',
|
|
39
|
+
inputs: [
|
|
40
|
+
{ name: 'index', type: 'int' }
|
|
41
|
+
]
|
|
42
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fn, Vec4, Vec3, float, vec3 } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const cmyk2rgb = Fn(([cmyk]: [Vec4]): Vec3 => {
|
|
4
|
+
const invK = float(1).sub(cmyk.w).toVar()
|
|
5
|
+
return float(1)
|
|
6
|
+
.sub(vec3(1).min(cmyk.xyz.mul(invK).add(cmyk.w)))
|
|
7
|
+
.saturate()
|
|
8
|
+
}).setLayout({
|
|
9
|
+
name: 'cmyk2rgb',
|
|
10
|
+
type: 'vec3',
|
|
11
|
+
inputs: [{ name: 'cmyk', type: 'vec4' }],
|
|
12
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fn, Vec4, float, vec4, X } from '../../../node'
|
|
2
|
+
|
|
3
|
+
const GAMMA = float(2.2)
|
|
4
|
+
|
|
5
|
+
export const gamma2linear = Fn(([v]: [X]): X => {
|
|
6
|
+
return v.pow(GAMMA)
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'gamma2linear',
|
|
9
|
+
type: 'auto',
|
|
10
|
+
inputs: [{ name: 'v', type: 'auto' }],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const gamma2linearVec4 = Fn(([v]: [Vec4]): Vec4 => {
|
|
14
|
+
return vec4(gamma2linear(v.xyz), v.w)
|
|
15
|
+
}).setLayout({
|
|
16
|
+
name: 'gamma2linearVec4',
|
|
17
|
+
type: 'vec4',
|
|
18
|
+
inputs: [{ name: 'v', type: 'vec4' }],
|
|
19
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Fn, Vec3, Vec4, float, vec4 } from '../../../node'
|
|
2
|
+
import { hue2rgb } from './hue2rgb'
|
|
3
|
+
|
|
4
|
+
export const hsl2rgb = Fn(([hsl]: [Vec3]): Vec3 => {
|
|
5
|
+
const rgb = hue2rgb(hsl.x).toVar()
|
|
6
|
+
const C = float(1).sub(hsl.z.mul(2).sub(1).abs()).mul(hsl.y).toVar()
|
|
7
|
+
return rgb.sub(0.5).mul(C).add(hsl.z)
|
|
8
|
+
}).setLayout({
|
|
9
|
+
name: 'hsl2rgb',
|
|
10
|
+
type: 'vec3',
|
|
11
|
+
inputs: [{ name: 'hsl', type: 'vec3' }],
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export const hsl2rgbVec4 = Fn(([hsl]: [Vec4]): Vec4 => {
|
|
15
|
+
return vec4(hsl2rgb(hsl.xyz), hsl.w)
|
|
16
|
+
}).setLayout({
|
|
17
|
+
name: 'hsl2rgbVec4',
|
|
18
|
+
type: 'vec4',
|
|
19
|
+
inputs: [{ name: 'hsl', type: 'vec4' }],
|
|
20
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Fn, Vec3, Vec4, vec4 } from '../../../node'
|
|
2
|
+
import { hue2rgb } from './hue2rgb'
|
|
3
|
+
|
|
4
|
+
export const hsv2rgb = Fn(([hsv]: [Vec3]): Vec3 => {
|
|
5
|
+
return hue2rgb(hsv.x).sub(1).mul(hsv.y).add(1).mul(hsv.z)
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'hsv2rgb',
|
|
8
|
+
type: 'vec3',
|
|
9
|
+
inputs: [{ name: 'hsv', type: 'vec3' }],
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export const hsv2rgbVec4 = Fn(([hsv]: [Vec4]): Vec4 => {
|
|
13
|
+
return vec4(hsv2rgb(hsv.xyz), hsv.w)
|
|
14
|
+
}).setLayout({
|
|
15
|
+
name: 'hsv2rgbVec4',
|
|
16
|
+
type: 'vec4',
|
|
17
|
+
inputs: [{ name: 'hsv', type: 'vec4' }],
|
|
18
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fn, Float, Vec3, float, vec3 } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const hue2rgb = Fn(([hue]: [Float]): Vec3 => {
|
|
4
|
+
const R = hue.mul(6).sub(3).abs().sub(1).toVar()
|
|
5
|
+
const G = float(2).sub(hue.mul(6).sub(2).abs()).toVar()
|
|
6
|
+
const B = float(2).sub(hue.mul(6).sub(4).abs()).toVar()
|
|
7
|
+
return vec3(R, G, B).saturate()
|
|
8
|
+
}).setLayout({
|
|
9
|
+
name: 'hue2rgb',
|
|
10
|
+
type: 'vec3',
|
|
11
|
+
inputs: [{ name: 'hue', type: 'float' }],
|
|
12
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from './cmyk2rgb'
|
|
2
|
+
export * from './gamma2linear'
|
|
3
|
+
export * from './hsl2rgb'
|
|
4
|
+
export * from './hsv2rgb'
|
|
5
|
+
export * from './hue2rgb'
|
|
6
|
+
export * from './lab2lch'
|
|
7
|
+
export * from './lab2rgb'
|
|
8
|
+
export * from './lab2xyz'
|
|
9
|
+
export * from './lch2lab'
|
|
10
|
+
export * from './lch2rgb'
|
|
11
|
+
export * from './linear2gamma'
|
|
12
|
+
export * from './oklab2rgb'
|
|
13
|
+
export * from './rgb2cmyk'
|
|
14
|
+
export * from './rgb2hcv'
|
|
15
|
+
export * from './rgb2hsl'
|
|
16
|
+
export * from './rgb2hsv'
|
|
17
|
+
export * from './rgb2hue'
|
|
18
|
+
export * from './rgb2lab'
|
|
19
|
+
export * from './rgb2lch'
|
|
20
|
+
export * from './rgb2oklab'
|
|
21
|
+
export * from './rgb2srgb'
|
|
22
|
+
export * from './rgb2xyz'
|
|
23
|
+
export * from './rgb2yiq'
|
|
24
|
+
export * from './rgb2yuv'
|
|
25
|
+
export * from './srgb2rgb'
|
|
26
|
+
export * from './xyz2lab'
|
|
27
|
+
export * from './xyz2rgb'
|
|
28
|
+
export * from './yiq2rgb'
|
|
29
|
+
export * from './yuv2rgb'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Fn, atan2, sqrt, vec3, vec4, Vec3, Vec4 } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const lab2lch3 = Fn(([lab]: [Vec3]): Vec3 => {
|
|
4
|
+
const chroma = sqrt(lab.y.mul(lab.y).add(lab.z.mul(lab.z)))
|
|
5
|
+
const hue = atan2(lab.z, lab.y).mul(57.2957795131)
|
|
6
|
+
return vec3(lab.x, chroma, hue)
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'lab2lch3',
|
|
9
|
+
type: 'vec3',
|
|
10
|
+
inputs: [{ name: 'lab', type: 'vec3' }],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const lab2lch4 = Fn(([lab]: [Vec4]): Vec4 => {
|
|
14
|
+
const lch = lab2lch3(lab.xyz)
|
|
15
|
+
return vec4(lch, lab.w)
|
|
16
|
+
}).setLayout({
|
|
17
|
+
name: 'lab2lch4',
|
|
18
|
+
type: 'vec4',
|
|
19
|
+
inputs: [{ name: 'lab', type: 'vec4' }],
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export const lab2lch = lab2lch3
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fn, Vec3, Vec4, vec4 } from '../../../node'
|
|
2
|
+
import { lab2xyz } from './lab2xyz'
|
|
3
|
+
import { xyz2rgb } from './xyz2rgb'
|
|
4
|
+
|
|
5
|
+
export const lab2rgb = Fn(([lab]: [Vec3]): Vec3 => {
|
|
6
|
+
return xyz2rgb(lab2xyz(lab))
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'lab2rgb',
|
|
9
|
+
type: 'vec3',
|
|
10
|
+
inputs: [{ name: 'lab', type: 'vec3' }],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const lab2rgbVec4 = Fn(([lab]: [Vec4]): Vec4 => {
|
|
14
|
+
return vec4(lab2rgb(lab.xyz), lab.w)
|
|
15
|
+
}).setLayout({
|
|
16
|
+
name: 'lab2rgbVec4',
|
|
17
|
+
type: 'vec4',
|
|
18
|
+
inputs: [{ name: 'lab', type: 'vec4' }],
|
|
19
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Fn, Vec3, Vec4, float, select, vec3, vec4 } from '../../../node'
|
|
2
|
+
|
|
3
|
+
// CIE D65 white point (default)
|
|
4
|
+
const CIE_WHITE = vec3(0.95045592705, 1, 1.08905775076)
|
|
5
|
+
|
|
6
|
+
export const lab2xyz = Fn(([lab]: [Vec3]): Vec3 => {
|
|
7
|
+
const fy = lab.x.add(16).div(116).toVar()
|
|
8
|
+
const fx = lab.y.div(500).add(fy).toVar()
|
|
9
|
+
const fz = fy.sub(lab.z.div(200)).toVar()
|
|
10
|
+
|
|
11
|
+
const threshold = float(0.206897)
|
|
12
|
+
const delta = float(16).div(116)
|
|
13
|
+
const factor = float(7.787)
|
|
14
|
+
|
|
15
|
+
const convertX = select(fx.pow(3), fx.sub(delta).div(factor), fx.greaterThan(threshold))
|
|
16
|
+
const convertY = select(fy.pow(3), fy.sub(delta).div(factor), fy.greaterThan(threshold))
|
|
17
|
+
const convertZ = select(fz.pow(3), fz.sub(delta).div(factor), fz.greaterThan(threshold))
|
|
18
|
+
|
|
19
|
+
return CIE_WHITE.mul(100).mul(vec3(convertX, convertY, convertZ))
|
|
20
|
+
}).setLayout({
|
|
21
|
+
name: 'lab2xyz',
|
|
22
|
+
type: 'vec3',
|
|
23
|
+
inputs: [{ name: 'lab', type: 'vec3' }],
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
export const lab2xyzVec4 = Fn(([lab]: [Vec4]): Vec4 => {
|
|
27
|
+
return vec4(lab2xyz(lab.xyz), lab.w)
|
|
28
|
+
}).setLayout({
|
|
29
|
+
name: 'lab2xyzVec4',
|
|
30
|
+
type: 'vec4',
|
|
31
|
+
inputs: [{ name: 'lab', type: 'vec4' }],
|
|
32
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Fn, vec3, vec4, Vec3, Vec4 } from '../../../node'
|
|
2
|
+
|
|
3
|
+
export const lch2lab3 = Fn(([lch]: [Vec3]): Vec3 => {
|
|
4
|
+
const radians = lch.z.mul(0.01745329251)
|
|
5
|
+
return vec3(lch.x, lch.y.mul(radians.cos()), lch.y.mul(radians.sin()))
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'lch2lab3',
|
|
8
|
+
type: 'vec3',
|
|
9
|
+
inputs: [{ name: 'lch', type: 'vec3' }],
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export const lch2lab4 = Fn(([lch]: [Vec4]): Vec4 => {
|
|
13
|
+
const lab = lch2lab3(lch.xyz)
|
|
14
|
+
return vec4(lab, lch.w)
|
|
15
|
+
}).setLayout({
|
|
16
|
+
name: 'lch2lab4',
|
|
17
|
+
type: 'vec4',
|
|
18
|
+
inputs: [{ name: 'lch', type: 'vec4' }],
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export const lch2lab = lch2lab3
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Fn, Vec3, Vec4, vec4 } from '../../../node'
|
|
2
|
+
import { lch2lab } from './lch2lab'
|
|
3
|
+
import { lab2rgb } from './lab2rgb'
|
|
4
|
+
|
|
5
|
+
export const lch2rgb3 = Fn(([lch]: [Vec3]): Vec3 => {
|
|
6
|
+
return lab2rgb(lch2lab(lch))
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'lch2rgb3',
|
|
9
|
+
type: 'vec3',
|
|
10
|
+
inputs: [{ name: 'lch', type: 'vec3' }],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const lch2rgb4 = Fn(([lch]: [Vec4]): Vec4 => {
|
|
14
|
+
const rgb = lch2rgb3(lch.xyz)
|
|
15
|
+
return vec4(rgb, lch.w)
|
|
16
|
+
}).setLayout({
|
|
17
|
+
name: 'lch2rgb4',
|
|
18
|
+
type: 'vec4',
|
|
19
|
+
inputs: [{ name: 'lch', type: 'vec4' }],
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export const lch2rgb = lch2rgb3
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fn, Vec4, float, vec4, X } from '../../../node'
|
|
2
|
+
|
|
3
|
+
const INV_GAMMA = float(1).div(2.2)
|
|
4
|
+
|
|
5
|
+
export const linear2gamma = Fn(([v]: [X]): X => {
|
|
6
|
+
return v.pow(INV_GAMMA)
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'linear2gamma',
|
|
9
|
+
type: 'auto',
|
|
10
|
+
inputs: [{ name: 'v', type: 'auto' }],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const linear2gammaVec4 = Fn(([v]: [Vec4]): Vec4 => {
|
|
14
|
+
return vec4(linear2gamma(v.xyz), v.w)
|
|
15
|
+
}).setLayout({
|
|
16
|
+
name: 'linear2gammaVec4',
|
|
17
|
+
type: 'vec4',
|
|
18
|
+
inputs: [{ name: 'v', type: 'vec4' }],
|
|
19
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Fn, mat3, vec4, Vec3, Vec4 } from '../../../node'
|
|
2
|
+
|
|
3
|
+
const OKLAB2RGB_A = mat3(1, 1, 1, 0.3963377774, -0.1055613458, -0.0894841775, 0.2158037573, -0.0638541728, -1.291485548)
|
|
4
|
+
|
|
5
|
+
const OKLAB2RGB_B = mat3(
|
|
6
|
+
4.0767416621,
|
|
7
|
+
-1.2684380046,
|
|
8
|
+
-0.0041960863,
|
|
9
|
+
-3.3077115913,
|
|
10
|
+
2.6097574011,
|
|
11
|
+
-0.7034186147,
|
|
12
|
+
0.2309699292,
|
|
13
|
+
-0.3413193965,
|
|
14
|
+
1.707614701
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
export const oklab2rgb3 = Fn(([oklab]: [Vec3]): Vec3 => {
|
|
18
|
+
const lms = OKLAB2RGB_A.mul(oklab)
|
|
19
|
+
return OKLAB2RGB_B.mul(lms.mul(lms).mul(lms))
|
|
20
|
+
}).setLayout({
|
|
21
|
+
name: 'oklab2rgb3',
|
|
22
|
+
type: 'vec3',
|
|
23
|
+
inputs: [{ name: 'oklab', type: 'vec3' }],
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
export const oklab2rgb4 = Fn(([oklab]: [Vec4]): Vec4 => {
|
|
27
|
+
const rgb = oklab2rgb3(oklab.xyz)
|
|
28
|
+
return vec4(rgb, oklab.w)
|
|
29
|
+
}).setLayout({
|
|
30
|
+
name: 'oklab2rgb4',
|
|
31
|
+
type: 'vec4',
|
|
32
|
+
inputs: [{ name: 'oklab', type: 'vec4' }],
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export const oklab2rgb = oklab2rgb3
|