0.10.2
Initialize a WebGL target with effects.
(kamposConfig)
import { Kampos, effects} from 'kampos';
const target = document.querySelector('#canvas');
const hueSat = effects.hueSaturation();
const kampos = new Kampos({target, effects: [hueSat]});
Initializes a Kampos instance. This is called inside the constructor, but can be called again after effects have changed or after Kampos#destroy.
boolean
:
success whether initializing of the context and program were successful
Set the source config.
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap | kamposSource))
const media = document.querySelector('#video');
kampos.setSource(media);
Initialize a ticker instance for batching animation of multiple Kampos instances.
Type: Object
(HTMLCanvasElement)
(Array<effectConfig>)
(planeConfig)
(Ticker?)
(boolean?)
(function?)
: function to run before each draw call. If it returns
false
kampos#draw
will not be called.
(function?)
: function to run after each draw call.
(function?)
(function?)
(function?)
Type: Object
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap))
(number)
(number)
Type: Object
Type: Object
Type: Object
Type: Object
Type: Object
(string)
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap)?)
brightnessContrastEffect
:
brightnessContrast({brightness: 1.5, contrast: 0.8})
hueSaturationEffect
:
hueSaturation({hue: 45, saturation: 1.3})
(Object?)
Name | Description |
---|---|
params.mode (
(default 'normal' )
|
blend mode to use |
params.color Array<number>
(default [0,0,0,1] )
|
Initial color to use when blending to a solid color |
blendEffect
:
blend('colorBurn')
alphaMaskEffect
:
alphaMask()
duotoneEffect
:
duotone({dark: [0.2, 0.11, 0.33, 1], light: [0.88, 0.78, 0.43, 1]})
(string)
: stretch the last value to the edge. This is the default behavior.
(string)
: discard values beyond the edge of the media - leaving a transparent pixel.
(string)
: continue rendering values from opposite direction when reaching the edge.
displacementEffect
:
displacement({wrap: displacement.DISCARD, scale: {x: 0.5, y: -0.5}})
(object)
Name | Description |
---|---|
params.noise string
|
3D noise implementation to use. |
params.output string?
|
how to output the
turbulenceValue
variable. Use
turbulence.COLOR
or
turbulence.ALPHA
for outputting to color or alpha correspondingly. Defaults to
turbulence.COLOR
.
|
params.frequency {x: number, y: number}
(default {x:0.0,y:0.0} )
|
initial frequencies to use for x and y axes. |
params.octaves number
(default 1 )
|
initial number of octaves to use for turbulence noise generation. |
params.isFractal boolean
(default false )
|
initial number of octaves to use for turbulence noise generation. |
params.time number
(default 0 )
|
initial time for controlling initial noise value. |
turbulenceEffect
:
turbulence({noise: kampos.noise.simplex, output: turbulence.COLOR, octaves: 4, isFractal: true})
kaleidoscopeEffect
:
kaleidoscope({segments: 12})
Type: Object
effect.brightness = 1.5;
effect.contrast = 0.9;
effect.contrastDisabled = true;
Type: Object
effect.hue = 45;
effect.saturation = 0.8;
Type: Object
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap))
: to use as backdrop
(boolean)
const img = new Image();
img.src = 'picture.png';
effect.color = [0.3, 0.55, 0.8, 1.0];
effect.image = img;
Multiplies alpha
value with values read from mask
media source.
Type: Object
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap))
(boolean)
(boolean)
const img = new Image();
img.src = 'picture.png';
effect.mask = img;
effect.disabled = true;
Type: Object
(boolean)
effect.light = [1.0, 1.0, 0.8];
effect.dark = [0.2, 0.6, 0.33];
Type: Object
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap))
(boolean)
const img = new Image();
img.src = 'disp.jpg';
effect.map = img;
effect.scale = {x: 0.4};
Generates a turbulence/fractal noise value stored into turbulenceValue
.
Depends on a noise(vec3 P)
function to be declared and injected via the noise
param, for example, simply supplying the perlinNoiseEffect.
Type: Object
effect.frequency = {x: 0.0065};
effect.octaves = 4;
effect.isFractal = true;
Type: Object
effect.segments = 8;
effect.offset = 0.5;
fadeTransitionEffect
:
fadeTransition()
(Object?)
displacementTransitionEffect
:
displacementTransition()
(Object?)
Name | Description |
---|---|
params.low number
(default 0.0 )
|
initial lower edge of intersection step |
params.high number
(default 0.01 )
|
initial higher edge of intersection step |
params.color Array<number>
(default [0,0,0,0] )
|
color to transition to if not transitioning to media |
params.textureEnabled boolean
(default true )
|
whether to enable transition to texture instead of color |
dissolveTransitionEffect
:
dissolveTransition()
Type: Object
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap))
: media source to transition into
(number)
: number between 0.0 and 1.0
(boolean)
effect.to = document.querySelector('#video-to');
effect.progress = 0.5;
Type: Object
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap))
: media source to transition into
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap))
: displacement map to use
(number)
: number between 0.0 and 1.0
(boolean)
const img = new Image();
img.src = 'disp.jpg';
effect.map = img;
effect.to = document.querySelector('#video-to');
effect.sourceScale = {x: 0.4};
effect.toScale = {x: 0.8};
Type: Object
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap))
: media source to transition into
((ArrayBufferView | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap))
: dissolve map to use
(Array<number>)
: a solid color to transition to with alpha channel, Array of 4 number in range [0.0, 1.0]
(number)
: lower edge of intersection step, in range [0.0, 1.0]
(number)
: higher edge of intersection step, in range [0.0, 1.0]
(number)
: number in range [0.0, 1.0]
(boolean)
: whether to enable transitioning to texture instead of color
(boolean)
const img = new Image();
img.src = 'dissolve.jpg';
effect.map = img;
effect.to = document.querySelector('#video-to');
effect.progress = 0.5;
Implementation of a 3D classic Perlin noise. Exposes a noise(vec3 P)
function for use inside fragment shaders.
Cellular noise ("Worley noise") in 3D in GLSL. Exposes a noise(vec3 P)
function for use inside fragment shaders.
Implementation of a 3D Simplex noise. Exposes a noise(vec3 v)
function for use inside fragment shaders.
Type: Object