diff --git a/HEADER.js b/HEADER.js index 24a98105..32a5c94b 100644 --- a/HEADER.js +++ b/HEADER.js @@ -1,4 +1,4 @@ -/*! Fabric.js Copyright 2008-2014, Printio (Juriy Zaytsev, Maxim Chernyak) */ +/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ var fabric = fabric || { version: "1.4.13" }; if (typeof exports !== 'undefined') { diff --git a/LICENSE b/LICENSE index efa45ab9..adb89c4a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2008-2014 Printio (Juriy Zaytsev, Maxim Chernyak) +Copyright (c) 2008-2015 Printio (Juriy Zaytsev, Maxim Chernyak) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 79d10c21..af928550 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,7 @@ Get help in Fabric's IRC channel — irc://irc.freenode.net/#fabric.js ### MIT License -Copyright (c) 2008-2014 Printio (Juriy Zaytsev, Maxim Chernyak) +Copyright (c) 2008-2015 Printio (Juriy Zaytsev, Maxim Chernyak) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/dist/fabric.js b/dist/fabric.js index 36f2d373..6502b2fb 100644 --- a/dist/fabric.js +++ b/dist/fabric.js @@ -1,5 +1,5 @@ /* build: `node build.js modules=ALL exclude=gestures,cufon,json minifier=uglifyjs` */ -/*! Fabric.js Copyright 2008-2014, Printio (Juriy Zaytsev, Maxim Chernyak) */ +/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ var fabric = fabric || { version: "1.4.13" }; if (typeof exports !== 'undefined') { @@ -9,6 +9,8 @@ if (typeof exports !== 'undefined') { if (typeof document !== 'undefined' && typeof window !== 'undefined') { fabric.document = document; fabric.window = window; + // ensure globality even if entire library were function wrapped (as in Meteor.js packaging system) + window.fabric = fabric; } else { // assume we're running under node.js when document/window are not present @@ -9116,12 +9118,12 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab addListener(this.upperCanvasEl, 'touchstart', this._onMouseDown); addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove); - if (typeof Event !== 'undefined' && 'add' in Event) { - Event.add(this.upperCanvasEl, 'gesture', this._onGesture); - Event.add(this.upperCanvasEl, 'drag', this._onDrag); - Event.add(this.upperCanvasEl, 'orientation', this._onOrientationChange); - Event.add(this.upperCanvasEl, 'shake', this._onShake); - Event.add(this.upperCanvasEl, 'longpress', this._onLongPress); + if (typeof eventjs !== 'undefined' && 'add' in eventjs) { + eventjs.add(this.upperCanvasEl, 'gesture', this._onGesture); + eventjs.add(this.upperCanvasEl, 'drag', this._onDrag); + eventjs.add(this.upperCanvasEl, 'orientation', this._onOrientationChange); + eventjs.add(this.upperCanvasEl, 'shake', this._onShake); + eventjs.add(this.upperCanvasEl, 'longpress', this._onLongPress); } }, @@ -9154,12 +9156,12 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab removeListener(this.upperCanvasEl, 'touchstart', this._onMouseDown); removeListener(this.upperCanvasEl, 'touchmove', this._onMouseMove); - if (typeof Event !== 'undefined' && 'remove' in Event) { - Event.remove(this.upperCanvasEl, 'gesture', this._onGesture); - Event.remove(this.upperCanvasEl, 'drag', this._onDrag); - Event.remove(this.upperCanvasEl, 'orientation', this._onOrientationChange); - Event.remove(this.upperCanvasEl, 'shake', this._onShake); - Event.remove(this.upperCanvasEl, 'longpress', this._onLongPress); + if (typeof eventjs !== 'undefined' && 'remove' in eventjs) { + eventjs.remove(this.upperCanvasEl, 'gesture', this._onGesture); + eventjs.remove(this.upperCanvasEl, 'drag', this._onDrag); + eventjs.remove(this.upperCanvasEl, 'orientation', this._onOrientationChange); + eventjs.remove(this.upperCanvasEl, 'shake', this._onShake); + eventjs.remove(this.upperCanvasEl, 'longpress', this._onLongPress); } }, @@ -11648,7 +11650,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati el.height = boundingRect.height; fabric.util.wrapElement(el, 'div'); - var canvas = new fabric.Canvas(el); + var canvas = new fabric.StaticCanvas(el); // to avoid common confusion https://github.com/kangax/fabric.js/issues/806 if (options.format === 'jpg') { @@ -15360,8 +15362,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot controlY = 0, // current control point y tempX, tempY, - tempControlX, - tempControlY, l = -this.pathOffset.x, t = -this.pathOffset.y; @@ -15464,9 +15464,17 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot tempX = x + current[3]; tempY = y + current[4]; - // calculate reflection of previous control points - controlX = controlX ? (2 * x - controlX) : x; - controlY = controlY ? (2 * y - controlY) : y; + if (previous[0].match(/[CcSs]/) === null) { + // If there is no previous command or if the previous command was not a C, c, S, or s, + // the control point is coincident with the current point + controlX = x; + controlY = y; + } + else { + // calculate reflection of previous control points + controlX = 2 * x - controlX; + controlY = 2 * y - controlY; + } ctx.bezierCurveTo( controlX + l, @@ -15490,9 +15498,17 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot case 'S': // shorthand cubic bezierCurveTo, absolute tempX = current[3]; tempY = current[4]; - // calculate reflection of previous control points - controlX = 2 * x - controlX; - controlY = 2 * y - controlY; + if (previous[0].match(/[CcSs]/) === null) { + // If there is no previous command or if the previous command was not a C, c, S, or s, + // the control point is coincident with the current point + controlX = x; + controlY = y; + } + else { + // calculate reflection of previous control points + controlX = 2 * x - controlX; + controlY = 2 * y - controlY; + } ctx.bezierCurveTo( controlX + l, controlY + t, @@ -15559,20 +15575,12 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot controlX = x; controlY = y; } - else if (previous[0] === 't') { - // calculate reflection of previous control points for t - controlX = 2 * x - tempControlX; - controlY = 2 * y - tempControlY; - } - else if (previous[0] === 'q') { - // calculate reflection of previous control points for q + else { + // calculate reflection of previous control point controlX = 2 * x - controlX; controlY = 2 * y - controlY; } - tempControlX = controlX; - tempControlY = controlY; - ctx.quadraticCurveTo( controlX + l, controlY + t, @@ -15581,17 +15589,24 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot ); x = tempX; y = tempY; - controlX = x + current[1]; - controlY = y + current[2]; + break; case 'T': tempX = current[1]; tempY = current[2]; - // calculate reflection of previous control points - controlX = 2 * x - controlX; - controlY = 2 * y - controlY; + if (previous[0].match(/[QqTt]/) === null) { + // If there is no previous command or if the previous command was not a Q, q, T or t, + // assume the control point is coincident with the current point + controlX = x; + controlY = y; + } + else { + // calculate reflection of previous control point + controlX = 2 * x - controlX; + controlY = 2 * y - controlY; + } ctx.quadraticCurveTo( controlX + l, controlY + t, @@ -15829,8 +15844,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot controlY = 0, // current control point y tempX, tempY, - tempControlX, - tempControlY, bounds; for (var i = 0, len = this.path.length; i < len; ++i) { @@ -15925,9 +15938,17 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot tempX = x + current[3]; tempY = y + current[4]; - // calculate reflection of previous control points - controlX = controlX ? (2 * x - controlX) : x; - controlY = controlY ? (2 * y - controlY) : y; + if (previous[0].match(/[CcSs]/) === null) { + // If there is no previous command or if the previous command was not a C, c, S, or s, + // the control point is coincident with the current point + controlX = x; + controlY = y; + } + else { + // calculate reflection of previous control points + controlX = 2 * x - controlX; + controlY = 2 * y - controlY; + } bounds = fabric.util.getBoundsOfCurve(x, y, controlX, @@ -15950,9 +15971,17 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot case 'S': // shorthand cubic bezierCurveTo, absolute tempX = current[3]; tempY = current[4]; - // calculate reflection of previous control points - controlX = 2 * x - controlX; - controlY = 2 * y - controlY; + if (previous[0].match(/[CcSs]/) === null) { + // If there is no previous command or if the previous command was not a C, c, S, or s, + // the control point is coincident with the current point + controlX = x; + controlY = y; + } + else { + // calculate reflection of previous control points + controlX = 2 * x - controlX; + controlY = 2 * y - controlY; + } bounds = fabric.util.getBoundsOfCurve(x, y, controlX, controlY, @@ -16014,20 +16043,12 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot controlX = x; controlY = y; } - else if (previous[0] === 't') { - // calculate reflection of previous control points for t - controlX = 2 * x - tempControlX; - controlY = 2 * y - tempControlY; - } - else if (previous[0] === 'q') { - // calculate reflection of previous control points for q + else { + // calculate reflection of previous control point controlX = 2 * x - controlX; controlY = 2 * y - controlY; } - tempControlX = controlX; - tempControlY = controlY; - bounds = fabric.util.getBoundsOfCurve(x, y, controlX, controlY, @@ -16038,16 +16059,24 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot ); x = tempX; y = tempY; - controlX = x + current[1]; - controlY = y + current[2]; + break; case 'T': tempX = current[1]; tempY = current[2]; - // calculate reflection of previous control points - controlX = 2 * x - controlX; - controlY = 2 * y - controlY; + + if (previous[0].match(/[QqTt]/) === null) { + // If there is no previous command or if the previous command was not a Q, q, T or t, + // assume the control point is coincident with the current point + controlX = x; + controlY = y; + } + else { + // calculate reflection of previous control point + controlX = 2 * x - controlX; + controlY = 2 * y - controlY; + } bounds = fabric.util.getBoundsOfCurve(x, y, controlX, controlY, diff --git a/dist/fabric.min.js b/dist/fabric.min.js index dbcd34b8..00a17219 100644 --- a/dist/fabric.min.js +++ b/dist/fabric.min.js @@ -1,8 +1,8 @@ -/* build: `node build.js modules=ALL exclude=gestures,cufon,json minifier=uglifyjs` *//*! Fabric.js Copyright 2008-2014, Printio (Juriy Zaytsev, Maxim Chernyak) */var fabric=fabric||{version:"1.4.13"};typeof exports!="undefined"&&(exports.fabric=fabric),typeof document!="undefined"&&typeof window!="undefined"?(fabric.document=document,fabric.window=window):(fabric.document=require("jsdom").jsdom("
"),fabric.document.createWindow?fabric.window=fabric.document.createWindow():fabric.window=fabric.document.parentWindow),fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement,fabric.isLikelyNode=typeof Buffer!="undefined"&&typeof window=="undefined",fabric.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width"],fabric.DPI=96,fabric.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)",function(){function e(e,t){if(!this.__eventListeners[e])return;t?fabric.util.removeFromArray(this.__eventListeners[e],t):this.__eventListeners[e].length=0}function t(e,t){this.__eventListeners||(this.__eventListeners={});if(arguments.length===1)for(var n in e)this.on(n,e[n]);else this.__eventListeners[e]||(this.__eventListeners[e]=[]),this.__eventListeners[e].push(t);return this}function n(t,n){if(!this.__eventListeners)return;if(arguments.length===0)this.__eventListeners={};else if(arguments.length===1&&typeof arguments[0]=="object")for(var r in t)e.call(this,r,t[r]);else e.call(this,t,n);return this}function r(e,t){if(!this.__eventListeners)return;var n=this.__eventListeners[e];if(!n)return;for(var r=0,i=n.length;r-1},complexity:function(){return this.getObjects().reduce(function(e,t){return e+=t.complexity?t.complexity():0,e},0)}},function(e){var t=Math.sqrt,n=Math.atan2,r=Math.PI/180;fabric.util={removeFromArray:function(e,t){var n=e.indexOf(t);return n!==-1&&e.splice(n,1),e},getRandomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e},degreesToRadians:function(e){return e*r},radiansToDegrees:function(e){return e/r},rotatePoint:function(e,t,n){var r=Math.sin(n),i=Math.cos(n);e.subtractEquals(t);var s=e.x*i-e.y*r,o=e.x*r+e.y*i;return(new fabric.Point(s,o)).addEquals(t)},transformPoint:function(e,t,n){return n?new fabric.Point(t[0]*e.x+t[1]*e.y,t[2]*e.x+t[3]*e.y):new fabric.Point(t[0]*e.x+t[1]*e.y+t[4],t[2]*e.x+t[3]*e.y+t[5])},invertTransform:function(e){var t=e.slice(),n=1/(e[0]*e[3]-e[1]*e[2]);t=[n*e[3],-n*e[1],-n*e[2],n*e[0],0,0];var r=fabric.util.transformPoint({x:e[4],y:e[5]},t);return t[4]=-r.x,t[5]=-r.y,t},toFixed:function(e,t){return parseFloat(Number(e).toFixed(t))},parseUnit:function(e,t){var n=/\D{0,2}$/.exec(e),r=parseFloat(e);t||(t=fabric.Text.DEFAULT_SVG_FONT_SIZE);switch(n[0]){case"mm":return r*fabric.DPI/25.4;case"cm":return r*fabric.DPI/2.54;case"in":return r*fabric.DPI;case"pt":return r*fabric.DPI/72;case"pc":return r*fabric.DPI/72*12;case"em":return r*t;default:return r}},falseFunction:function(){return!1},getKlass:function(e,t){return e=fabric.util.string.camelize(e.charAt(0).toUpperCase()+e.slice(1)),fabric.util.resolveNamespace(t)[e]},resolveNamespace:function(t){if(!t)return fabric;var n=t.split("."),r=n.length,i=e||fabric.window;for(var s=0;s