diff --git a/HEADER.js b/HEADER.js index df2d95e8..d5a9c8ef 100644 --- a/HEADER.js +++ b/HEADER.js @@ -1,6 +1,6 @@ /*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */ -var fabric = fabric || { version: "1.1.19" }; +var fabric = fabric || { version: "1.1.20" }; if (typeof exports !== 'undefined') { exports.fabric = fabric; diff --git a/dist/all.js b/dist/all.js index 5a62f7a5..095a746e 100644 --- a/dist/all.js +++ b/dist/all.js @@ -1,7 +1,7 @@ /* build: `node build.js modules=ALL exclude=gestures` */ /*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */ -var fabric = fabric || { version: "1.1.19" }; +var fabric = fabric || { version: "1.1.20" }; if (typeof exports !== 'undefined') { exports.fabric = fabric; @@ -9171,15 +9171,25 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab (function(){ - var cursorMap = { - 'tr': 'ne-resize', - 'br': 'se-resize', - 'bl': 'sw-resize', - 'tl': 'nw-resize', - 'ml': 'w-resize', - 'mt': 'n-resize', - 'mr': 'e-resize', - 'mb': 's-resize' + var cursorMap = [ + 'n-resize', + 'ne-resize', + 'e-resize', + 'se-resize', + 's-resize', + 'sw-resize', + 'w-resize', + 'nw-resize' + ], + cursorOffset = { + 'mt': 0, // n + 'tr': 1, // ne + 'mr': 2, // e + 'br': 3, // se + 'mb': 4, // s + 'bl': 5, // sw + 'ml': 6, // w + 'tl': 7 // nw }, addListener = fabric.util.addListener, removeListener = fabric.util.removeListener, @@ -9571,8 +9581,15 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab s.cursor = this.hoverCursor; } else { - if (corner in cursorMap) { - s.cursor = cursorMap[corner]; + if (corner in cursorOffset) { + var n = Math.round((target.getAngle() % 360) / 45); + if (n<0) { + n += 8; // full circle ahead + } + n += cursorOffset[corner]; + // normalize n to be from 0 to 7 + n %= 8; + s.cursor = cursorMap[n]; } else if (corner === 'mtr' && target.hasRotatingPoint) { s.cursor = this.rotationCursor; @@ -12191,7 +12208,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot var size = this.cornerSize, size2 = size / 2, - strokeWidth2 = this.strokeWidth / 2, + strokeWidth2 = this.strokeWidth > 1 ? (this.strokeWidth / 2) : 0, left = -(this.width / 2), top = -(this.height / 2), _left, @@ -12207,6 +12224,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot height = this.height, width = this.width, methodName = this.transparentCorners ? 'strokeRect' : 'fillRect', + transparent = this.transparentCorners, isVML = typeof G_vmlCanvasManager !== 'undefined'; ctx.save(); @@ -12220,28 +12238,28 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot _left = left - scaleOffsetX - strokeWidth2 - paddingX; _top = top - scaleOffsetY - strokeWidth2 - paddingY; - isVML || ctx.clearRect(_left, _top, sizeX, sizeY); + isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY); ctx[methodName](_left, _top, sizeX, sizeY); // top-right _left = left + width - scaleOffsetX + strokeWidth2 + paddingX; _top = top - scaleOffsetY - strokeWidth2 - paddingY; - isVML || ctx.clearRect(_left, _top, sizeX, sizeY); + isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY); ctx[methodName](_left, _top, sizeX, sizeY); // bottom-left _left = left - scaleOffsetX - strokeWidth2 - paddingX; _top = top + height + scaleOffsetSizeY + strokeWidth2 + paddingY; - isVML || ctx.clearRect(_left, _top, sizeX, sizeY); + isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY); ctx[methodName](_left, _top, sizeX, sizeY); // bottom-right _left = left + width + scaleOffsetSizeX + strokeWidth2 + paddingX; _top = top + height + scaleOffsetSizeY + strokeWidth2 + paddingY; - isVML || ctx.clearRect(_left, _top, sizeX, sizeY); + isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY); ctx[methodName](_left, _top, sizeX, sizeY); if (!this.get('lockUniScaling')) { @@ -12249,28 +12267,28 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot _left = left + width/2 - scaleOffsetX; _top = top - scaleOffsetY - strokeWidth2 - paddingY; - isVML || ctx.clearRect(_left, _top, sizeX, sizeY); + isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY); ctx[methodName](_left, _top, sizeX, sizeY); // middle-bottom _left = left + width/2 - scaleOffsetX; _top = top + height + scaleOffsetSizeY + strokeWidth2 + paddingY; - isVML || ctx.clearRect(_left, _top, sizeX, sizeY); + isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY); ctx[methodName](_left, _top, sizeX, sizeY); // middle-right _left = left + width + scaleOffsetSizeX + strokeWidth2 + paddingX; _top = top + height/2 - scaleOffsetY; - isVML || ctx.clearRect(_left, _top, sizeX, sizeY); + isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY); ctx[methodName](_left, _top, sizeX, sizeY); // middle-left _left = left - scaleOffsetX - strokeWidth2 - paddingX; _top = top + height/2 - scaleOffsetY; - isVML || ctx.clearRect(_left, _top, sizeX, sizeY); + isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY); ctx[methodName](_left, _top, sizeX, sizeY); } @@ -12282,7 +12300,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot (top + height + (this.rotatingPointOffset / this.scaleY) - sizeY/2 + strokeWidth2 + paddingY) : (top - (this.rotatingPointOffset / this.scaleY) - sizeY/2 - strokeWidth2 - paddingY); - isVML || ctx.clearRect(_left, _top, sizeX, sizeY); + isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY); ctx[methodName](_left, _top, sizeX, sizeY); } @@ -17088,7 +17106,7 @@ fabric.Image.filters.Tint.fromObject = function(object) { */ _getTopOffset: function() { if (fabric.isLikelyNode) { - if (this.originY === 'center' || this.originY === 'top') { + if (this.originY === 'center') { return -this.height / 2; } else if (this.originY === 'bottom') { diff --git a/dist/all.min.js b/dist/all.min.js index cdb63b75..4bf014b3 100644 --- a/dist/all.min.js +++ b/dist/all.min.js @@ -1,6 +1,6 @@ -/* build: `node build.js modules=ALL exclude=gestures` *//*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */var fabric=fabric||{version:"1.1.19"};typeof exports!="undefined"&&(exports.fabric=fabric),typeof document!="undefined"&&typeof window!="undefined"?(fabric.document=document,fabric.window=window):(fabric.document=require("jsdom").jsdom("
"),fabric.window=fabric.document.createWindow()),fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement,fabric.isLikelyNode=typeof Buffer!="undefined"&&typeof window=="undefined";var Cufon=function(){function r(e){var t=this.face=e.face;this.glyphs=e.glyphs,this.w=e.w,this.baseSize=parseInt(t["units-per-em"],10),this.family=t["font-family"].toLowerCase(),this.weight=t["font-weight"],this.style=t["font-style"]||"normal",this.viewBox=function(){var e=t.bbox.split(/\s+/),n={minX:parseInt(e[0],10),minY:parseInt(e[1],10),maxX:parseInt(e[2],10),maxY:parseInt(e[3],10)};return n.width=n.maxX-n.minX,n.height=n.maxY-n.minY,n.toString=function(){return[this.minX,this.minY,this.width,this.height].join(" ")},n}(),this.ascent=-parseInt(t.ascent,10),this.descent=-parseInt(t.descent,10),this.height=-this.ascent+this.descent}function i(){var e={},t={oblique:"italic",italic:"oblique"};this.add=function(t){(e[t.style]||(e[t.style]={}))[t.weight]=t},this.get=function(n,r){var i=e[n]||e[t[n]]||e.normal||e.italic||e.oblique;if(!i)return null;r={normal:400,bold:700}[r]||parseInt(r,10);if(i[r])return i[r];var s={1:1,99:0}[r%100],o=[],u,a;s===undefined&&(s=r>400),r==500&&(r=400);for(var f in i){f=parseInt(f,10);if(!u||fa)a=f;o.push(f)}return ra&&(r=a),o.sort(function(e,t){return(s?e>r&&t>r?e-1},complexity:function(){return this.getObjects().reduce(function(e,t){return e+=t.complexity?t.complexity():0,e},0)},toGrayscale:function(){return this.forEachObject(function(e){e.toGrayscale()})}},function(){function n(e,t){var n=e.indexOf(t);return n!==-1&&e.splice(n,1),e}function r(e,t){return Math.floor(Math.random()*(t-e+1))+e}function s(e){return e*i}function o(e){return e/i}function u(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)}function a(e,t){return parseFloat(Number(e).toFixed(t))}function f(){return!1}function l(e){e||(e={});var t=+(new Date),n=e.duration||500,r=t+n,i,s=e.onChange||function(){},o=e.abort||function(){return!1},u=e.easing||function(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t},a="startValue"in e?e.startValue:0,f="endValue"in e?e.endValue:100,l=e.byValue||f-a;e.onStart&&e.onStart(),function c(){i=+(new Date);var f=i>r?n:i-t;s(u(f,a,l,n));if(i>r||o()){e.onComplete&&e.onComplete();return}h(c)}()}function p(e){return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(e))]}function d(e,t,n){if(e){var r=fabric.util.createImage();r.onload=function(){t&&t.call(n,r),r=r.onload=null},r.src=e}else t&&t.call(n,e)}function v(e,t){function n(){++i===s&&t&&t(r)}var r=[],i=0,s=e.length;e.forEach(function(e,t){if(!e.type)return;var i=fabric.util.getKlass(e.type);i.async?i.fromObject(e,function(e,i){i||(r[t]=e),n()}):(r[t]=i.fromObject(e),n())})}function m(e,t,n){var r;return e.length>1?r=new fabric.PathGroup(e,t):r=e[0],typeof n!="undefined"&&r.setSourcePath(n),r}function g(e,t,n){if(n&&Object.prototype.toString.call(n)==="[object Array]")for(var r=0,i=n.length;rr)r+=u[p++%h],r>l&&(r=l),n[d?"lineTo":"moveTo"](r,0),d=!d;n.restore()}function b(e){return e||(e=fabric.document.createElement("canvas")),!e.getContext&&typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(e),e}function w(){return fabric.isLikelyNode?new(require("canvas").Image):fabric.document.createElement("img")}function E(e){var t=e.prototype;for(var n=t.stateProperties.length;n--;){var r=t.stateProperties[n],i=r.charAt(0).toUpperCase()+r.slice(1),s="set"+i,o="get"+i;t[o]||(t[o]=function(e){return new Function('return this.get("'+e+'")')}(r)),t[s]||(t[s]=function(e){return new Function("value",'return this.set("'+e+'", value)')}(r))}}function S(e,t){t.save(),t.beginPath(),e.clipTo(t),t.clip()}function x(e,t){var n=[[e[0],e[2],e[4]],[e[1],e[3],e[5]],[0,0,1]],r=[[t[0],t[2],t[4]],[t[1],t[3],t[5]],[0,0,1]],i=[];for(var s=0;s<3;s++){i[s]=[];for(var o=0;o<3;o++){var u=0;for(var a=0;a<3;a++)u+=n[s][a]*r[a][o];i[s][o]=u}}return[i[0][0],i[1][0],i[0][1],i[1][1],i[0][2],i[1][2]]}function T(e){return(String(e).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]}var e=Math.sqrt,t=Math.atan2;fabric.util={};var i=Math.PI/180,c=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(e){fabric.window.setTimeout(e,1e3/60)},h=function(){return c.apply(fabric.window,arguments)};fabric.util.removeFromArray=n,fabric.util.degreesToRadians=s,fabric.util.radiansToDegrees=o,fabric.util.rotatePoint=u,fabric.util.toFixed=a,fabric.util.getRandomInt=r,fabric.util.falseFunction=f,fabric.util.animate=l,fabric.util.requestAnimFrame=h,fabric.util.getKlass=p,fabric.util.loadImage=d,fabric.util.enlivenObjects=v,fabric.util.groupSVGElements=m,fabric.util.populateWithProperties=g,fabric.util.drawDashedLine=y,fabric.util.createCanvasElement=b,fabric.util.createImage=w,fabric.util.createAccessors=E,fabric.util.clipContext=S,fabric.util.multiplyTransformMatrices=x,fabric.util.getFunctionBody=T}(),function(){function t(t,n){var r=e.call(arguments,2),i=[];for(var s=0,o=t.length;s -1},complexity:function(){return this.getObjects().reduce(function(e,t){return e+=t.complexity?t.complexity():0,e},0)},toGrayscale:function(){return this.forEachObject(function(e){e.toGrayscale()})}},function(){function n(e,t){var n=e.indexOf(t);return n!==-1&&e.splice(n,1),e}function r(e,t){return Math.floor(Math.random()*(t-e+1))+e}function s(e){return e*i}function o(e){return e/i}function u(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)}function a(e,t){return parseFloat(Number(e).toFixed(t))}function f(){return!1}function l(e){e||(e={});var t=+(new Date),n=e.duration||500,r=t+n,i,s=e.onChange||function(){},o=e.abort||function(){return!1},u=e.easing||function(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t},a="startValue"in e?e.startValue:0,f="endValue"in e?e.endValue:100,l=e.byValue||f-a;e.onStart&&e.onStart(),function c(){i=+(new Date);var f=i>r?n:i-t;s(u(f,a,l,n));if(i>r||o()){e.onComplete&&e.onComplete();return}h(c)}()}function p(e){return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(e))]}function d(e,t,n){if(e){var r=fabric.util.createImage();r.onload=function(){t&&t.call(n,r),r=r.onload=null},r.src=e}else t&&t.call(n,e)}function v(e,t){function n(){++i===s&&t&&t(r)}var r=[],i=0,s=e.length;e.forEach(function(e,t){if(!e.type)return;var i=fabric.util.getKlass(e.type);i.async?i.fromObject(e,function(e,i){i||(r[t]=e),n()}):(r[t]=i.fromObject(e),n())})}function m(e,t,n){var r;return e.length>1?r=new fabric.PathGroup(e,t):r=e[0],typeof n!="undefined"&&r.setSourcePath(n),r}function g(e,t,n){if(n&&Object.prototype.toString.call(n)==="[object Array]")for(var r=0,i=n.length;rr)r+=u[p++%h],r>l&&(r=l),n[d?"lineTo":"moveTo"](r,0),d=!d;n.restore()}function b(e){return e||(e=fabric.document.createElement("canvas")),!e.getContext&&typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(e),e}function w(){return fabric.isLikelyNode?new(require("canvas").Image):fabric.document.createElement("img")}function E(e){var t=e.prototype;for(var n=t.stateProperties.length;n--;){var r=t.stateProperties[n],i=r.charAt(0).toUpperCase()+r.slice(1),s="set"+i,o="get"+i;t[o]||(t[o]=function(e){return new Function('return this.get("'+e+'")')}(r)),t[s]||(t[s]=function(e){return new Function("value",'return this.set("'+e+'", value)')}(r))}}function S(e,t){t.save(),t.beginPath(),e.clipTo(t),t.clip()}function x(e,t){var n=[[e[0],e[2],e[4]],[e[1],e[3],e[5]],[0,0,1]],r=[[t[0],t[2],t[4]],[t[1],t[3],t[5]],[0,0,1]],i=[];for(var s=0;s<3;s++){i[s]=[];for(var o=0;o<3;o++){var u=0;for(var a=0;a<3;a++)u+=n[s][a]*r[a][o];i[s][o]=u}}return[i[0][0],i[1][0],i[0][1],i[1][1],i[0][2],i[1][2]]}function T(e){return(String(e).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]}var e=Math.sqrt,t=Math.atan2;fabric.util={};var i=Math.PI/180,c=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(e){fabric.window.setTimeout(e,1e3/60)},h=function(){return c.apply(fabric.window,arguments)};fabric.util.removeFromArray=n,fabric.util.degreesToRadians=s,fabric.util.radiansToDegrees=o,fabric.util.rotatePoint=u,fabric.util.toFixed=a,fabric.util.getRandomInt=r,fabric.util.falseFunction=f,fabric.util.animate=l,fabric.util.requestAnimFrame=h,fabric.util.getKlass=p,fabric.util.loadImage=d,fabric.util.enlivenObjects=v,fabric.util.groupSVGElements=m,fabric.util.populateWithProperties=g,fabric.util.drawDashedLine=y,fabric.util.createCanvasElement=b,fabric.util.createImage=w,fabric.util.createAccessors=E,fabric.util.clipContext=S,fabric.util.multiplyTransformMatrices=x,fabric.util.getFunctionBody=T}(),function(){function t(t,n){var r=e.call(arguments,2),i=[];for(var s=0,o=t.length;s>>0,n=0,r;if(arguments.length>1)r=arguments[1];else do{if(n in this){r=this[n++];break}if(++n>=t)throw new TypeError}while(!0);for(;n>>0,n=0,r;if(arguments.length>1)r=arguments[1];else do{if(n in this){r=this[n++];break}if(++n>=t)throw new TypeError}while(!0);for(;n0&&(i.status="Intersection"),i},t.Intersection.intersectPolygonPolygon=function(e,t){var r=new n("No Intersection"),i=e.length;for(var s=0;s0&&(r.status="Intersection"),r},t.Intersection.intersectPolygonRectangle=function(e,r,i){var s=r.min(i),o=r.max(i),u=new t.Point(o.x,s.y),a=new t.Point(s.x,o.y),f=n.intersectLinePolygon(s,u,e),l=n.intersectLinePolygon(u,o,e),c=n.intersectLinePolygon(o,a,e),h=n.intersectLinePolygon(a,s,e),p=new n("No Intersection");return p.appendPoints(f.points),p.appendPoints(l.points),p.appendPoints(c.points),p.appendPoints(h.points),p.points.length>0&&(p.status="Intersection"),p}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function n(e){e?this._tryParsingColor(e):this.setSource([0,0,0,1])}function r(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var t=e.fabric||(e.fabric={});if(t.Color){t.warn("fabric.Color is already defined.");return}t.Color=n,t.Color.prototype={_tryParsingColor:function(e){var t;e in n.colorNameMap&&(e=n.colorNameMap[e]),t=n.sourceFromHex(e),t||(t=n.sourceFromRgb(e)),t||(t=n.sourceFromHsl(e)),t&&this.setSource(t)},_rgbToHsl:function(e,n,r){e/=255,n/=255,r/=255;var i,s,o,u=t.util.array.max([e,n,r]),a=t.util.array.min([e,n,r]);o=(u+a)/2;if(u===a)i=s=0;else{var f=u-a;s=o>.5?f/(2-u-a):f/(u+a);switch(u){case e:i=(n-r)/f+(n