Thanks for the replies so far. I'm still looking for an answer to my scale problem. I have attached some example code to explain a bit more the problem i have:
Code:
<html>
<head>
<script type="application/x-javascript">
var ctx;
var mapArrayX = [];
var mapArrayY = [];
function init()
{
ctx = document.getElementById('canvas').getContext('2d');
ctx.fillStyle = '#08f';
var i = 0;
for (i = 0; i < 1500; i++)
{
mapArrayX[i] = 50 + (Math.random() * 700);
mapArrayY[i] = 50 + (Math.random() * 700);
ctx.fillRect(mapArrayX[i],mapArrayY[i],3,3);
}
}
function scale()
{
var i = 0;
ctx.clearRect(0, 0, 750,750);
ctx.beginPath();
ctx.rect(250,200,100,50);
ctx.stroke();
ctx.scale(0.5,0.5);
ctx.closePath();
for (i = 0; i < 1500; i++)
ctx.fillRect(mapArrayX[i],mapArrayY[i],3,3);
}
</script>
</head>
<body onload="init();">
<table border=0>
<tr>
<td>
<canvas id="canvas" width="750" height="750"</canvas>
<button type="button" onClick="scale();">Scale</button>
</td>
</tr>
</table>
</body>
</html>
This will draw a canvas with some random dots on it. When pushing the scale button now the whole canvas is scaled. But what i would like to get is that it only scales a part (where the rectangle is now) instead of the whole canvas. Is this possible? or is the scale function bound to the whole canvas?
Bookmarks