Skip to content

Instantly share code, notes, and snippets.

@andion
Created May 16, 2020 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andion/a0d077d12c49ecb46b3ae013eff6c59c to your computer and use it in GitHub Desktop.
Save andion/a0d077d12c49ecb46b3ae013eff6c59c to your computer and use it in GitHub Desktop.
// Get our canvas and image
const canvas = document.getElementById("canvas");
const image = document.getElementById("source");
const ctx = canvas.getContext("2d");
// Our new ratio and source image width/height
const transformedRatio = 3/4;
const {naturalWidth: originalWidth, naturalHeight: originalHeight} = image;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment