Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

.gitignore

  • Loading branch information...
commit 591a0522bb43065a17c9f03c71aaca97daf36044 1 parent 5ee26a1
Damian Suarez authored
Showing with 1 addition and 9,523 deletions.
  1. +1 −1  .gitignore
  2. +0 −28 node_modules/.npm/.cache/canvas/0.4.0/package.json
  3. BIN  node_modules/.npm/.cache/canvas/0.4.0/package.tgz
  4. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._.DS_Store
  5. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._.gitignore
  6. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._History.md
  7. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._Readme.md
  8. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._package.json
  9. +0 −8 node_modules/.npm/.cache/canvas/0.4.0/package/.gitignore
  10. +0 −9 node_modules/.npm/.cache/canvas/0.4.0/package/.gitmodules
  11. +0 −6 node_modules/.npm/.cache/canvas/0.4.0/package/.npmignore
  12. +0 −122 node_modules/.npm/.cache/canvas/0.4.0/package/History.md
  13. +0 −21 node_modules/.npm/.cache/canvas/0.4.0/package/Makefile
  14. +0 −184 node_modules/.npm/.cache/canvas/0.4.0/package/Readme.md
  15. +0 −1  node_modules/.npm/.cache/canvas/0.4.0/package/index.js
  16. +0 −48 node_modules/.npm/.cache/canvas/0.4.0/package/install
  17. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/lib/._canvas.js
  18. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/lib/._pngstream.js
  19. +0 −146 node_modules/.npm/.cache/canvas/0.4.0/package/lib/canvas.js
  20. +0 −325 node_modules/.npm/.cache/canvas/0.4.0/package/lib/context2d.js
  21. +0 −28 node_modules/.npm/.cache/canvas/0.4.0/package/lib/image.js
  22. +0 −29 node_modules/.npm/.cache/canvas/0.4.0/package/lib/pixelarray.js
  23. +0 −63 node_modules/.npm/.cache/canvas/0.4.0/package/lib/pngstream.js
  24. +0 −11 node_modules/.npm/.cache/canvas/0.4.0/package/package.json
  25. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._Canvas.cc
  26. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._Canvas.h
  27. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._CanvasGradient.cc
  28. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._CanvasRenderingContext2d.cc
  29. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._Image.h
  30. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._ImageData.cc
  31. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._ImageData.h
  32. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._PixelArray.cc
  33. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._PixelArray.h
  34. BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._color.cc
  35. +0 −312 node_modules/.npm/.cache/canvas/0.4.0/package/src/Canvas.cc
  36. +0 −59 node_modules/.npm/.cache/canvas/0.4.0/package/src/Canvas.h
  37. +0 −122 node_modules/.npm/.cache/canvas/0.4.0/package/src/CanvasGradient.cc
  38. +0 −29 node_modules/.npm/.cache/canvas/0.4.0/package/src/CanvasGradient.h
  39. +0 −1,823 node_modules/.npm/.cache/canvas/0.4.0/package/src/CanvasRenderingContext2d.cc
  40. +0 −133 node_modules/.npm/.cache/canvas/0.4.0/package/src/CanvasRenderingContext2d.h
  41. +0 −348 node_modules/.npm/.cache/canvas/0.4.0/package/src/Image.cc
  42. +0 −64 node_modules/.npm/.cache/canvas/0.4.0/package/src/Image.h
  43. +0 −69 node_modules/.npm/.cache/canvas/0.4.0/package/src/ImageData.cc
  44. +0 −28 node_modules/.npm/.cache/canvas/0.4.0/package/src/ImageData.h
  45. +0 −149 node_modules/.npm/.cache/canvas/0.4.0/package/src/PixelArray.cc
  46. +0 −33 node_modules/.npm/.cache/canvas/0.4.0/package/src/PixelArray.h
  47. +0 −19 node_modules/.npm/.cache/canvas/0.4.0/package/src/Point.h
  48. +0 −24 node_modules/.npm/.cache/canvas/0.4.0/package/src/closure.h
  49. +0 −423 node_modules/.npm/.cache/canvas/0.4.0/package/src/color.cc
  50. +0 −39 node_modules/.npm/.cache/canvas/0.4.0/package/src/color.h
  51. +0 −25 node_modules/.npm/.cache/canvas/0.4.0/package/src/init.cc
  52. +0 −36 node_modules/.npm/.cache/canvas/0.4.0/package/wscript
  53. BIN  node_modules/.npm/canvas/0.4.0/package/._.DS_Store
  54. BIN  node_modules/.npm/canvas/0.4.0/package/._.gitignore
  55. BIN  node_modules/.npm/canvas/0.4.0/package/._History.md
  56. BIN  node_modules/.npm/canvas/0.4.0/package/._Readme.md
  57. BIN  node_modules/.npm/canvas/0.4.0/package/._package.json
  58. +0 −8 node_modules/.npm/canvas/0.4.0/package/.gitignore
  59. +0 −9 node_modules/.npm/canvas/0.4.0/package/.gitmodules
  60. +0 −6 node_modules/.npm/canvas/0.4.0/package/.npmignore
  61. +0 −122 node_modules/.npm/canvas/0.4.0/package/History.md
  62. +0 −21 node_modules/.npm/canvas/0.4.0/package/Makefile
  63. +0 −184 node_modules/.npm/canvas/0.4.0/package/Readme.md
  64. +0 −1  node_modules/.npm/canvas/0.4.0/package/index.js
  65. +0 −48 node_modules/.npm/canvas/0.4.0/package/install
  66. BIN  node_modules/.npm/canvas/0.4.0/package/lib/._canvas.js
  67. BIN  node_modules/.npm/canvas/0.4.0/package/lib/._pngstream.js
  68. +0 −146 node_modules/.npm/canvas/0.4.0/package/lib/canvas.js
  69. +0 −325 node_modules/.npm/canvas/0.4.0/package/lib/context2d.js
  70. +0 −28 node_modules/.npm/canvas/0.4.0/package/lib/image.js
  71. +0 −29 node_modules/.npm/canvas/0.4.0/package/lib/pixelarray.js
  72. +0 −63 node_modules/.npm/canvas/0.4.0/package/lib/pngstream.js
  73. +0 −11 node_modules/.npm/canvas/0.4.0/package/package.json
  74. BIN  node_modules/.npm/canvas/0.4.0/package/src/._Canvas.cc
  75. BIN  node_modules/.npm/canvas/0.4.0/package/src/._Canvas.h
  76. BIN  node_modules/.npm/canvas/0.4.0/package/src/._CanvasGradient.cc
  77. BIN  node_modules/.npm/canvas/0.4.0/package/src/._CanvasRenderingContext2d.cc
  78. BIN  node_modules/.npm/canvas/0.4.0/package/src/._Image.h
  79. BIN  node_modules/.npm/canvas/0.4.0/package/src/._ImageData.cc
  80. BIN  node_modules/.npm/canvas/0.4.0/package/src/._ImageData.h
  81. BIN  node_modules/.npm/canvas/0.4.0/package/src/._PixelArray.cc
  82. BIN  node_modules/.npm/canvas/0.4.0/package/src/._PixelArray.h
  83. BIN  node_modules/.npm/canvas/0.4.0/package/src/._color.cc
  84. +0 −312 node_modules/.npm/canvas/0.4.0/package/src/Canvas.cc
  85. +0 −59 node_modules/.npm/canvas/0.4.0/package/src/Canvas.h
  86. +0 −122 node_modules/.npm/canvas/0.4.0/package/src/CanvasGradient.cc
  87. +0 −29 node_modules/.npm/canvas/0.4.0/package/src/CanvasGradient.h
  88. +0 −1,823 node_modules/.npm/canvas/0.4.0/package/src/CanvasRenderingContext2d.cc
  89. +0 −133 node_modules/.npm/canvas/0.4.0/package/src/CanvasRenderingContext2d.h
  90. +0 −348 node_modules/.npm/canvas/0.4.0/package/src/Image.cc
  91. +0 −64 node_modules/.npm/canvas/0.4.0/package/src/Image.h
  92. +0 −69 node_modules/.npm/canvas/0.4.0/package/src/ImageData.cc
  93. +0 −28 node_modules/.npm/canvas/0.4.0/package/src/ImageData.h
  94. +0 −149 node_modules/.npm/canvas/0.4.0/package/src/PixelArray.cc
  95. +0 −33 node_modules/.npm/canvas/0.4.0/package/src/PixelArray.h
  96. +0 −19 node_modules/.npm/canvas/0.4.0/package/src/Point.h
  97. +0 −24 node_modules/.npm/canvas/0.4.0/package/src/closure.h
  98. +0 −423 node_modules/.npm/canvas/0.4.0/package/src/color.cc
  99. +0 −39 node_modules/.npm/canvas/0.4.0/package/src/color.h
  100. +0 −25 node_modules/.npm/canvas/0.4.0/package/src/init.cc
  101. +0 −36 node_modules/.npm/canvas/0.4.0/package/wscript
  102. +0 −1  node_modules/.npm/canvas/active
  103. +0 −1  node_modules/canvas
  104. +0 −20 node_modules/canvas@0.4.0/index.js
View
2  .gitignore
@@ -1 +1 @@
-/node_modules
+node_modules/*
View
28 node_modules/.npm/.cache/canvas/0.4.0/package.json
@@ -1,28 +0,0 @@
-{
- "name": "canvas",
- "description": "Canvas graphics API backed by Cairo",
- "version": "0.4.0",
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@learnboost.com"
- },
- "keywords": [
- "canvas",
- "graphic",
- "graphics"
- ],
- "scripts": {
- "preinstall": "node-waf configure build"
- },
- "engines": {
- "node": ">= 0.2.3"
- },
- "main": "./lib/canvas",
- "_id": "canvas@0.4.0",
- "_nodeSupported": true,
- "_npmVersion": "0.2.12-1",
- "_nodeVersion": "v0.2.6",
- "dist": {
- "shasum": "843578eaabb9b04906d8a63325f00e04053bfa64"
- }
-}
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package.tgz
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._.DS_Store
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._.gitignore
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._History.md
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._Readme.md
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/._package.json
Binary file not shown
View
8 node_modules/.npm/.cache/canvas/0.4.0/package/.gitignore
@@ -1,8 +0,0 @@
-build
-.DS_Store
-.lock-wscript
-test/images/*.png
-examples/*.png
-testing
-test.png
-.pomo
View
9 node_modules/.npm/.cache/canvas/0.4.0/package/.gitmodules
@@ -1,9 +0,0 @@
-[submodule "support/expresso"]
- path = support/expresso
- url = git://github.com/visionmedia/expresso.git
-[submodule "support/express"]
- path = support/express
- url = git://github.com/visionmedia/express.git
-[submodule "support/jade"]
- path = support/jade
- url = git://github.com/visionmedia/jade.git
View
6 node_modules/.npm/.cache/canvas/0.4.0/package/.npmignore
@@ -1,6 +0,0 @@
-testing
-build
-benchmarks
-examples
-support
-test
View
122 node_modules/.npm/.cache/canvas/0.4.0/package/History.md
@@ -1,122 +0,0 @@
-
-0.4.0 / 2010-12-12
-==================
-
- * Added `drawImage()` with `Canvas` instance support. Closes #67
-
-0.3.3 / 2010-11-30
-==================
-
- * Added `CanvasRenderingContext2d#patternQuality` accessor, accepting _fast_, _good_, and _best_
- * Fixed; pre-multiply `putImageData()` components
- * Fixed; `PixelArray` data is not premultiplied
-
-0.3.2 / 2010-11-26
-==================
-
- * Added --profile option to config
- * Fixed `eio_custom` segfault(s). Closes #46
- * Fixed two named colors. Closes #62 [thanks noonat]
- * Fixed a few warnings
- * Fixed; freeing data in `Image::loadJPEG()` on failure
- * Fixed; include _jpeglib_ only when __HAVE_JPEG__
- * Fixed; using `strstr()` instead of `strnstr()`
-
-0.3.1 / 2010-11-24
-==================
-
- * Fixed; `Image` loading is sync until race-condition is resolved
- * Fixed; `Image::loadJPEG()` return status based on errno
-
-0.3.0 / 2010-11-24
-==================
-
- * Added arcTo(). Closes #11
- * Added c color parser, _./examples/ray.js_ is now twice as fast
- * Fixed `putImageData()` bug messing up rgba channels
-
-0.2.1 / 2010-11-19
-==================
-
- * Added image _resize_ example
- * Fixed canvas resizing via `{width,height}=`. Closes #57
- * Fixed `Canvas#getContext()`, caching the CanvasRenderingContext
- * Fixed async image loading (test server still messed)
-
-0.2.0 / 2010-11-18
-==================
-
- * Added jpeg `Image` support (when libjpeg is available)
- * Added _hsl_ / _hsla_ color support. [Tom Carden]
-
-0.1.0 / 2010-11-17
-==================
-
- * Added `Image`
- * Added `ImageData`
- * Added `PixelArray`
- * Added `CanvasRenderingContext2d#drawImage()`
- * Added `CanvasRenderingContext2d#getImageData()`
- * Added `CanvasRenderingContext2d#createImageData()`
- * Added kraken blur benchmark example
- * Added several new tests
- * Fixed instanceof checks for many c++ methods
- * Fixed test runner in firefox [Don Park]
-
-0.0.8 / 2010-11-12
-==================
-
- * Added `CanvasRenderingContext2d#drawImage()`
- * Fixed `free()` call missing stdlib
- * Fixed Image#{width,height} initialization to 0
- * Fixed; load image on non-LOADING state
-
-0.0.7 / 2010-11-12
-==================
-
- * Fixed _lighter_ for older versions of cairo
-
-0.0.6 / 2010-11-12
-==================
-
- * Added `Image`
- * Added conditional support for cairo 1.10.0 operators
-
-0.0.5 / 2010-11-10
-==================
-
- * Added custom port support to _test/server.js_
- * Added more global composite operator support
- * Added `Context2d#antialias=`
- * Added _voronoi_ example
- * Added -D__NDEBUG__ to default build
- * Added __BUFFER_DATA__ macro for backwards compat buffer data access [Don Park]
- * Fixed getter bug preventing patterns from being returned via `fillStyle` etc
-
- * Fixed; __CAIRO_STATUS_NO_MEMORY___ on failed {re,m}alloc()
- * Fixed; free `Canvas::ToBuffer()` closure data
-
-0.0.4 / 2010-11-09
-==================
-
- * Bump to fix npm engine cache bug...
-
-0.0.3 / 2010-11-09
-==================
-
- * Added async `toDataURL()` support
- * Added async `toBuffer()` support
- * Removed buffer utils
-
-0.0.2 / 2010-11-08
-==================
-
- * Added shadow support (faster/better gaussian blur to come)
- * Added node v0.3 support [Don Park]
- * Added -O3 to build
- * Removed `Canvas#savePNG()` use `Canvas#createPNGStream()`
-
-0.0.1 / 2010-11-04
-==================
-
- * Initial release
View
21 node_modules/.npm/.cache/canvas/0.4.0/package/Makefile
@@ -1,21 +0,0 @@
-
-ADDON = build/default/canvas.node
-
-$(ADDON): src/*.cc
- node-waf configure build
-
-test: $(ADDON)
- @./support/expresso/bin/expresso \
- -I lib \
- test/*.test.js
-
-test-server: $(ADDON)
- @node test/server.js
-
-benchmark:
- @node benchmarks/run.js
-
-clean:
- node-waf distclean
-
-.PHONY: test test-server benchmark clean
View
184 node_modules/.npm/.cache/canvas/0.4.0/package/Readme.md
@@ -1,184 +0,0 @@
-
-# node-canvas
-
- Node canvas is a [Cairo](http://cairographics.org/) backed Canvas implementation for [NodeJS](http://nodejs.org).
-
-## Authors
-
- - TJ Holowaychuk ([visionmedia](http://github.com/visionmedia))
-
-## Installation
-
- $ npm install canvas
-
-If not previously installed, you will want to install the [cairo graphics library](http://cairographics.org/download/) version _>= 1.8.6_ first using the package manager available to you, or [building from source](https://github.com/LearnBoost/node-canvas/wiki/_pages).
-
-## Screencasts
-
- - [Introduction](http://screenr.com/CTk)
-
-## Example
-
- var Canvas = require('canvas')
- , canvas = new Canvas(200,200)
- , ctx = canvas.getContext('2d');
-
-
- ctx.font = '30px Impact';
- ctx.rotate(.1);
- ctx.fillText("Awesome!", 50, 100);
-
- var te = ctx.measureText('Awesome!');
- ctx.strokeStyle = 'rgba(0,0,0,0.5)';
- ctx.beginPath();
- ctx.lineTo(50, 102);
- ctx.lineTo(50 + te.width, 102);
- ctx.stroke();
-
- console.log('<img src="' + canvas.toDataURL() + '" />');
-
-## Non-Standard API
-
-
- node-canvas extends the canvas API to provide interfacing with node, for example streaming PNG data, converting to a `Buffer` instance, etc. Among the interfacing API, in some cases the drawing API has been extended for SSJS image manipulation / creation usage, however keep in mind these additions may fail to render properly within browsers.
-
-### Canvas#createPNGStream()
-
- To create a `PNGStream` simple call `canvas.createPNGStream()`, and the stream will start to emit _data_ events, finally emitting _end_ when finished. If an exception occurs the _error_ event is emitted.
-
- var fs = require('fs')
- , out = fs.createWriteStream(__dirname + '/text.png')
- , stream = canvas.createPNGStream();
-
- stream.on('data', function(chunk){
- out.write(chunk);
- });
-
- stream.on('end', function(){
- console.log('saved png');
- });
-
-Currently _only_ sync streaming is supported, however we plan on supporting async streaming as well (of course :) ). Until then the `Canvas#toBuffer(callback)` alternative is async utilizing `eio_custom()`.
-
-### Canvas#toBuffer()
-
- A call to `Canvas#toBuffer()` will return a node `Buffer` instance containing all of the PNG data.
-
- canvas.toBuffer();
-
-### Canvas#toBuffer() async
-
- Optionally we may pass a callback function to `Canvas#toBuffer()`, and this process will be performed asynchronously, and will `callback(err, buf)`.
-
-
- canvas.toBuffer(function(err, buf){
-
- });
-
-### Canvas#toDataURL() async
-
- Optionally we may pass a callback function to `Canvas#toDataURL()`, and this process will be performed asynchronously, and will `callback(err, str)`.
-
-
- canvas.toDataURL(function(err, str){
-
- });
-
-or specify the mime type:
-
- canvas.toDataURL('image/png', function(err, str){
-
- });
-
-### CanvasRenderingContext2d#patternQuality
-
-Given one of the values below will alter pattern (gradients, images, etc) render quality, defaults to _good_.
-
- - fast
- - good
- - best
-
-### Global Composite Operations
-
- In addition to those specified and commonly implemented by browsers, the following have been added:
-
- - multiply
- - screen
- - overlay
- - hard-light
- - soft-light
- - hsl-hue
- - hsl-saturation
- - hsl-color
- - hsl-luminosity
-
-## Anti-Aliasing
-
- Set anti-aliasing mode:
-
- - default
- - none
- - gray
- - subpixel
-
-## Benchmarks
-
- Although node-canvas is extremely new, and we have not even begun optimization yet it is already quite fast. For benchmarks vs other node canvas implementations view this [gist](https://gist.github.com/664922), or update the submodules and run `$ make benchmark` yourself.
-
-## Contribute
-
- Want to contribute to node-canvas? patches for features, bug fixes, documentation, examples and others are certainly welcome. Take a look at the [issue queue](https://github.com/LearnBoost/node-canvas/issues) for existing issues.
-
-## Examples
-
- Examples are placed in _./examples_, be sure to check them out! most produce a png image of the same name, and others such as _live-clock.js_ launch an http server to be viewed in the browser.
-
-## Testing
-
-If you have not previously, init git submodules:
-
- $ git submodule update --init
-
-Build node-canvas:
-
- $ node-waf configure build
-
-Unit tests:
-
- $ make test
-
-Visual tests:
-
- $ make test-server
-
-## Versions
-
-Tested with:
-
- - node 0.2.4
- - cairo 1.8.6
-
-## License
-
-(The MIT License)
-
-Copyright (c) 2010 LearnBoost &lt;dev@learnboost.ca&gt;
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-'Software'), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
1  node_modules/.npm/.cache/canvas/0.4.0/package/index.js
@@ -1 +0,0 @@
-module.exports = require('./lib/canvas');
View
48 node_modules/.npm/.cache/canvas/0.4.0/package/install
@@ -1,48 +0,0 @@
-#!/bin/sh
-
-PKG_CONFIG="http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz"
-PIXMAN="http://www.cairographics.org/releases/pixman-0.20.0.tar.gz"
-CAIRO="http://cairographics.org/releases/cairo-1.10.0.tar.gz"
-LIBPNG="ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.40.tar.gz"
-PREFIX=${1-/usr/local}
-
-require() {
- echo "... checking for $1"
- if test `which $1`; then
- echo "... found"
- else
- echo "... not found"
- exit 1
- fi
-}
-
-fetch() {
- local tarball=`basename $1`
- echo "... downloading $tarball"
- local dir=${tarball/.tar.gz/}
- curl -# -L $1 -o $tarball \
- && echo "... unpacking" \
- && tar -zxf $tarball \
- && echo "... removing tarball" \
- && rm -fr $tarball \
- && install $dir
-}
-
-install() {
- local dir=$1
- echo "... installing $1"
- cd $dir \
- && ./configure --disable-dependency-tracking --prefix=$PREFIX \
- && make \
- && make install \
- && echo "... removing $dir" \
- && cd .. && rm -fr $dir
-}
-
-echo "... installing to $PREFIX"
-require curl
-require tar
-test `which pkg-config` || fetch $PKG_CONFIG
-require 'pkg-config'
-fetch $PIXMAN
-fetch $CAIRO
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/lib/._canvas.js
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/lib/._pngstream.js
Binary file not shown
View
146 node_modules/.npm/.cache/canvas/0.4.0/package/lib/canvas.js
@@ -1,146 +0,0 @@
-
-/*!
- * Canvas
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
- * MIT Licensed
- */
-
-/**
- * Module dependencies.
- */
-
-var canvas = require('../build/default/canvas')
- , Canvas = canvas.Canvas
- , Image = canvas.Image
- , cairoVersion = canvas.cairoVersion
- , PixelArray = canvas.PixelArray
- , Context2d = require('./context2d')
- , PNGStream = require('./pngstream')
- , fs = require('fs');
-
-/**
- * Export `Canvas` as the module.
- */
-
-var Canvas = exports = module.exports = Canvas;
-
-/**
- * Library version.
- */
-
-exports.version = '0.4.0';
-
-/**
- * Cairo version.
- */
-
-exports.cairoVersion = cairoVersion;
-
-/**
- * Expose constructors.
- */
-
-exports.Context2d = Context2d;
-exports.PNGStream = PNGStream;
-exports.PixelArray = PixelArray;
-exports.Image = Image;
-
-/**
- * Context2d implementation.
- */
-
-require('./context2d');
-
-/**
- * Image implementation.
- */
-
-require('./image');
-
-/**
- * PixelArray implementation.
- */
-
-require('./pixelarray');
-
-/**
- * Inspect canvas.
- *
- * @return {String}
- * @api public
- */
-
-Canvas.prototype.inspect = function(){
- return '[Canvas ' + this.width + 'x' + this.height + ']';
-};
-
-/**
- * Get a context object.
- *
- * @param {String} contextId
- * @return {Context2d}
- * @api public
- */
-
-Canvas.prototype.getContext = function(contextId){
- if ('2d' == contextId) {
- var ctx = this._context2d || (this._context2d = new Context2d(this));
- this.context = ctx;
- ctx.canvas = this;
- return ctx;
- }
-};
-
-/**
- * Create a `PNGStream` for `this` canvas.
- *
- * @return {PNGStream}
- * @api public
- */
-
-Canvas.prototype.createPNGStream = function(){
- return new PNGStream(this);
-};
-
-/**
- * Create a synchronous `PNGStream` for `this` canvas.
- *
- * @return {PNGStream}
- * @api public
- */
-
-Canvas.prototype.createSyncPNGStream = function(){
- return new PNGStream(this, true);
-};
-
-/**
- * Return a data url. Pass a function for async support.
- *
- * @param {String|Function} type
- * @param {Function} fn
- * @return {String}
- * @api public
- */
-
-Canvas.prototype.toDataURL = function(type, fn){
- // Default to png
- type = type || 'image/png';
-
- // Allow callback as first arg
- if ('function' == typeof type) fn = type, type = 'image/png';
-
- // Throw on non-png
- if ('image/png' != type) throw new Error('currently only image/png is supported');
-
- var prefix = 'data:' + type + ';base64,';
-
- if (fn) {
- this.toBuffer(function(err, buf){
- if (err) return fn(err);
- var str = 'data:' + type
- fn(null, prefix + buf.toString('base64'));
- });
- } else {
- return prefix + this.toBuffer().toString('base64');
- }
-};
View
325 node_modules/.npm/.cache/canvas/0.4.0/package/lib/context2d.js
@@ -1,325 +0,0 @@
-
-/*!
- * Canvas - Context2d
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
- * MIT Licensed
- */
-
-/**
- * Module dependencies.
- */
-
-var canvas = require('../build/default/canvas')
- , Context2d = canvas.CanvasRenderingContext2d
- , CanvasGradient = canvas.CanvasGradient
- , ImageData = canvas.ImageData
- , PixelArray = canvas.CanvasPixelArray;
-
-/**
- * Export `Context2d` as the module.
- */
-
-var Context2d = exports = module.exports = Context2d;
-
-/**
- * Cache color string RGBA values.
- */
-
-var cache = {};
-
-/**
- * Text baselines.
- */
-
-var baselines = ['alphabetic', 'top', 'bottom', 'middle', 'ideographic', 'hanging'];
-
-/**
- * Font RegExp helpers.
- */
-
-var weights = 'normal|bold|bolder|lighter|[1-9]00'
- , styles = 'normal|italic|oblique'
- , units = 'px|pt|pc|in|cm|mm|%'
- , string = '\'([^\']+)\'|"([^"]+)"|[\\w-]+';
-
-/**
- * Font parser RegExp;
- */
-
-var fontre = new RegExp('^ *'
- + '(?:(' + weights + ') *)?'
- + '(?:(' + styles + ') *)?'
- + '([\\d\\.]+)(' + units + ') *'
- + '((?:' + string + ')( *, *(?:' + string + '))*)'
- );
-
-/**
- * Parse font `str`.
- *
- * @param {String} str
- * @return {Object}
- * @api private
- */
-
-var parseFont = exports.parseFont = function(str){
- var font = {}
- , captures = fontre.exec(str);
-
- // Invalid
- if (!captures) return;
-
- // Populate font object
- font.weight = captures[1] || 'normal';
- font.style = captures[2] || 'normal';
- font.size = parseFloat(captures[3]);
- font.unit = captures[4];
- font.family = captures[5];
-
- return font;
-};
-
-/**
- * Create a linear gradient at the given point `(x0, y0)` and `(x1, y1)`.
- *
- * @param {Number} x0
- * @param {Number} y0
- * @param {Number} x1
- * @param {Number} y1
- * @return {CanvasGradient}
- * @api public
- */
-
-Context2d.prototype.createLinearGradient = function(x0, y0, x1, y1){
- return new CanvasGradient(x0, y0, x1, y1);
-};
-
-/**
- * Create a radial gradient at the given point `(x0, y0)` and `(x1, y1)`
- * and radius `r0` and `r1`.
- *
- * @param {Number} x0
- * @param {Number} y0
- * @param {Number} r0
- * @param {Number} x1
- * @param {Number} y1
- * @param {Number} r1
- * @return {CanvasGradient}
- * @api public
- */
-
-Context2d.prototype.createRadialGradient = function(x0, y0, r0, x1, y1, r1){
- return new CanvasGradient(x0, y0, r0, x1, y1, r1);
-};
-
-/**
- * Reset transform matrix to identity, then apply the given args.
- *
- * @param {...}
- * @api public
- */
-
-Context2d.prototype.setTransform = function(){
- this.resetTransform();
- this.transform.apply(this, arguments);
-};
-
-/**
- * Set the fill style with the given css color string.
- *
- * @api public
- */
-
-Context2d.prototype.__defineSetter__('fillStyle', function(val){
- if (val instanceof CanvasGradient) {
- this.lastFillStyle = val;
- this.setFillPattern(val);
- } else if ('string' == typeof val) {
- this.setFillColor(val);
- }
-});
-
-/**
- * Get previous fill style.
- *
- * @return {CanvasGradient|String}
- * @api public
- */
-
-Context2d.prototype.__defineGetter__('fillStyle', function(){
- return this.lastFillStyle || this.fillColor;
-});
-
-/**
- * Set the stroke style with the given css color string.
- *
- * @api public
- */
-
-Context2d.prototype.__defineSetter__('strokeStyle', function(val){
- if (val instanceof CanvasGradient) {
- this.lastStrokeStyle = val;
- this.setStrokePattern(val);
- } else if ('string' == typeof val) {
- this.setStrokeColor(val);
- }
-});
-
-/**
- * Get previous stroke style.
- *
- * @return {CanvasGradient|String}
- * @api public
- */
-
-Context2d.prototype.__defineGetter__('strokeStyle', function(){
- return this.lastStrokeStyle || this.strokeColor;
-});
-
-
-/**
- * Set font.
- *
- * @see exports.parseFont()
- * @api public
- */
-
-Context2d.prototype.__defineSetter__('font', function(val){
- if ('string' == typeof val) {
- var font;
- if (font = cache[val] || parseFont(val)) {
- this.lastFontString = val;
-
- // TODO: dpi
- // TODO: remaining unit conversion
- switch (font.unit) {
- case 'pt':
- font.size /= .75;
- break;
- case 'in':
- font.size *= 96;
- break;
- case 'mm':
- font.size *= 96.0 / 25.4;
- break;
- case 'cm':
- font.size *= 96.0 / 2.54;
- break;
- }
-
- // Cache font object
- cache[val] = font;
-
- // Set font
- this.setFont(
- font.weight
- , font.style
- , font.size
- , font.unit
- , font.family);
- }
- }
-});
-
-/**
- * Get the current font.
- *
- * @api public
- */
-
-Context2d.prototype.__defineGetter__('font', function(){
- return this.lastFontString || '10px sans-serif';
-});
-
-/**
- * Set text baseline.
- *
- * @api public
- */
-
-Context2d.prototype.__defineSetter__('textBaseline', function(val){
- var n = baselines.indexOf(val);
- if (~n) {
- this.lastBaseline = val;
- this.setTextBaseline(n);
- }
-});
-
-/**
- * Get the current baseline setting.
- *
- * @api public
- */
-
-Context2d.prototype.__defineGetter__('textAlign', function(){
- return this.lastBaseline || 'alphabetic';
-});
-
-/**
- * Set text alignment.
- *
- * @api public
- */
-
-Context2d.prototype.__defineSetter__('textAlign', function(val){
- switch (val) {
- case 'center':
- this.setTextAlignment(0);
- this.lastTextAlignment = val;
- break;
- case 'left':
- case 'start':
- this.setTextAlignment(-1);
- this.lastTextAlignment = val;
- break;
- case 'right':
- case 'end':
- this.setTextAlignment(1);
- this.lastTextAlignment = val;
- break;
- }
-});
-
-/**
- * Get the current font.
- *
- * @see exports.parseFont()
- * @api public
- */
-
-Context2d.prototype.__defineGetter__('textAlign', function(){
- return this.lastTextAlignment || 'start';
-});
-
-/**
- * Get `ImageData` with the given rect.
- *
- * @param {Number} x
- * @param {Number} y
- * @param {Number} width
- * @param {Number} height
- * @return {ImageData}
- * @api public
- */
-
-Context2d.prototype.getImageData = function(x, y, width, height){
- var arr = new PixelArray(this.canvas, x, y, width, height);
- return new ImageData(arr);
-};
-
-/**
- * Create `ImageData` with the given dimensions or
- * `ImageData` instance for dimensions.
- *
- * @param {Number|ImageData} width
- * @param {Number} height
- * @return {ImageData}
- * @api public
- */
-
-Context2d.prototype.createImageData = function(width, height){
- if (width instanceof ImageData) {
- height = width.height;
- width = width.width;
- }
- return new ImageData(new PixelArray(width, height));
-};
View
28 node_modules/.npm/.cache/canvas/0.4.0/package/lib/image.js
@@ -1,28 +0,0 @@
-
-/*!
- * Canvas - Image
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
- * MIT Licensed
- */
-
-/**
- * Module dependencies.
- */
-
-var Canvas = require('../build/default/canvas')
- , Image = Canvas.Image;
-
-/**
- * Inspect image.
- *
- * @return {String}
- * @api public
- */
-
-Image.prototype.inspect = function(){
- return '[Image'
- + (this.complete ? ':' + this.width + 'x' + this.height : '')
- + (this.src ? ' ' + this.src : '')
- + (this.complete ? ' complete' : '')
- + ']';
-};
View
29 node_modules/.npm/.cache/canvas/0.4.0/package/lib/pixelarray.js
@@ -1,29 +0,0 @@
-
-/*!
- * Canvas - PixelArray
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
- * MIT Licensed
- */
-
-/**
- * Module dependencies.
- */
-
-var Canvas = require('../build/default/canvas')
- , PixelArray = Canvas.CanvasPixelArray;
-
-/**
- * Custom inspect.
- */
-
-PixelArray.prototype.inspect = function(){
- var buf = '[PixelArray ';
- for (var i = 0, len = this.length; i < len; i += 4) {
- buf += '\n ' + i + ': rgba('
- + this[i + 0] + ','
- + this[i + 1] + ','
- + this[i + 2] + ','
- + this[i + 3] + ')';
- }
- return buf + '\n]';
-};
View
63 node_modules/.npm/.cache/canvas/0.4.0/package/lib/pngstream.js
@@ -1,63 +0,0 @@
-
-/*!
- * Canvas - PNGStream
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
- * MIT Licensed
- */
-
-/**
- * Module dependencies.
- */
-
-var EventEmitter = require('events').EventEmitter;
-
-/**
- * Initialize a `PNGStream` with the given `canvas`.
- *
- * "data" events are emitted with `Buffer` chunks, once complete the
- * "end" event is emitted. The following example will stream to a file
- * named "./my.png".
- *
- * var out = fs.createWriteStream(__dirname + '/my.png')
- * , stream = canvas.createPNGStream();
- *
- * stream.on('data', function(chunk){
- * out.write(chunk);
- * });
- *
- * stream.on('end', function(){
- * out.end();
- * });
- *
- * @param {Canvas} canvas
- * @param {Boolean} sync
- * @api public
- */
-
-var PNGStream = module.exports = function PNGStream(canvas, sync) {
- var self = this
- , method = sync
- ? 'streamPNGSync'
- : 'streamPNG';
- this.sync = sync;
- this.canvas = canvas;
- // TODO: implement async
- if ('streamPNG' == method) method = 'streamPNGSync';
- process.nextTick(function(){
- canvas[method](function(err, chunk, len){
- if (err) {
- self.emit('error', err);
- } else if (len) {
- self.emit('data', chunk, len);
- } else {
- self.emit('end');
- }
- });
- });
-};
-
-/**
- * Inherit from `EventEmitter`.
- */
-
-PNGStream.prototype.__proto__ = EventEmitter.prototype;
View
11 node_modules/.npm/.cache/canvas/0.4.0/package/package.json
@@ -1,11 +0,0 @@
-{ "name": "canvas"
- , "description": "Canvas graphics API backed by Cairo"
- , "version": "0.4.0"
- , "author": "TJ Holowaychuk <tj@learnboost.com>"
- , "keywords": ["canvas", "graphic", "graphics"]
- , "scripts": {
- "preinstall": "node-waf configure build"
- }
- , "engines": { "node": ">= 0.2.3" }
- , "main": "./lib/canvas.js"
-}
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._Canvas.cc
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._Canvas.h
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._CanvasGradient.cc
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._CanvasRenderingContext2d.cc
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._Image.h
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._ImageData.cc
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._ImageData.h
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._PixelArray.cc
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._PixelArray.h
Binary file not shown
View
BIN  node_modules/.npm/.cache/canvas/0.4.0/package/src/._color.cc
Binary file not shown
View
312 node_modules/.npm/.cache/canvas/0.4.0/package/src/Canvas.cc
@@ -1,312 +0,0 @@
-
-//
-// Canvas.cc
-//
-// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
-//
-
-#include "Canvas.h"
-#include "CanvasRenderingContext2d.h"
-#include "closure.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <node_buffer.h>
-#include <node_version.h>
-
-Persistent<FunctionTemplate> Canvas::constructor;
-
-/*
- * Buffer data pointer access.
- */
-
-#if NODE_VERSION_AT_LEAST(0,3,0)
-#define BUFFER_DATA(buf) Buffer::Data(buf->handle_)
-#else
-#define BUFFER_DATA(buf) buf->data()
-#endif
-
-/*
- * Initialize Canvas.
- */
-
-void
-Canvas::Initialize(Handle<Object> target) {
- HandleScope scope;
-
- // Constructor
- constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Canvas::New));
- constructor->InstanceTemplate()->SetInternalFieldCount(1);
- constructor->SetClassName(String::NewSymbol("Canvas"));
-
- // Prototype
- Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
- NODE_SET_PROTOTYPE_METHOD(constructor, "toBuffer", ToBuffer);
- NODE_SET_PROTOTYPE_METHOD(constructor, "streamPNGSync", StreamPNGSync);
- proto->SetAccessor(String::NewSymbol("width"), GetWidth, SetWidth);
- proto->SetAccessor(String::NewSymbol("height"), GetHeight, SetHeight);
- target->Set(String::NewSymbol("Canvas"), constructor->GetFunction());
-}
-
-/*
- * Initialize a Canvas with the given width and height.
- */
-
-Handle<Value>
-Canvas::New(const Arguments &args) {
- HandleScope scope;
- int width = 0, height = 0;
- if (args[0]->IsNumber()) width = args[0]->Uint32Value();
- if (args[1]->IsNumber()) height = args[1]->Uint32Value();
- Canvas *canvas = new Canvas(width, height);
- canvas->Wrap(args.This());
- return args.This();
-}
-
-/*
- * Get width.
- */
-
-Handle<Value>
-Canvas::GetWidth(Local<String> prop, const AccessorInfo &info) {
- Canvas *canvas = ObjectWrap::Unwrap<Canvas>(info.This());
- return Number::New(canvas->width);
-}
-
-/*
- * Set width.
- */
-
-void
-Canvas::SetWidth(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
- if (val->IsNumber()) {
- Canvas *canvas = ObjectWrap::Unwrap<Canvas>(info.This());
- canvas->width = val->Uint32Value();
- canvas->resurface(info.This());
- }
-}
-
-/*
- * Get height.
- */
-
-Handle<Value>
-Canvas::GetHeight(Local<String> prop, const AccessorInfo &info) {
- Canvas *canvas = ObjectWrap::Unwrap<Canvas>(info.This());
- return Number::New(canvas->height);
-}
-
-/*
- * Set height.
- */
-
-void
-Canvas::SetHeight(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
- if (val->IsNumber()) {
- Canvas *canvas = ObjectWrap::Unwrap<Canvas>(info.This());
- canvas->height = val->Uint32Value();
- canvas->resurface(info.This());
- }
-}
-
-/*
- * Canvas::ToBuffer callback.
- */
-
-static cairo_status_t
-toBuffer(void *c, const uint8_t *data, unsigned len) {
- closure_t *closure = (closure_t *) c;
- if (closure->len) {
- closure->data = (uint8_t *) realloc(closure->data, closure->len + len);
- if (!closure->data) return CAIRO_STATUS_NO_MEMORY;
- memcpy(closure->data + closure->len, data, len);
- closure->len += len;
- } else {
- closure->data = (uint8_t *) malloc(len);
- if (!closure->data) return CAIRO_STATUS_NO_MEMORY;
- memcpy(closure->data, data, len);
- closure->len += len;
- }
- return CAIRO_STATUS_SUCCESS;
-}
-
-/*
- * EIO toBuffer callback.
- */
-
-int
-Canvas::EIO_ToBuffer(eio_req *req) {
- closure_t *closure = (closure_t *) req->data;
-
- closure->status = cairo_surface_write_to_png_stream(
- closure->canvas->surface()
- , toBuffer
- , closure);
-
- return 0;
-}
-
-/*
- * EIO after toBuffer callback.
- */
-
-int
-Canvas::EIO_AfterToBuffer(eio_req *req) {
- HandleScope scope;
- closure_t *closure = (closure_t *) req->data;
- ev_unref(EV_DEFAULT_UC);
-
- if (closure->status) {
- Local<Value> argv[1] = { Canvas::Error(closure->status) };
- closure->pfn->Call(Context::GetCurrent()->Global(), 1, argv);
- } else {
- Buffer *buf = Buffer::New(closure->len);
- memcpy(BUFFER_DATA(buf), closure->data, closure->len);
- Local<Value> argv[2] = { Local<Value>::New(Null()), Local<Value>::New(buf->handle_) };
- closure->pfn->Call(Context::GetCurrent()->Global(), 2, argv);
- }
-
- closure->canvas->Unref();
- closure->pfn.Dispose();
- free(closure->data);
- free(closure);
- return 0;
-}
-
-/*
- * Convert PNG data to a node::Buffer, async when a
- * callback function is passed.
- */
-
-Handle<Value>
-Canvas::ToBuffer(const Arguments &args) {
- HandleScope scope;
- Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This());
-
- // Async
- if (args[0]->IsFunction()) {
- closure_t *closure = (closure_t *) malloc(sizeof(closure_t));
- closure->len = 0;
- closure->canvas = canvas;
- // TODO: only one callback fn in closure
- canvas->Ref();
- closure->pfn = Persistent<Function>::New(Handle<Function>::Cast(args[0]));
- eio_custom(EIO_ToBuffer, EIO_PRI_DEFAULT, EIO_AfterToBuffer, closure);
- ev_ref(EV_DEFAULT_UC);
- return Undefined();
- } else {
- closure_t closure;
- closure.len = 0;
-
- TryCatch try_catch;
- cairo_status_t status = cairo_surface_write_to_png_stream(canvas->surface(), toBuffer, &closure);
-
- if (try_catch.HasCaught()) {
- return try_catch.ReThrow();
- } else if (status) {
- return ThrowException(Canvas::Error(status));
- } else {
- Buffer *buf = Buffer::New(closure.len);
- memcpy(BUFFER_DATA(buf), closure.data, closure.len);
- return buf->handle_;
- }
- }
-}
-
-/*
- * Canvas::StreamPNG callback.
- */
-
-static cairo_status_t
-streamPNG(void *c, const uint8_t *data, unsigned len) {
- HandleScope scope;
- closure_t *closure = (closure_t *) c;
- Local<Buffer> buf = Buffer::New(len);
- memcpy(BUFFER_DATA(buf), data, len);
- Local<Value> argv[3] = {
- Local<Value>::New(Null())
- , Local<Value>::New(buf->handle_)
- , Integer::New(len) };
- closure->fn->Call(Context::GetCurrent()->Global(), 3, argv);
- return CAIRO_STATUS_SUCCESS;
-}
-
-/*
- * Stream PNG data synchronously.
- */
-
-Handle<Value>
-Canvas::StreamPNGSync(const Arguments &args) {
- HandleScope scope;
- // TODO: async as well
- if (!args[0]->IsFunction())
- return ThrowException(Exception::TypeError(String::New("callback function required")));
-
- Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This());
- closure_t closure;
- closure.fn = Handle<Function>::Cast(args[0]);
-
- TryCatch try_catch;
- cairo_status_t status = cairo_surface_write_to_png_stream(canvas->surface(), streamPNG, &closure);
-
- if (try_catch.HasCaught()) {
- return try_catch.ReThrow();
- } else if (status) {
- Local<Value> argv[1] = { Canvas::Error(status) };
- closure.fn->Call(Context::GetCurrent()->Global(), 1, argv);
- } else {
- Local<Value> argv[3] = {
- Local<Value>::New(Null())
- , Local<Value>::New(Null())
- , Integer::New(0) };
- closure.fn->Call(Context::GetCurrent()->Global(), 3, argv);
- }
- return Undefined();
-}
-
-/*
- * Initialize cairo surface.
- */
-
-Canvas::Canvas(int w, int h): ObjectWrap() {
- width = w;
- height = h;
- _surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
-}
-
-/*
- * Destroy cairo surface.
- */
-
-Canvas::~Canvas() {
- cairo_surface_destroy(_surface);
-}
-
-/*
- * Re-alloc the surface, destroying the previous.
- */
-
-void
-Canvas::resurface(Handle<Object> canvas) {
- // Re-surface
- cairo_surface_destroy(_surface);
- _surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
-
- // Reset context
- Handle<Value> context = canvas->Get(String::New("context"));
- if (!context->IsUndefined()) {
- Context2d *context2d = ObjectWrap::Unwrap<Context2d>(context->ToObject());
- cairo_t *prev = context2d->context();
- context2d->setContext(cairo_create(surface()));
- cairo_destroy(prev);
- }
-}
-
-/*
- * Construct an Error from the given cairo status.
- */
-
-Local<Value>
-Canvas::Error(cairo_status_t status) {
- return Exception::Error(String::New(cairo_status_to_string(status)));
-}
View
59 node_modules/.npm/.cache/canvas/0.4.0/package/src/Canvas.h
@@ -1,59 +0,0 @@
-
-//
-// Canvas.h
-//
-// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
-//
-
-#ifndef __NODE_CANVAS_H__
-#define __NODE_CANVAS_H__
-
-#include <v8.h>
-#include <node.h>
-#include <node_object_wrap.h>
-#include <cairo.h>
-
-using namespace v8;
-using namespace node;
-
-/*
- * Maxmimum states per context.
- * TODO: remove/resize
- */
-
-#ifndef CANVAS_MAX_STATES
-#define CANVAS_MAX_STATES 64
-#endif
-
-/*
- * Canvas.
- */
-
-class Canvas: public node::ObjectWrap {
- public:
- int width;
- int height;
- static Persistent<FunctionTemplate> constructor;
- static void Initialize(Handle<Object> target);
- static Handle<Value> New(const Arguments &args);
- static Handle<Value> ToBuffer(const Arguments &args);
- static Handle<Value> GetWidth(Local<String> prop, const AccessorInfo &info);
- static Handle<Value> GetHeight(Local<String> prop, const AccessorInfo &info);
- static void SetWidth(Local<String> prop, Local<Value> val, const AccessorInfo &info);
- static void SetHeight(Local<String> prop, Local<Value> val, const AccessorInfo &info);
- static Handle<Value> StreamPNGSync(const Arguments &args);
- static Local<Value> Error(cairo_status_t status);
- static int EIO_ToBuffer(eio_req *req);
- static int EIO_AfterToBuffer(eio_req *req);
- inline cairo_surface_t *surface(){ return _surface; }
- inline uint8_t *data(){ return cairo_image_surface_get_data(_surface); }
- inline int stride(){ return cairo_image_surface_get_stride(_surface); }
- Canvas(int width, int height);
- void resurface(Handle<Object> canvas);
-
- private:
- ~Canvas();
- cairo_surface_t *_surface;
-};
-
-#endif
View
122 node_modules/.npm/.cache/canvas/0.4.0/package/src/CanvasGradient.cc
@@ -1,122 +0,0 @@
-
-//
-// Gradient.cc
-//
-// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
-//
-
-#include "color.h"
-#include "Canvas.h"
-#include "CanvasGradient.h"
-
-Persistent<FunctionTemplate> Gradient::constructor;
-
-/*
- * Initialize CanvasGradient.
- */
-
-void
-Gradient::Initialize(Handle<Object> target) {
- HandleScope scope;
-
- // Constructor
- constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Gradient::New));
- constructor->InstanceTemplate()->SetInternalFieldCount(1);
- constructor->SetClassName(String::NewSymbol("CanvasGradient"));
-
- // Prototype
- NODE_SET_PROTOTYPE_METHOD(constructor, "addColorStop", AddColorStop);
- target->Set(String::NewSymbol("CanvasGradient"), constructor->GetFunction());
-}
-
-/*
- * Initialize a new CanvasGradient.
- */
-
-Handle<Value>
-Gradient::New(const Arguments &args) {
- HandleScope scope;
-
- // Linear
- if (4 == args.Length()) {
- Gradient *grad = new Gradient(
- args[0]->NumberValue()
- , args[1]->NumberValue()
- , args[2]->NumberValue()
- , args[3]->NumberValue());
- grad->Wrap(args.This());
- return args.This();
- }
-
- // Radial
- if (6 == args.Length()) {
- Gradient *grad = new Gradient(
- args[0]->NumberValue()
- , args[1]->NumberValue()
- , args[2]->NumberValue()
- , args[3]->NumberValue()
- , args[4]->NumberValue()
- , args[5]->NumberValue());
- grad->Wrap(args.This());
- return args.This();
- }
-
- return ThrowException(Exception::TypeError(String::New("invalid arguments")));
-}
-
-/*
- * Add color stop.
- */
-
-Handle<Value>
-Gradient::AddColorStop(const Arguments &args) {
- HandleScope scope;
- if (!args[0]->IsNumber())
- return ThrowException(Exception::TypeError(String::New("offset required")));
- if (!args[1]->IsString())
- return ThrowException(Exception::TypeError(String::New("color string required")));
-
- Gradient *grad = ObjectWrap::Unwrap<Gradient>(args.This());
- short ok;
- String::AsciiValue str(args[1]);
- uint32_t rgba = rgba_from_string(*str, &ok);
-
- if (ok) {
- rgba_t color = rgba_create(rgba);
- cairo_pattern_add_color_stop_rgba(
- grad->pattern()
- , args[0]->NumberValue()
- , color.r
- , color.g
- , color.b
- , color.a);
- }
-
- return Undefined();
-}
-
-/*
- * Initialize linear gradient.
- */
-
-Gradient::Gradient(double x0, double y0, double x1, double y1):
- _x0(x0), _y0(y0), _x1(x1), _y1(y1) {
- _pattern = cairo_pattern_create_linear(x0, y0, x1, y1);
-}
-
-/*
- * Initialize radial gradient.
- */
-
-Gradient::Gradient(double x0, double y0, double r0, double x1, double y1, double r1):
- _x0(x0), _y0(y0), _x1(x1), _y1(y1), _r0(r0), _r1(r1) {
- _pattern = cairo_pattern_create_radial(x0, y0, r0, x1, y1, r1);
-}
-
-/*
- * Destroy the pattern.
- */
-
-Gradient::~Gradient() {
- cairo_pattern_destroy(_pattern);
-}
View
29 node_modules/.npm/.cache/canvas/0.4.0/package/src/CanvasGradient.h
@@ -1,29 +0,0 @@
-
-//
-// CanvasGradient.h
-//
-// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
-//
-
-#ifndef __NODE_GRADIENT_H__
-#define __NODE_GRADIENT_H__
-
-#include "Canvas.h"
-
-class Gradient: public node::ObjectWrap {
- public:
- static Persistent<FunctionTemplate> constructor;
- static void Initialize(Handle<Object> target);
- static Handle<Value> New(const Arguments &args);
- static Handle<Value> AddColorStop(const Arguments &args);
- Gradient(double x0, double y0, double x1, double y1);
- Gradient(double x0, double y0, double r0, double x1, double y1, double r1);
- inline cairo_pattern_t *pattern(){ return _pattern; }
-
- private:
- ~Gradient();
- double _x0, _y0, _x1, _y1, _r0, _r1;
- cairo_pattern_t *_pattern;
-};
-
-#endif
View
1,823 node_modules/.npm/.cache/canvas/0.4.0/package/src/CanvasRenderingContext2d.cc
@@ -1,1823 +0,0 @@
-
-//
-// CanvasRenderingContext2d.cc
-//
-// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
-//
-
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include "Canvas.h"
-#include "Point.h"
-#include "Image.h"
-#include "ImageData.h"
-#include "CanvasRenderingContext2d.h"
-#include "CanvasGradient.h"
-
-Persistent<FunctionTemplate> Context2d::constructor;
-
-/*
- * Rectangle arg assertions.
- */
-
-#define RECT_ARGS \
- if (!args[0]->IsNumber() \
- ||!args[1]->IsNumber() \
- ||!args[2]->IsNumber() \
- ||!args[3]->IsNumber()) return Undefined(); \
- double x = args[0]->Int32Value(); \
- double y = args[1]->Int32Value(); \
- double width = args[2]->Int32Value(); \
- double height = args[3]->Int32Value();
-
-/*
- * Text baselines.
- */
-
-enum {
- TEXT_BASELINE_ALPHABETIC
- , TEXT_BASELINE_TOP
- , TEXT_BASELINE_BOTTOM
- , TEXT_BASELINE_MIDDLE
- , TEXT_BASELINE_IDEOGRAPHIC
- , TEXT_BASELINE_HANGING
-};
-
-/*
- * Initialize Context2d.
- */
-
-void
-Context2d::Initialize(Handle<Object> target) {
- HandleScope scope;
-
- // Constructor
- constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Context2d::New));
- constructor->InstanceTemplate()->SetInternalFieldCount(1);
- constructor->SetClassName(String::NewSymbol("CanvasRenderingContext2d"));
-
- // Prototype
- Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
- NODE_SET_PROTOTYPE_METHOD(constructor, "drawImage", DrawImage);
- NODE_SET_PROTOTYPE_METHOD(constructor, "putImageData", PutImageData);
- NODE_SET_PROTOTYPE_METHOD(constructor, "save", Save);
- NODE_SET_PROTOTYPE_METHOD(constructor, "restore", Restore);
- NODE_SET_PROTOTYPE_METHOD(constructor, "rotate", Rotate);
- NODE_SET_PROTOTYPE_METHOD(constructor, "translate", Translate);
- NODE_SET_PROTOTYPE_METHOD(constructor, "transform", Transform);
- NODE_SET_PROTOTYPE_METHOD(constructor, "resetTransform", ResetTransform);
- NODE_SET_PROTOTYPE_METHOD(constructor, "isPointInPath", IsPointInPath);
- NODE_SET_PROTOTYPE_METHOD(constructor, "scale", Scale);
- NODE_SET_PROTOTYPE_METHOD(constructor, "clip", Clip);
- NODE_SET_PROTOTYPE_METHOD(constructor, "fill", Fill);
- NODE_SET_PROTOTYPE_METHOD(constructor, "stroke", Stroke);
- NODE_SET_PROTOTYPE_METHOD(constructor, "fillText", FillText);
- NODE_SET_PROTOTYPE_METHOD(constructor, "strokeText", StrokeText);
- NODE_SET_PROTOTYPE_METHOD(constructor, "fillRect", FillRect);
- NODE_SET_PROTOTYPE_METHOD(constructor, "strokeRect", StrokeRect);
- NODE_SET_PROTOTYPE_METHOD(constructor, "clearRect", ClearRect);
- NODE_SET_PROTOTYPE_METHOD(constructor, "rect", Rect);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setTextBaseline", SetTextBaseline);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setTextAlignment", SetTextAlignment);
- NODE_SET_PROTOTYPE_METHOD(constructor, "measureText", MeasureText);
- NODE_SET_PROTOTYPE_METHOD(constructor, "moveTo", MoveTo);
- NODE_SET_PROTOTYPE_METHOD(constructor, "lineTo", LineTo);
- NODE_SET_PROTOTYPE_METHOD(constructor, "bezierCurveTo", BezierCurveTo);
- NODE_SET_PROTOTYPE_METHOD(constructor, "quadraticCurveTo", QuadraticCurveTo);
- NODE_SET_PROTOTYPE_METHOD(constructor, "beginPath", BeginPath);
- NODE_SET_PROTOTYPE_METHOD(constructor, "closePath", ClosePath);
- NODE_SET_PROTOTYPE_METHOD(constructor, "arc", Arc);
- NODE_SET_PROTOTYPE_METHOD(constructor, "arcTo", ArcTo);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setFont", SetFont);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setFillColor", SetFillColor);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setStrokeColor", SetStrokeColor);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setFillPattern", SetFillPattern);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setStrokePattern", SetStrokePattern);
- proto->SetAccessor(String::NewSymbol("patternQuality"), GetPatternQuality, SetPatternQuality);
- proto->SetAccessor(String::NewSymbol("globalCompositeOperation"), GetGlobalCompositeOperation, SetGlobalCompositeOperation);
- proto->SetAccessor(String::NewSymbol("globalAlpha"), GetGlobalAlpha, SetGlobalAlpha);
- proto->SetAccessor(String::NewSymbol("shadowColor"), GetShadowColor, SetShadowColor);
- proto->SetAccessor(String::NewSymbol("fillColor"), GetFillColor);
- proto->SetAccessor(String::NewSymbol("strokeColor"), GetStrokeColor);
- proto->SetAccessor(String::NewSymbol("miterLimit"), GetMiterLimit, SetMiterLimit);
- proto->SetAccessor(String::NewSymbol("lineWidth"), GetLineWidth, SetLineWidth);
- proto->SetAccessor(String::NewSymbol("lineCap"), GetLineCap, SetLineCap);
- proto->SetAccessor(String::NewSymbol("lineJoin"), GetLineJoin, SetLineJoin);
- proto->SetAccessor(String::NewSymbol("shadowOffsetX"), GetShadowOffsetX, SetShadowOffsetX);
- proto->SetAccessor(String::NewSymbol("shadowOffsetY"), GetShadowOffsetY, SetShadowOffsetY);
- proto->SetAccessor(String::NewSymbol("shadowBlur"), GetShadowBlur, SetShadowBlur);
- proto->SetAccessor(String::NewSymbol("antialias"), GetAntiAlias, SetAntiAlias);
- target->Set(String::NewSymbol("CanvasRenderingContext2d"), constructor->GetFunction());
-}
-
-/*
- * Create a cairo context.
- */
-
-Context2d::Context2d(Canvas *canvas) {
- _canvas = canvas;
- _context = cairo_create(canvas->surface());
- cairo_set_line_width(_context, 1);
- state = states[stateno = 0] = (canvas_state_t *) malloc(sizeof(canvas_state_t));
- state->shadowBlur = 0;
- state->shadowOffsetX = state->shadowOffsetY = 0;
- state->globalAlpha = 1;
- state->textAlignment = -1;
- state->fillPattern = state->strokePattern = NULL;
- state->textBaseline = NULL;
- rgba_t transparent = { 0,0,0,1 };
- rgba_t transparent_black = { 0,0,0,0 };
- state->fill = transparent;
- state->stroke = transparent;
- state->shadow = transparent_black;
- state->patternQuality = CAIRO_FILTER_GOOD;
-}
-
-/*
- * Destroy cairo context.
- */
-
-Context2d::~Context2d() {
- cairo_destroy(_context);
-}
-
-/*
- * Save cairo / canvas state.
- */
-
-void
-Context2d::save() {
- cairo_save(_context);
- saveState();
-}
-
-/*
- * Restore cairo / canvas state.
- */
-
-void
-Context2d::restore() {
- cairo_restore(_context);
- restoreState();
-}
-
-/*
- * Save the current state.
- */
-
-void
-Context2d::saveState() {
- if (stateno == CANVAS_MAX_STATES) return;
- states[++stateno] = (canvas_state_t *) malloc(sizeof(canvas_state_t));
- memcpy(states[stateno], state, sizeof(canvas_state_t));
- state = states[stateno];
-}
-
-/*
- * Restore state.
- */
-
-void
-Context2d::restoreState() {
- if (0 == stateno) return;
- state = states[--stateno];
-}
-
-/*
- * Save flat path.
- */
-
-void
-Context2d::savePath() {
- _path = cairo_copy_path_flat(_context);
- cairo_new_path(_context);
-}
-
-/*
- * Restore flat path.
- */
-
-void
-Context2d::restorePath() {
- cairo_append_path(_context, _path);
-}
-
-/*
- * Fill and apply shadow.
- */
-
-void
-Context2d::fill(bool preserve) {
- if (state->fillPattern) {
- cairo_pattern_set_filter(state->fillPattern, state->patternQuality);
- cairo_set_source(_context, state->fillPattern);
- } else {
- setSourceRGBA(state->fill);
- }
-
- if (preserve) {
- hasShadow()
- ? shadow(cairo_fill_preserve)
- : cairo_fill_preserve(_context);
- } else {
- hasShadow()
- ? shadow(cairo_fill)
- : cairo_fill(_context);
- }
-}
-
-/*
- * Stroke and apply shadow.
- */
-
-void
-Context2d::stroke(bool preserve) {
- if (state->strokePattern) {
- cairo_pattern_set_filter(state->strokePattern, state->patternQuality);
- cairo_set_source(_context, state->fillPattern);
- } else {
- setSourceRGBA(state->stroke);
- }
-
- if (preserve) {
- hasShadow()
- ? shadow(cairo_stroke_preserve)
- : cairo_stroke_preserve(_context);
- } else {
- hasShadow()
- ? shadow(cairo_stroke)
- : cairo_stroke(_context);
- }
-}
-
-/*
- * Apply shadow with the given draw fn.
- */
-
-void
-Context2d::shadow(void (fn)(cairo_t *cr)) {
- cairo_path_t *path = cairo_copy_path_flat(_context);
- cairo_save(_context);
-
- // Offset
- cairo_translate(
- _context
- , state->shadowOffsetX
- , state->shadowOffsetY);
-
- // Apply shadow
- cairo_push_group(_context);
- cairo_new_path(_context);
- cairo_append_path(_context, path);
- setSourceRGBA(state->shadow);
- fn(_context);
-
- // No need to invoke blur if shadowBlur is 0
- if (state->shadowBlur) {
- blur(cairo_get_group_target(_context), state->shadowBlur);
- }
-
- // Paint the shadow
- cairo_pop_group_to_source(_context);
- cairo_paint(_context);
-
- // Restore state
- cairo_restore(_context);
- cairo_new_path(_context);
- cairo_append_path(_context, path);
- fn(_context);
-
- cairo_path_destroy(path);
-}
-
-/*
- * Set source RGBA.
- */
-
-void
-Context2d::setSourceRGBA(rgba_t color) {
- cairo_set_source_rgba(
- _context
- , color.r
- , color.g
- , color.b
- , color.a * state->globalAlpha);
-}
-
-/*
- * Check if the context has a drawable shadow.
- */
-
-bool
-Context2d::hasShadow() {
- return state->shadow.a
- && (state->shadowBlur || state->shadowOffsetX || state->shadowOffsetX);
-}
-
-/*
- * Blur the given surface with the given radius.
- */
-
-void
-Context2d::blur(cairo_surface_t *surface, int radius) {
- // Steve Hanov, 2009
- // Released into the public domain.
- --radius;
- // get width, height
- int width = cairo_image_surface_get_width( surface );
- int height = cairo_image_surface_get_height( surface );
- unsigned* precalc =
- (unsigned*)malloc(width*height*sizeof(unsigned));
- unsigned char* src = cairo_image_surface_get_data( surface );
- double mul=1.f/((radius*2)*(radius*2));
- int channel;
-
- // The number of times to perform the averaging. According to wikipedia,
- // three iterations is good enough to pass for a gaussian.
- const int MAX_ITERATIONS = 3;
- int iteration;
-
- for ( iteration = 0; iteration < MAX_ITERATIONS; iteration++ ) {
- for( channel = 0; channel < 4; channel++ ) {
- int x,y;
-
- // precomputation step.
- unsigned char* pix = src;
- unsigned* pre = precalc;
-
- pix += channel;
- for (y=0;y<height;y++) {
- for (x=0;x<width;x++) {
- int tot=pix[0];
- if (x>0) tot+=pre[-1];
- if (y>0) tot+=pre[-width];
- if (x>0 && y>0) tot-=pre[-width-1];
- *pre++=tot;
- pix += 4;
- }
- }
-
- // blur step.
- pix = src + (int)radius * width * 4 + (int)radius * 4 + channel;
- for (y=radius;y<height-radius;y++) {
- for (x=radius;x<width-radius;x++) {
- int l = x < radius ? 0 : x - radius;
- int t = y < radius ? 0 : y - radius;
- int r = x + radius >= width ? width - 1 : x + radius;
- int b = y + radius >= height ? height - 1 : y + radius;
- int tot = precalc[r+b*width] + precalc[l+t*width] -
- precalc[l+b*width] - precalc[r+t*width];
- *pix=(unsigned char)(tot*mul);
- pix += 4;
- }
- pix += (int)radius * 2 * 4;
- }
- }
- }
- free( precalc );
-}
-
-/*
- * Initialize a new Context2d with the given canvas.
- */
-
-Handle<Value>
-Context2d::New(const Arguments &args) {
- HandleScope scope;
- Local<Object> obj = args[0]->ToObject();
- if (!Canvas::constructor->HasInstance(obj))
- return ThrowException(Exception::TypeError(String::New("Canvas expected")));
- Canvas *canvas = ObjectWrap::Unwrap<Canvas>(obj);
- Context2d *context = new Context2d(canvas);
- context->Wrap(args.This());
- return args.This();
-}
-
-/*
- * Put image data.
- *
- * - imageData, dx, dy
- * - imageData, dx, dy, sx, sy, sw, sh
- *
- */
-
-Handle<Value>
-Context2d::PutImageData(const Arguments &args) {
- HandleScope scope;
-
- Local<Object> obj = args[0]->ToObject();
- if (!ImageData::constructor->HasInstance(obj))
- return ThrowException(Exception::TypeError(String::New("ImageData expected")));
-
- Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
- ImageData *imageData = ObjectWrap::Unwrap<ImageData>(obj);
- PixelArray *arr = imageData->pixelArray();
-
- uint8_t *src = arr->data();
- uint8_t *dst = context->canvas()->data();
-
- int srcStride = arr->stride()
- , dstStride = context->canvas()->stride();
-
- int sx = 0
- , sy = 0
- , sw = 0
- , sh = 0
- , dx = args[1]->Int32Value()
- , dy = args[2]->Int32Value()
- , rows
- , cols;
-
- switch (args.Length()) {
- // imageData, dx, dy
- case 3:
- cols = arr->width();
- rows = arr->height();
- break;
- // imageData, dx, dy, sx, sy, sw, sh
- case 7:
- sx = args[3]->Int32Value();
- sy = args[4]->Int32Value();
- sw = args[5]->Int32Value();
- sh = args[6]->Int32Value();
- if (sx < 0) sw += sx, sx = 0;
- if (sy < 0) sh += sy, sy = 0;
- if (sx + sw > arr->width()) sw = arr->width() - sx;
- if (sy + sh > arr->height()) sh = arr->height() - sy;
- if (sw <= 0 || sh <= 0) return Undefined();
- cols = sw;
- rows = sh;
- dx += sx;
- dy += sy;
- break;
- default:
- return ThrowException(Exception::Error(String::New("invalid arguments")));
- }
-
- uint8_t *srcRows = src + sy * srcStride + sx * 4;
- for (int y = 0; y < rows; ++y) {
- uint32_t *row = (uint32_t *)(dst + dstStride * (y + dy));
- for (int x = 0; x < cols; ++x) {
- int bx = x * 4;
- uint32_t *pixel = row + x + dx;
-
- // RGBA
- uint8_t a = srcRows[bx + 3];
- uint8_t r = srcRows[bx + 0];
- uint8_t g = srcRows[bx + 1];
- uint8_t b = srcRows[bx + 2];
- float alpha = (float) a / 255;
-
- // ARGB
- *pixel = a << 24
- | (int)((float) r * alpha) << 16
- | (int)((float) g * alpha) << 8
- | (int)((float) b * alpha);
- }
- srcRows += srcStride;
- }
-
- cairo_surface_mark_dirty_rectangle(
- context->canvas()->surface()
- , dx
- , dy
- , cols
- , rows);
-
- return Undefined();
-}
-
-/*
- * Draw image src image to the destination (context).
- *
- * - dx, dy
- * - dx, dy, dw, dh
- * - sx, sy, sw, sh, dx, dy, dw, dh
- *
- */
-
-Handle<Value>
-Context2d::DrawImage(const Arguments &args) {
- HandleScope scope;
-
- if (args.Length() < 3)
- return ThrowException(Exception::TypeError(String::New("invalid arguments")));
-
-#if CAIRO_VERSION_MINOR < 10
- return ThrowException(Exception::Error(String::New("drawImage() needs cairo >= 1.10.0")));
-#else
-
- int sx = 0
- , sy = 0
- , sw = 0
- , sh = 0
- , dx, dy, dw, dh;
-
- cairo_surface_t *surface;
-
- Local<Object> obj = args[0]->ToObject();
-
- // Image
- if (Image::constructor->HasInstance(obj)) {
- Image *img = ObjectWrap::Unwrap<Image>(obj);
- sw = img->width;
- sh = img->height;
- surface = img->surface();
-
- // Canvas
- } else if (Canvas::constructor->HasInstance(obj)) {
- Canvas *canvas = ObjectWrap::Unwrap<Canvas>(obj);
- sw = canvas->width;
- sh = canvas->height;
- surface = canvas->surface();
-
- // Invalid
- } else {
- return ThrowException(Exception::TypeError(String::New("Image or Canvas expected")));
- }
-
- Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
- cairo_t *ctx = context->context();
-
- // Arguments
- switch (args.Length()) {
- // img, sx, sy, sw, sh, dx, dy, dw, dh
- case 9:
- sx = args[1]->Int32Value();
- sy = args[2]->Int32Value();
- sw = args[3]->Int32Value();
- sh = args[4]->Int32Value();
- dx = args[5]->Int32Value();
- dy = args[6]->Int32Value();
- dw = args[7]->Int32Value();
- dh = args[8]->Int32Value();
- break;
- // img, dx, dy, dw, dh
- case 5:
- dx = args[1]->Int32Value();
- dy = args[2]->Int32Value();
- dw = args[3]->Int32Value();
- dh = args[4]->Int32Value();
- break;
- // img, dx, dy
- case 3:
- dx = args[1]->Int32Value();
- dy = args[2]->Int32Value();
- dw = sw;
- dh = sh;
- break;
- default:
- return ThrowException(Exception::TypeError(String::New("invalid arguments")));
- }
-
- // Start draw
- cairo_save(ctx);
-
- // Source surface
- // TODO: only works with cairo >= 1.10.0
- cairo_surface_t *src = cairo_surface_create_for_rectangle(
- surface
- , sx
- , sy
- , sw
- , sh);
-
- // Scale src
- if (dw != sw || dh != sh) {
- float fx = (float) dw / sw;
- float fy = (float) dh / sh;
- cairo_scale(ctx, fx, fy);
- dx /= fx;
- dy /= fy;
- }
-
- // Paint
- cairo_set_source_surface(ctx, src, dx, dy);
- cairo_pattern_set_filter(cairo_get_source(ctx), context->state->patternQuality);
- cairo_paint_with_alpha(ctx, context->state->globalAlpha);
-
- cairo_restore(ctx);
- cairo_surface_destroy(src);
-
-#endif
-
- return Undefined();
-}
-
-/*
- * Get global alpha.
- */
-
-Handle<Value>
-Context2d::GetGlobalAlpha(Local<String> prop, const AccessorInfo &info) {
- Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
- return Number::New(context->state->globalAlpha);
-}
-
-/*
- * Set global alpha.
- */
-
-void
-Context2d::SetGlobalAlpha(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
- double n = val->NumberValue();
- if (n >= 0 && n <= 1) {
- Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
- context->state->globalAlpha = n;
- }
-}
-
-/*
- * Get global composite operation.
- */
-
-Handle<Value>
-Context2d::GetGlobalCompositeOperation(Local<String> prop, const AccessorInfo &info) {
- Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
- cairo_t *ctx = context->context();
- switch (cairo_get_operator(ctx)) {
- case CAIRO_OPERATOR_ATOP:
- return String::NewSymbol("source-atop");
- case CAIRO_OPERATOR_IN:
- return String::NewSymbol("source-in");
- case CAIRO_OPERATOR_OUT:
- return String::NewSymbol("source-out");
- case CAIRO_OPERATOR_XOR:
- return String::NewSymbol("xor");
- case CAIRO_OPERATOR_DEST_ATOP:
- return String::NewSymbol("destination-atop");
- case CAIRO_OPERATOR_DEST_IN:
- return String::NewSymbol("destination-in");
- case CAIRO_OPERATOR_DEST_OUT:
- return String::NewSymbol("destination-out");
- case CAIRO_OPERATOR_DEST_OVER:
- return String::NewSymbol("destination-over");
- case CAIRO_OPERATOR_ADD: