diff --git a/HEADER.js b/HEADER.js index 4e750b4f..f9ebfee5 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.0.11" }; +var fabric = fabric || { version: "1.0.12" }; if (typeof exports !== 'undefined') { exports.fabric = fabric; diff --git a/dist/all.js b/dist/all.js index 12899629..7a67c288 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.0.11" }; +var fabric = fabric || { version: "1.0.12" }; if (typeof exports !== 'undefined') { exports.fabric = fabric; @@ -5744,7 +5744,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { clipTo: null, /** - * Indicates whether object controls (borders/corners) are rendered above overlay image + * Indicates whether object controls (borders/controls) are rendered above overlay image * @property * @type Boolean */ @@ -6056,11 +6056,11 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { if (!object) return; if (this.controlsAboveOverlay) { - var hasBorders = object.hasBorders, hasCorners = object.hasCorners; - object.hasBorders = object.hasCorners = false; + var hasBorders = object.hasBorders, hasControls = object.hasControls; + object.hasBorders = object.hasControls = false; object.render(ctx); object.hasBorders = hasBorders; - object.hasCorners = hasCorners; + object.hasControls = hasControls; } else { object.render(ctx); @@ -6288,7 +6288,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { } // delegate rendering to group selection if one exists - // used for drawing selection borders/corners + // used for drawing selection borders/controls var activeGroup = this.getActiveGroup(); if (activeGroup) { activeGroup.render(ctx); @@ -6304,7 +6304,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { }, /** - * Draws objects' controls (borders/corners) + * Draws objects' controls (borders/controls) * @method drawControls * @param {Object} ctx context to render controls on */ @@ -6313,7 +6313,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { if (activeGroup) { ctx.save(); fabric.Group.prototype.transform.call(activeGroup, ctx); - activeGroup.drawBorders(ctx).drawCorners(ctx); + activeGroup.drawBorders(ctx).drawControls(ctx); ctx.restore(); } else { @@ -6322,7 +6322,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { ctx.save(); fabric.Object.prototype.transform.call(this._objects[i], ctx); - this._objects[i].drawBorders(ctx).drawCorners(ctx); + this._objects[i].drawBorders(ctx).drawControls(ctx); ctx.restore(); this.lastRenderedObjectWithControlsAboveOverlay = this._objects[i]; @@ -6374,7 +6374,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { if (activeGroup) { // not removing group due to complications with restoring it with correct state afterwords - this._tempRemoveBordersCornersFromGroup(activeGroup); + this._tempRemoveBordersControlsFromGroup(activeGroup); } else if (activeObject && this.deactivateAll) { this.deactivateAll(); @@ -6393,7 +6393,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { this.setWidth(origWidth).setHeight(origHeight); if (activeGroup) { - this._restoreBordersCornersOnGroup(activeGroup); + this._restoreBordersControlsOnGroup(activeGroup); } else if (activeObject && this.setActiveObject) { this.setActiveObject(activeObject); @@ -6407,13 +6407,13 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * @private - * @method _tempRemoveBordersCornersFromGroup + * @method _tempRemoveBordersControlsFromGroup */ - _tempRemoveBordersCornersFromGroup: function(group) { - group.origHideCorners = group.hideCorners; + _tempRemoveBordersControlsFromGroup: function(group) { + group.origHasControls = group.hasControls; group.origBorderColor = group.borderColor; - group.hideCorners = true; + group.hasControls = true; group.borderColor = 'rgba(0,0,0,0)'; group.forEachObject(function(o) { @@ -6424,10 +6424,10 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * @private - * @method _restoreBordersCornersOnGroup + * @method _restoreBordersControlsOnGroup */ - _restoreBordersCornersOnGroup: function(group) { - group.hideCorners = group.origHideCorners; + _restoreBordersControlsOnGroup: function(group) { + group.hideControls = group.origHideControls; group.borderColor = group.origBorderColor; group.forEachObject(function(o) { @@ -9761,7 +9761,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati if (this.active && !noTransform) { this.drawBorders(ctx); - this.hideCorners || this.drawCorners(ctx); + this.drawControls(ctx); } ctx.restore(); }, @@ -11065,12 +11065,12 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * Draws corners of an object's bounding box. * Requires public properties: width, height, scaleX, scaleY * Requires public options: cornerSize, padding - * @method drawCorners + * @method drawControls * @param {CanvasRenderingContext2D} ctx Context to draw on * @return {fabric.Object} thisArg * @chainable */ - drawCorners: function(ctx) { + drawControls: function(ctx) { if (!this.hasControls) return; var size = this.cornerSize, @@ -13035,7 +13035,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati } if (!noTransform && this.active) { this.drawBorders(ctx); - this.hideCorners || this.drawCorners(ctx); + this.drawControls(ctx); } ctx.restore(); }, @@ -13342,7 +13342,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati if (this.active) { this.drawBorders(ctx); - this.hideCorners || this.drawCorners(ctx); + this.drawControls(ctx); } ctx.restore(); }, @@ -13593,7 +13593,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati object.setCoords(); // do not display corners of objects enclosed in a group - object.hideCorners = true; + object.hasControls = false; }, this); }, @@ -13759,7 +13759,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati if (!noTransform && this.active) { this.drawBorders(ctx); - this.hideCorners || this.drawCorners(ctx); + this.drawControls(ctx); } ctx.restore(); this.setCoords(); @@ -13823,7 +13823,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati object.set('scaleY', object.get('scaleY') * this.get('scaleY')); object.setCoords(); - object.hideCorners = false; + object.hasControls = true; object.setActive(false); object.setCoords(); @@ -14168,7 +14168,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati if (this.active && !noTransform) { this.drawBorders(ctx); - this.hideCorners || this.drawCorners(ctx); + this.drawControls(ctx); } ctx.restore(); }, @@ -16024,7 +16024,7 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { this._render(ctx); if (!noTransform && this.active) { this.drawBorders(ctx); - this.hideCorners || this.drawCorners(ctx); + this.drawControls(ctx); } ctx.restore(); }, diff --git a/dist/all.min.js b/dist/all.min.js index ade96146..53b22e04 100644 --- a/dist/all.min.js +++ b/dist/all.min.js @@ -1,5 +1,5 @@ -/* build: `node build.js modules=ALL exclude=gestures` *//*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */var fabric=fabric||{version:"1.0.11"};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?er?n:i-t;s(u(f,a,l,n));if(i>r||o()){e.onComplete&&e.onComplete();return}h(c)}()}function p(e,t,n){if(e){var r=new Image;r.onload=function(){t&&t.call(n,r),r=r.onload=null},r.src=e}else t&&t.call(n,e)}function d(e,t){function n(e){return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(e))]}function r(){++s===o&&t&&t(i)}var i=[],s=0,o=e.length;e.forEach(function(e,t){if(!e.type)return;var s=n(e.type);s.async?s.fromObject(e,function(e,n){n||(i[t]=e),r()}):(i[t]=s.fromObject(e),r())})}function v(e,t,n){var r;if(e.length>1){var i=e.some(function(e){return e.type==="text"});i?(r=new fabric.Group([],t),e.reverse().forEach(function(e){e.cx&&(e.left=e.cx),e.cy&&(e.top=e.cy),r.addWithUpdate(e)})):r=new fabric.PathGroup(e,t)}else r=e[0];return typeof n!="undefined"&&r.setSourcePath(n),r}function m(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 y(e){return e||(e=fabric.document.createElement("canvas")),!e.getContext&&typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(e),e}function b(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))}}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.loadImage=p,fabric.util.enlivenObjects=d,fabric.util.groupSVGElements=v,fabric.util.populateWithProperties=m,fabric.util.drawDashedLine=g,fabric.util.createCanvasElement=y,fabric.util.createAccessors=b}(),function(){function t(t,n){var r=e.call(arguments,2),i=[];for(var s=0,o=t.length;s 0&&this.init(e,t)}var t=e.fabric||(e.fabric={});if(t.Point){t.warn("fabric.Point is already defined");return}t.Point=n,n.prototype={constructor:n,init:function(e,t){this.x=e,this.y=t},add:function(e){return new n(this.x+e.x,this.y+e.y)},addEquals:function(e){return this.x+=e.x,this.y+=e.y,this},scalarAdd:function(e){return new n(this.x+e,this.y+e)},scalarAddEquals:function(e){return this.x+=e,this.y+=e,this},subtract:function(e){return new n(this.x-e.x,this.y-e.y)},subtractEquals:function(e){return this.x-=e.x,this.y-=e.y,this},scalarSubtract:function(e){return new n(this.x-e,this.y-e)},scalarSubtractEquals:function(e){return this.x-=e,this.y-=e,this},multiply:function(e){return new n(this.x*e,this.y*e)},multiplyEquals:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return new n(this.x/e,this.y/e)},divideEquals:function(e){return this.x/=e,this.y/=e,this},eq:function(e){return this.x===e.x&&this.y===e.y},lt:function(e){return this.x>>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])}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=n.sourceFromHex(e);t||(t=n.sourceFromRgb(e)),t&&this.setSource(t)},getSource:function(){return this._source},setSource:function(e){this._source=e},toRgb:function(){var e=this.getSource();return"rgb("+e[0]+","+e[1]+","+e[2]+")"},toRgba:function(){var e=this.getSource();return"rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")"},toHex:function(){var e=this.getSource(),t=e[0].toString(16);t=t.length===1?"0"+t:t;var n=e[1].toString(16);n=n.length===1?"0"+n:n;var r=e[2].toString(16);return r=r.length===1?"0"+r:r,t.toUpperCase()+n.toUpperCase()+r.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var t=this.getSource();return t[3]=e,this.setSource(t),this},toGrayscale:function(){var e=this.getSource(),t=parseInt((e[0]*.3+e[1]*.59+e[2]*.11).toFixed(0),10),n=e[3];return this.setSource([t,t,t,n]),this},toBlackWhite:function(e){var t=this.getSource(),n=(t[0]*.3+t[1]*.59+t[2]*.11).toFixed(0),r=t[3];return e=e||127,n=Number(n)