Public
Edited
May 17, 2023
1 star
Insert cell
Insert cell
playbackrate
Insert cell
videoControls(canvas)
Insert cell
html`<div class="element" id="el2">0</div>`
Insert cell
canvas = {
const ctx = DOM.context2d(160, 90);
ctx.font = '48px sans-serif';
ctx.textAlign = 'center';

const draw = t => {
ctx.fillStyle = `limegreen`;
ctx.fillRect(0, 0, 160, 90);
ctx.fillStyle = 'white';
ctx.fillText(Math.floor(t * 10), 80, 60);
};

return mediatize(ctx.canvas, {
duration: 10,
onstep: draw,
playbackRate: 1
// ontimeupdate: draw // try the difference with ontimeupdate
});

// example taken from the excellent: https://observablehq.com/@mourner/canvas-recorder
}
Insert cell
Insert cell
mutable playbackrate = 0
Insert cell
block = ({
start: function(event) {
console.log('start', event);
},

change: function(force, event) {
// event.preventDefault();
this.style.width = Pressure.map(force, 0, 1, 200, 300) + 'px';
this.innerHTML = force;
mutable playbackrate = force
console.log('change', force);
},

startDeepPress: function(event) {
console.log('start deep press', event);
this.style.backgroundColor = '#FF0040';
},

endDeepPress: function() {
console.log('end deep press');
this.style.backgroundColor = '#0080FF';
},

end: function() {
console.log('end');
mutable playbackrate = 0
this.style.width = '200px';
this.innerHTML = 0;
},

unsupported: function() {
console.log(this);
this.innerHTML = 'Your device / browser does not support this :(';
}
})
Insert cell
Pressure.set(document.querySelectorAll('#el2'), block);
Insert cell
Pressure = require("pressure/dist/pressure.js")
Insert cell
Insert cell
import {mediatize} from "@severo/timer-media"
Insert cell
import {videoControls} from "@severo/detached-video-controls"
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