2.0.2 • Published 6 years ago
stylus-canvas v2.0.2
stylus-canvas
This exposes the <stylus-canvas> web component, which allows for low-latency inking in browsers.
API
getContext(id: string, attrs: object)-- get a 2d or webgl contextsetLowLatency(enabled: boolean)-- toggle low-latency. When updating large portions of the canvas, as when panning, tearing might occur when low-latency is enabled.resizeevent -- fired when canvas has been resizedrotateevent -- fired when canvas has been rotated to fit the
Additional functions
glDrawWithBackPressure
import drawWithBackPressure from "@tbuckley89/stylus-canvas/drawWithBackPressure";
const ctx = document.querySelector("stylus-canvas").getContext("2d", {desynchronized: true});
function draw() {
drawWithBackPressure(ctx, () => {
// draw here
});
requestAnimationFrame(draw);
}
requestAnimationFrame(draw);