stretch-canvas
- Make a project with a fixed size canvas using absolute units.
stretch(canvas);
- It now works on any screen.
What does it do?
- Adapts to device resolution
- Fits to viewport preserving w:h ratio
- Absolute center
Getting started
npm install --save stretch-canvas
or place this script tag before your code
HTML
JS
const stretch = stretch; const canvas = document;const ctx = canvas; ; // this is where magic happens // draw like its an old fixed size canvasctx;
Docs
const stretch = stretch; // accepts an optional config object;
// function for converting coordinates to the position on the original canvas before stretch function was appliedconst unstretchCoordinates = unstretchCoordinates; canvas;