Skip to content

Commit

Permalink
add test.html
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Aug 23, 2012
1 parent 21ac87c commit 8916115
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 8 additions & 6 deletions index.js
Expand Up @@ -8,12 +8,14 @@
*/

module.exports = function(canvas){
var ratio = window.devicePixelRatio || 1;
canvas.style.width = canvas.width;
canvas.style.height = canvas.height;
canvas.width *= ratio;
canvas.height *= ratio;
var ctx = canvas.getContext('2d');
ctx.scale(ratio, ratio);
var ratio = window.devicePixelRatio || 1;
if (1 != ratio) {
canvas.style.width = canvas.width;
canvas.style.height = canvas.height;
canvas.width *= ratio;
canvas.height *= ratio;
ctx.scale(ratio, ratio);
}
return canvas;
};
8 changes: 8 additions & 0 deletions test.html
@@ -0,0 +1,8 @@
<canvas width=200 height=200></canvas>
<script>
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');
ctx.strokeRect(0, 0, 200, 200);
ctx.font = '28px Helvetica';
ctx.fillText('[o_O]', 60, 100);
</script>

0 comments on commit 8916115

Please sign in to comment.