Published
Edited
May 10, 2022
Fork of WebGL Shader
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
shader({
width: 400,
height: 400,
iTime: true,
visibility,
inputs:{a: viewof amp, f:viewof frec}
})`

float Wave(float p, float amplitude, float frequence)
{
float y = amplitude*(abs(mod(p*frequence,2.0)-1.));
return y;
}

void mainImage(out vec4 fragColor,in vec2 fragCoord) {
vec2 st = fragCoord.xy/iResolution.xy;
st.x *= iResolution.x/iResolution.y;
st = st * 2.-1.;

float d = length(st);
d -= iTime;
float wave = Wave(d,a,f);

fragColor = vec4(vec3(wave),1.0);
}
`
Insert cell
Insert cell
viewof freq2 = Inputs.range([0, 10], {label: "Frequency"})
Insert cell
viewof amp2 = Inputs.range([0, 10], {label: "Amplitude", value:1.0})
Insert cell
canvas = shader({width:400, height: 400, iTime: true,uniforms: {f: "float", a:"float"}})`

float Wave(float p, float amplitude, float frequence)
{
float y = amplitude*(abs(mod(p*frequence,2.0)-1.));
return y;
}

void mainImage(out vec4 fragColor,in vec2 fragCoord) {
vec2 st = fragCoord.xy/iResolution.xy;
st.x *= iResolution.x/iResolution.y;
st = st * 2.-1.;

float d = length(st);
d -= iTime;
float wave = Wave(d,a,f);

fragColor = vec4(vec3(wave),1.0);
}
`
Insert cell
canvas.update({f: freq2,a:amp2})
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more