Published
Edited
May 14, 2021
Importers
6 stars
Insert cell
Insert cell
import { shader } from "@mbostock/shader"
Insert cell
tex = ({ block: shader({ width: 640, height: 100, iTime: true }) })
Insert cell
// /* everything in this "TeX" code cell gets rendered as a shader! */
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
fragColor = vec4(vec2(fragCoord.xy / iResolution.xy), 0.0, 1.0);
}
Insert cell
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
fragColor = vec4(vec2(fragCoord.xy / iResolution.xy), 0.0, .5);
}
Insert cell
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
fragColor = vec4(vec2(fragCoord.xy / iResolution.xy), 0.0, .25);
}
Insert cell
const float size = 25.0;

mat2 rotate2d(float a) {
return mat2(cos(a), -sin(a), sin(a), cos(a));
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 p = (fragCoord.xy - iResolution.xy / 2.0) * rotate2d(iTime / 10.0);
float k = float(mod(p.x, size * 2.0) < size == mod(p.y, size * 2.0) < size);
fragColor = vec4(vec3(k), 1.0);
}
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