Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

canvas

Package Overview
Dependencies
Maintainers
1
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas - npm Package Compare versions

Comparing version 0.8.3 to 0.9.0

examples/crop.jpg

5

History.md
0.9.0 / 2012-01-13
==================
* Added `createJPEGStream()` [Elijah Hamovitz]
0.8.3 / 2012-01-04

@@ -3,0 +8,0 @@ ==================

32

lib/canvas.js

@@ -19,2 +19,3 @@

, PNGStream = require('./pngstream')
, JPEGStream = require('./jpegstream')
, fs = require('fs');

@@ -32,3 +33,3 @@

exports.version = '0.8.3';
exports.version = '0.9.0';

@@ -47,2 +48,3 @@ /**

exports.PNGStream = PNGStream;
exports.JPEGStream = JPEGStream;
exports.PixelArray = PixelArray;

@@ -120,2 +122,30 @@ exports.Image = Image;

/**
* Create a `JPEGStream` for `this` canvas.
*
* @param {Object} options
* @return {JPEGStream}
* @api public
*/
Canvas.prototype.createJPEGStream = function(options){
return this.createSyncJPEGStream(options);
};
/**
* Create a synchronous `JPEGStream` for `this` canvas.
*
* @param {Object} options
* @return {JPEGStream}
* @api public
*/
Canvas.prototype.createSyncJPEGStream = function(options){
options = options || {};
return new JPEGStream(this, {
bufsize: options.bufsize || 4096
, quality: options.quality || 75
});
};
/**
* Return a data url. Pass a function for async support.

@@ -122,0 +152,0 @@ *

6

lib/context2d.js

@@ -153,3 +153,3 @@

Context2d.prototype.__defineSetter__('fillStyle', function(val){
if (val instanceof CanvasGradient) {
if ('CanvasGradient' == val.constructor.name) {
this.lastFillStyle = val;

@@ -180,3 +180,3 @@ this._setFillPattern(val);

Context2d.prototype.__defineSetter__('strokeStyle', function(val){
if (val instanceof CanvasGradient) {
if ('CanvasGradient' == val.constructor.name) {
this.lastStrokeStyle = val;

@@ -320,3 +320,3 @@ this._setStrokePattern(val);

Context2d.prototype.createImageData = function(width, height){
if (width instanceof ImageData) {
if ('ImageData' == width.constructor.name) {
height = width.height;

@@ -323,0 +323,0 @@ width = width.width;

@@ -24,10 +24,4 @@

*
* stream.on('data', function(chunk){
* out.write(chunk);
* });
* stream.pipe(out);
*
* stream.on('end', function(){
* out.end();
* });
*
* @param {Canvas} canvas

@@ -34,0 +28,0 @@ * @param {Boolean} sync

{ "name": "canvas"
, "description": "Canvas graphics API backed by Cairo"
, "version": "0.8.3"
, "version": "0.9.0"
, "author": "TJ Holowaychuk <tj@learnboost.com>"

@@ -13,4 +13,5 @@ , "keywords": ["canvas", "graphic", "graphics", "pixman", "cairo", "image", "images"]

"express": "2.3.7"
, "expresso": "0.7.6"
, "jade": "0.11.0"
, "mocha": "*"
, "should": "*"
}

@@ -17,0 +18,0 @@ , "engines": { "node": ">= 0.4.0 && < 0.7.0" }

@@ -69,3 +69,3 @@ # node-canvas

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.
To create a `PNGStream` simply 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.

@@ -88,2 +88,6 @@ ```javascript

### Canvas#createJPEGStream()
You can likewise create a `JPEGStream` by calling `canvas.createJPEGStream()` with some optional parameters; functionality is otherwise identical to `createPNGStream()`. See `examples/crop.js` for an example.
### Canvas#toBuffer()

@@ -90,0 +94,0 @@

@@ -6,7 +6,6 @@

var Canvas = require('canvas')
var Canvas = require('../')
, assert = require('assert')
, parseFont = Canvas.Context2d.parseFont
, assert = require('assert')
, sys = require('sys')
, fs = require('fs');

@@ -20,7 +19,7 @@

'test .version': function(){
assert.match(Canvas.version, /^\d+\.\d+\.\d+$/);
Canvas.version.should.match(/^\d+\.\d+\.\d+$/);
},
'test .cairoVersion': function(){
assert.match(Canvas.cairoVersion, /^\d+\.\d+\.\d+$/);
Canvas.cairoVersion.should.match(/^\d+\.\d+\.\d+$/);
},

@@ -77,9 +76,6 @@

, obj = tests[i]
, got = parseFont(str);
, actual = parseFont(str);
if (!obj.style) obj.style = 'normal';
if (!obj.weight) obj.weight = 'normal';
assert.eql(obj, got, ''
+ '\n from: ' + sys.inspect(str)
+ '\n got:\n' + sys.inspect(got)
+ '\n expected:\n' + sys.inspect(obj));
actual.should.eql(obj);
}

@@ -86,0 +82,0 @@ },

@@ -6,3 +6,3 @@

var Canvas = require('canvas')
var Canvas = require('../')
, Image = Canvas.Image

@@ -18,3 +18,3 @@ , assert = require('assert');

'test Image#onload': function(beforeExit){
'test Image#onload': function(){
var img = new Image

@@ -32,12 +32,10 @@ , n = 0;

beforeExit(function(){
assert.equal(img.src, png);
assert.strictEqual(true, img.complete);
assert.strictEqual(320, img.width);
assert.strictEqual(320, img.height);
assert.equal(1, n);
});
assert.equal(img.src, png);
assert.strictEqual(true, img.complete);
assert.strictEqual(320, img.width);
assert.strictEqual(320, img.height);
assert.equal(1, n);
},
'test Image#onerror': function(beforeExit){
'test Image#onerror': function(){
var img = new Image

@@ -65,10 +63,8 @@ , error

beforeExit(function(){
assert.ok(error instanceof Error, 'did not invoke onerror() with error');
assert.strictEqual(false, img.complete);
assert.equal(1, n);
});
assert.ok(error instanceof Error, 'did not invoke onerror() with error');
assert.strictEqual(false, img.complete);
assert.equal(1, n);
},
'test Image#{width,height}': function(beforeExit){
'test Image#{width,height}': function(){
var img = new Image

@@ -86,6 +82,4 @@ , n = 0;

beforeExit(function(){
assert.equal(1, n);
});
assert.equal(1, n);
}
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc