-
-
Save jrm2k6/5ca5c121360444372db4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<canvas id="myCanvas" width="1000" height="1000" style="border: 3px solid red;"> | |
</canvas> | |
<script> | |
var canvas = document.getElementById('myCanvas'); | |
var ok = 1; | |
try { | |
var ctx = canvas.getContext("2d"); | |
} catch (err) { | |
ok = 0; | |
} | |
if (ok == 1) { | |
// defining mask | |
ctx.fillStyle = 'red'; | |
ctx.fillRect(100, 100, 200, 300); | |
ctx.clip(); | |
base_image = new Image(); | |
base_image.src = 'jeremy_cropping.png'; | |
base_image.width = 50; | |
base_image.height = 50; | |
base_image.onload = function () { | |
ctx.drawImage(base_image, 0, 0, 50, 50); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment