Skip to content

Instantly share code, notes, and snippets.

@zaidalyafeai
Created July 3, 2018 18:08
Show Gist options
  • Save zaidalyafeai/9d9fa8e91c78dc36f0ad067fc810e0c7 to your computer and use it in GitHub Desktop.
Save zaidalyafeai/9d9fa8e91c78dc36f0ad067fc810e0c7 to your computer and use it in GitHub Desktop.
//the minimum boudning box around the current drawing
const mbb = getMinBox()
//cacluate the dpi of the current window
const dpi = window.devicePixelRatio
//extract the image data
const imgData = canvas.contextContainer.getImageData(mbb.min.x * dpi, mbb.min.y * dpi,
(mbb.max.x - mbb.min.x) * dpi, (mbb.max.y - mbb.min.y) * dpi);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment