Permalink
Browse files

add test.html

  • Loading branch information...
1 parent 21ac87c commit 8916115533672436503f0c05a2664ed3f8f105e5 @tj tj committed Aug 23, 2012
Showing with 16 additions and 6 deletions.
  1. +8 −6 index.js
  2. +8 −0 test.html
View
@@ -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;
};
View
@@ -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.