@amaui/utils
Version:
9 lines (8 loc) • 304 B
JavaScript
const canvasCrop = (canvas, x, y, width, height) => {
const newCanvas = document.createElement('canvas');
newCanvas.width = width;
newCanvas.height = height;
newCanvas.getContext('2d').drawImage(canvas, x, y, width, height, 0, 0, width, height);
return newCanvas;
};
export default canvasCrop;