Closes #51 again. Fix background scaling in toDataURLWithMultiplier.

This commit is contained in:
kangax 2011-09-07 16:30:25 -04:00
parent 952a31262e
commit 5dc7220425
4 changed files with 25 additions and 31 deletions

View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.5.8" };
var fabric = fabric || { version: "0.5.9" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;

27
dist/all.js vendored
View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.5.8" };
var fabric = fabric || { version: "0.5.9" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;
@ -5695,27 +5695,24 @@ fabric.util.string = {
scaledHeight = origHeight * multiplier,
activeObject = this.getActiveObject();
if (multiplier > 1) {
// we're only changing canvas dimensions when retrieving _enlarged_ version of data url,
// since canvas element needs to accomodate increased dimensions
// when multiplier is <=1 canvas dimensions stay the same (and only context scaling changes)
this.setWidth(scaledWidth).setHeight(scaledHeight);
}
this.setWidth(scaledWidth).setHeight(scaledHeight);
this.contextTop.scale(multiplier, multiplier);
this.renderAll(true);
if (activeObject) {
this.deactivateAll().renderAll();
this.deactivateAll();
}
// restoring width, height for `renderAll` to draw
// background properly (while context is scaled)
this.width = origWidth;
this.height = origHeight;
this.renderAll(true);
var dataURL = this.toDataURL(format);
this.contextTop.scale( 1 / multiplier, 1 / multiplier);
if (multiplier > 1) {
this.setWidth(origWidth).setHeight(origHeight);
}
this.contextTop.scale(1 / multiplier, 1 / multiplier);
this.setWidth(origWidth).setHeight(origHeight);
if (activeObject) {
this.setActiveObject(activeObject);

View file

@ -1,7 +1,7 @@
{
"name": "fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"version": "0.5.8",
"version": "0.5.9",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
"repository": "git://github.com/kangax/fabric.js",

View file

@ -1440,27 +1440,24 @@
scaledHeight = origHeight * multiplier,
activeObject = this.getActiveObject();
if (multiplier > 1) {
// we're only changing canvas dimensions when retrieving _enlarged_ version of data url,
// since canvas element needs to accomodate increased dimensions
// when multiplier is <=1 canvas dimensions stay the same (and only context scaling changes)
this.setWidth(scaledWidth).setHeight(scaledHeight);
}
this.setWidth(scaledWidth).setHeight(scaledHeight);
this.contextTop.scale(multiplier, multiplier);
this.renderAll(true);
if (activeObject) {
this.deactivateAll().renderAll();
this.deactivateAll();
}
// restoring width, height for `renderAll` to draw
// background properly (while context is scaled)
this.width = origWidth;
this.height = origHeight;
this.renderAll(true);
var dataURL = this.toDataURL(format);
this.contextTop.scale( 1 / multiplier, 1 / multiplier);
if (multiplier > 1) {
this.setWidth(origWidth).setHeight(origHeight);
}
this.contextTop.scale(1 / multiplier, 1 / multiplier);
this.setWidth(origWidth).setHeight(origHeight);
if (activeObject) {
this.setActiveObject(activeObject);