Published
Edited
Apr 27, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const canvas = this||html`<canvas width=${width} height=400></canvas>`;
yield canvas;
const gl = canvas.getContext('webgl');
const vertexShader = createShader(gl,gl.VERTEX_SHADER,vertexShaderRectCode.code);
const fragmentShader = createShader(gl,gl.FRAGMENT_SHADER,fragmentShaderRectCode.code);

// setup GLSL program
const program = createProgram(gl,vertexShader, fragmentShader);
// Create a buffer
var positionBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);

// Set Geometry
setRectGeometry(gl);
// Create color buffer
var colorBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER,colorBuffer);
// Set the colors
setColorsGrad(gl)
// Transforms
var translation = [r2.x, r2.y];
var angleInRadians = r2.angle;
var scale = [r2.scaleX, r2.scaleY];
drawSceneRectColor(gl, program,positionBuffer, translation, angleInRadians,scale, colorBuffer )

invalidation.then(d=>{
gl.deleteProgram(program);
gl.deleteShader(vertexShader);
gl.deleteShader(fragmentShader);
})

}
Insert cell
Insert cell
import {slider} from "@jashkenas/inputs"
Insert cell
import {inputsGroup} from "@bumbeishvili/utils"
Insert cell
import {requireScript} from "@bumbeishvili/fetcher"
Insert cell
webglUtils = requireScript('https://webglfundamentals.org/webgl/resources/webgl-utils.js')
Insert cell
m3 = requireScript('https://webglfundamentals.org/webgl/resources/m3.js')
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