Permalink
Browse files

Initial commit

  • Loading branch information...
tj committed Aug 18, 2012
0 parents commit d13ebeb601da0e5e7d45933f5554fde56b6a5b8b
Showing with 69 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +1 −0 .npmignore
  3. +5 −0 History.md
  4. +11 −0 Makefile
  5. +21 −0 Readme.md
  6. +8 −0 component.json
  7. +18 −0 index.js
@@ -0,0 +1,5 @@
+node_modules
+test/*.js
+test/*.css
+components
+build
@@ -0,0 +1 @@
+test
@@ -0,0 +1,5 @@
+
+0.0.2 / 2012-07-05
+==================
+
+ * fix dialog.effect support
@@ -0,0 +1,11 @@
+
+build: index.js components
+ @component build
+
+components:
+ @component install
+
+clean:
+ rm -fr build components
+
+.PHONY: clean
@@ -0,0 +1,21 @@
+
+# Autoscale-canvas
+
+ Retina-enable an HTML canvas according to `devicePixelRatio`.
+
+## Installation
+
+```
+$ component install component/autoscale-canvas
+```
+
+## API
+
+```js
+var autoscale = require('autoscale-canvas');
+autoscale(document.querySelector('canvas'));
+```
+
+## License
+
+ MIT
@@ -0,0 +1,8 @@
+{
+ "name": "autoscale-canvas",
+ "description": "Retina-enable an HTML canvas",
+ "version": "0.0.1",
+ "keywords": ["canvas", "retina", "hd"],
+ "dependencies": {},
+ "scripts": ["index.js"]
+}
@@ -0,0 +1,18 @@
+
+/**
+ * Retina-enable the given `canvas`.
+ *
+ * @param {Canvas} canvas
+ * @return {Canvas}
+ * @api public
+ */
+
+module.exports = function(canvas){
+ canvas.style.width = canvas.width;
+ canvas.style.height = canvas.height;
+ canvas.width *= devicePixelRatio;
+ canvas.height *= devicePixelRatio;
+ var ctx = canvas.getContext('2d');
+ ctx.scale(2, 2);
+ return canvas;
+};

0 comments on commit d13ebeb

Please sign in to comment.