Created
June 24, 2012 16:30
-
-
Save yogesh061/2983915 to your computer and use it in GitHub Desktop.
Canvas resize drawing disappear issue?
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> | |
<head> | |
<title>Canvas</title> | |
<style type="text/css"> | |
#myCanvas{ | |
border:1px solid red; | |
} | |
</style> | |
</head> | |
<body> | |
<canvas id = "myCanvas" width = "500px" height = "500px"></canvas> | |
<button id = "btn1" onclick = "resizeCanvas()">Resize</button> | |
</body> | |
<script type="text/javascript"> | |
var canvasRef = document.getElementById('myCanvas'); | |
var ctx = canvasRef.getContext("2d"); | |
if (ctx) { | |
ctx.fillStyle = "rgb(200,0,0)"; | |
ctx.fillRect (10, 10, 55, 50); | |
}; | |
function resizeCanvas () { | |
canvasRef.width = 1000; | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment