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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more