diff --git a/dist/all.js b/dist/all.js index 6e7aeb2c..3d8607c9 100644 --- a/dist/all.js +++ b/dist/all.js @@ -1,9 +1,5 @@ /* build: `node build.js modules=ALL exclude=gestures` */ -<<<<<<< HEAD -/*! Fabric.js Copyright 2008-2012, Printio (Juriy Zaytsev, Maxim Chernyak) */ -======= /*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */ ->>>>>>> master var fabric = fabric || { version: "1.0.6" }; @@ -4731,6 +4727,13 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { */ offsetY: 0, + /** + * Whether the shadow should affect stroke operations + * @property + * @type Boolean + */ + affectStroke: false, + /** * Constructor * @method initialize @@ -6844,6 +6847,81 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { })(); +/** + * BaseBrush class + * @class fabric.BaseBrush + */ +fabric.BaseBrush = fabric.util.createClass({ + + /** + * Color of a brush + * @property + * @type String + */ + color: 'rgb(0, 0, 0)', + + /** + * Width of a brush + * @property + * @type Number + */ + width: 1, + + /** + * Shadow blur of a brush + * @property + * @type Number + */ + shadowBlur: 0, + + /** + * Shadow color of a brush + * @property + * @type String + */ + shadowColor: '', + + /** + * Shadow offset x of a brush + * @property + * @type Number + */ + shadowOffsetX: 0, + + /** + * Shadow offset y of a brush + * @property + * @type Number + */ + shadowOffsetY: 0, + + /** + * Sets brush styles + * @method setBrushStyles + */ + setBrushStyles: function() { + var ctx = this.canvas.contextTop; + + ctx.strokeStyle = this.color; + ctx.lineWidth = this.width; + ctx.lineCap = ctx.lineJoin = 'round'; + }, + + /** + * Sets brush shadow styles + * @method setShadowStyles + */ + setShadowStyles: function() { + var ctx = this.canvas.contextTop; + + if (this.shadowBlur) { + ctx.shadowBlur = this.shadowBlur; + ctx.shadowColor = this.shadowColor || this.color; + ctx.shadowOffsetX = this.shadowOffsetX; + ctx.shadowOffsetY = this.shadowOffsetY; + } + } +}); (function() { var utilMin = fabric.util.array.min, @@ -6852,50 +6930,9 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * PencilBrush class * @class fabric.PencilBrush + * @extends fabric.BaseBrush */ - fabric.PencilBrush = fabric.util.createClass( /** @scope fabric.PencilBrush.prototype */ { - - /** - * Color of the pencil - * @property - * @type String - */ - color: 'rgb(0, 0, 0)', - - /** - * Width of a pencil - * @property - * @type Number - */ - width: 1, - - /** - * Shadow blur of a pencil - * @property - * @type Number - */ - shadowBlur: 0, - - /** - * Shadow color of a pencil - * @property - * @type String - */ - shadowColor: '', - - /** - * Shadow offset x of a pencil - * @property - * @type Number - */ - shadowOffsetX: 0, - - /** - * Shadow offset y of a pencil - * @property - * @type Number - */ - shadowOffsetY: 0, + fabric.PencilBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric.PencilBrush.prototype */ { /** * Constructor @@ -6972,19 +7009,8 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { _reset: function() { this._points.length = 0; - var ctx = this.canvas.contextTop; - - ctx.strokeStyle = this.color; - ctx.lineWidth = this.width; - - if (this.shadowBlur) { - ctx.shadowBlur = this.shadowBlur; - ctx.shadowColor = this.shadowColor || this.color; - ctx.shadowOffsetX = this.shadowOffsetX; - ctx.shadowOffsetY = this.shadowOffsetY; - } - - ctx.lineCap = ctx.lineJoin = 'round'; + this.setBrushStyles(); + this.setShadowStyles(); }, /** @@ -7115,8 +7141,15 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { createPath: function(pathData) { var path = new fabric.Path(pathData); path.fill = null; - path.stroke = this.canvas.freeDrawingColor; - path.strokeWidth = this.canvas.freeDrawingLineWidth; + path.stroke = this.color; + path.strokeWidth = this.width; + path.setShadow({ + color: this.shadowColor || this.color, + blur: this.shadowBlur, + offsetX: this.shadowOffsetX, + offsetY: this.shadowOffsetY, + affectStroke: true + }); return path; }, @@ -7130,12 +7163,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { _finalizeAndAddPath: function() { var ctx = this.canvas.contextTop; ctx.closePath(); -<<<<<<< HEAD - - var path = this._getSVGPathData(); - path = path.join(''); -======= ->>>>>>> master var pathData = this._getSVGPathData().join(''); if (pathData === "M 0 0 Q 0 0 0 0 L 0 0") { @@ -7147,15 +7174,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { return; } -<<<<<<< HEAD - var p = new fabric.Path(path); - p.fill = null; - p.stroke = this.color; - p.strokeWidth = this.width; - this.canvas.add(p); - -======= ->>>>>>> master // set path origin coordinates based on our bounding box var originLeft = this.box.minx + (this.box.maxx - this.box.minx) /2; var originTop = this.box.miny + (this.box.maxy - this.box.miny) /2; @@ -7176,18 +7194,12 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { } }); })(); + /** * CircleBrush class * @class fabric.CircleBrush */ -fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prototype */ { - - /** - * Color of the brush - * @property - * @type String - */ - color: 'rgb(0, 0, 0)', +fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric.CircleBrush.prototype */ { /** * Width of a brush @@ -7196,34 +7208,6 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot */ width: 10, - /** - * Shadow blur of a pencil - * @property - * @type Number - */ - shadowBlur: 0, - - /** - * Shadow color of a pencil - * @property - * @type String - */ - shadowColor: '', - - /** - * Shadow offset x of a pencil - * @property - * @type Number - */ - shadowOffsetX: 0, - - /** - * Shadow offset y of a pencil - * @property - * @type Number - */ - shadowOffsetY: 0, - /** * Constructor * @method initialize @@ -7281,7 +7265,13 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot radius: point.radius, left: point.x, top: point.y, - fill: point.fill + fill: point.fill, + shadow: { + color: this.shadowColor || this.color, + blur: this.shadowBlur, + offsetX: this.shadowOffsetX, + offsetY: this.shadowOffsetY + } }); this.canvas.add(circle); } @@ -7313,6 +7303,229 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot return pointerPoint; } }); +/** + * SprayBrush class + * @class fabric.SprayBrush + */ +fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric.SprayBrush.prototype */ { + + /** + * Width of a spray + * @property + * @type Number + */ + width: 10, + + /** + * Density of a spray (number of dots per chunk) + * @property + * @type Number + */ + density: 20, + + /** + * Width of spray dots + * @property + * @type Number + */ + dotWidth: 1, + + /** + * Width variance of spray dots + * @property + * @type Number + */ + dotWidthVariance: 1, + + /** + * Whether opacity of a dot should be random + * @property + * @type Boolean + */ + randomOpacity: false, + + /** + * Constructor + * @method initialize + * @param {fabric.Canvas} canvas + * @return {fabric.SprayBrush} Instance of a spray brush + */ + initialize: function(canvas) { + this.canvas = canvas; + this.sprayChunks = [ ]; + }, + + /** + * @method onMouseDown + * @param {Object} pointer + */ + onMouseDown: function(pointer) { + this.sprayChunks.length = 0; + this.canvas.clearContext(this.canvas.contextTop); + this.setShadowStyles(); + + this.addSprayChunk(pointer); + this.render(); + }, + + /** + * @method onMouseMove + * @param {Object} pointer + */ + onMouseMove: function(pointer) { + this.addSprayChunk(pointer); + this.render(); + }, + + /** + * @method onMouseUp + */ + onMouseUp: function() { + var originalRenderOnAddition = this.canvas.renderOnAddition; + this.canvas.renderOnAddition = false; + + for (var i = 0, ilen = this.sprayChunks.length; i < ilen; i++) { + var sprayChunk = this.sprayChunks[i]; + + for (var j = 0, jlen = sprayChunk.length; j < jlen; j++) { + + var rect = new fabric.Rect({ + width: sprayChunk[j].width, + height: sprayChunk[j].width, + left: sprayChunk[j].x + 1, + top: sprayChunk[j].y + 1, + fill: this.color, + shadow: { + color: this.shadowColor || this.color, + blur: this.shadowBlur, + offsetX: this.shadowOffsetX, + offsetY: this.shadowOffsetY + } + }); + + this.canvas.add(rect); + } + } + + this.canvas.renderOnAddition = originalRenderOnAddition; + this.canvas.clearContext(this.canvas.contextTop); + this.canvas.renderAll(); + }, + + /** + * @method render + */ + render: function() { + var ctx = this.canvas.contextTop; + ctx.fillStyle = this.color; + ctx.save(); + + for (var i = 0, len = this.sprayChunkPoints.length; i < len; i++) { + var point = this.sprayChunkPoints[i]; + if (typeof point.opacity !== 'undefined') { + ctx.globalAlpha = point.opacity; + } + ctx.fillRect(point.x, point.y, point.width, point.width); + } + ctx.restore(); + }, + + /** + * @method addSprayChunk + * @param {Object} pointer + */ + addSprayChunk: function(pointer) { + this.sprayChunkPoints = [ ]; + + var x, y, width, radius = this.width / 2; + + for (var i = 0; i < this.density; i++) { + + x = fabric.util.getRandomInt(pointer.x - radius, pointer.x + radius); + y = fabric.util.getRandomInt(pointer.y - radius, pointer.y + radius); + + if (this.dotWidthVariance) { + width = fabric.util.getRandomInt( + // bottom clamp width to 1 + Math.max(1, this.dotWidth - this.dotWidthVariance), + this.dotWidth + this.dotWidthVariance); + } + else { + width = this.dotWidth; + } + + var point = { x: x, y: y, width: width }; + + if (this.randomOpacity) { + point.opacity = fabric.util.getRandomInt(0, 100) / 100; + } + + this.sprayChunkPoints.push(point); + } + + this.sprayChunks.push(this.sprayChunkPoints); + } +}); +/** + * PatternBrush class + * @class fabric.PatternBrush + * @extends fabric.BaseBrush + */ +fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fabric.PatternBrush.prototype */ { + + getPatternSrc: function() { + + var dotWidth = 20, + dotDistance = 5, + patternCanvas = fabric.document.createElement('canvas'), + patternCtx = patternCanvas.getContext('2d'); + + patternCanvas.width = patternCanvas.height = dotWidth + dotDistance; + + patternCtx.fillStyle = this.color; + patternCtx.beginPath(); + patternCtx.arc(dotWidth / 2, dotWidth / 2, dotWidth / 2, 0, Math.PI * 2, false); + patternCtx.closePath(); + patternCtx.fill(); + + return patternCanvas; + }, + + getPatternSrcBody: function() { + return String(this.getPatternSrc) + .match(/function\s+\w*\s*\(.*\)\s+\{([\s\S]*)\}/)[1] + .replace('this.color', '"' + this.color + '"'); + }, + + /** + * Creates "pattern" instance property + * @method getPattern + */ + getPattern: function() { + return this.canvas.contextTop.createPattern(this.source || this.getPatternSrc(), 'repeat'); + }, + + /** + * Sets brush styles + * @method setBrushStyles + */ + setBrushStyles: function() { + this.callSuper('setBrushStyles'); + this.canvas.contextTop.strokeStyle = this.getPattern(); + }, + + /** + * Creates path + * @method createPath + */ + createPath: function(pathData) { + var path = this.callSuper('createPath', pathData); + path.stroke = new fabric.Pattern({ + source: this.source || this.getPatternSrcBody() + }); + return path; + } +}); (function() { var extend = fabric.util.object.extend, @@ -7470,10 +7683,12 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot _initInteractive: function() { this._currentTransform = null; this._groupSelector = null; - this.freeDrawing = fabric.FreeDrawing && new fabric.FreeDrawing(this); this._initWrapperElement(); this._createUpperCanvas(); this._initEvents(); + + this.freeDrawingBrush = fabric.PencilBrush && new fabric.PencilBrush(this); + this.calcOffset(); }, @@ -7549,18 +7764,6 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot * @private * @method _normalizePointer */ -<<<<<<< HEAD - _initInteractive: function() { - this._currentTransform = null; - this._groupSelector = null; - this._initWrapperElement(); - this._createUpperCanvas(); - this._initEvents(); - - this.freeDrawingBrush = fabric.PencilBrush && new fabric.PencilBrush(this); - - this.calcOffset(); -======= _normalizePointer: function (object, pointer) { var activeGroup = this.getActiveGroup(), @@ -7578,7 +7781,6 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot y -= activeGroup.top; } return { x: x, y: y }; ->>>>>>> master }, /** @@ -7707,14 +7909,6 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot mouseYSign: 1 }; -<<<<<<< HEAD - if (this.isDrawingMode && this._isCurrentlyDrawing) { - this._isCurrentlyDrawing = false; - this.freeDrawingBrush.onMouseUp(); - this.fire('mouse:up', { e: e }); - return; - } -======= this._currentTransform.original = { left: target.left, top: target.top, @@ -7723,7 +7917,6 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot originX: originX, originY: originY }; ->>>>>>> master this._resetCurrentTransform(e); }, @@ -7825,17 +8018,6 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot var lockScalingX = target.get('lockScalingX'), lockScalingY = target.get('lockScalingY'); -<<<<<<< HEAD - if (this.isDrawingMode) { - pointer = this.getPointer(e); - - this._isCurrentlyDrawing = true; - this.discardActiveObject().renderAll(); - - this.freeDrawingBrush.onMouseDown(pointer); - this.fire('mouse:down', { e: e }); - return; -======= if (lockScalingX && lockScalingY) return; // Get the constraint point @@ -7844,7 +8026,6 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot if (t.originX === 'right') { localMouse.x *= -1; ->>>>>>> master } else if (t.originX === 'center') { localMouse.x *= t.mouseXSign * 2; @@ -7897,16 +8078,6 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot lockScalingY || target.set('scaleY', newScaleY); } -<<<<<<< HEAD - if (this.isDrawingMode) { - if (this._isCurrentlyDrawing) { - pointer = this.getPointer(e); - this.freeDrawingBrush.onMouseMove(pointer); - } - this.upperCanvasEl.style.cursor = this.freeDrawingCursor; - this.fire('mouse:move', { e: e }); - return; -======= // Check if we flipped if (newScaleX < 0) { @@ -7922,7 +8093,6 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot t.originY = 'bottom'; else if (t.originY === 'bottom') t.originY = 'top'; ->>>>>>> master } // Make sure the constraints apply @@ -8466,7 +8636,8 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot var target; if (this.isDrawingMode && this._isCurrentlyDrawing) { - this.freeDrawing._finalizeAndAddPath(); + this._isCurrentlyDrawing = false; + this.freeDrawingBrush.onMouseUp(); this.fire('mouse:up', { e: e }); return; } @@ -8550,12 +8721,9 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot if (this.isDrawingMode) { pointer = this.getPointer(e); - this.freeDrawing._prepareForDrawing(pointer); - - // capture coordinates immediately; - // this allows to draw dots (when movement never occurs) - this.freeDrawing._captureDrawingPath(pointer); - + this._isCurrentlyDrawing = true; + this.discardActiveObject().renderAll(); + this.freeDrawingBrush.onMouseDown(pointer); this.fire('mouse:down', { e: e }); return; } @@ -8628,12 +8796,7 @@ fabric.CircleBrush = fabric.util.createClass( /** @scope fabric.CircleBrush.prot if (this.isDrawingMode) { if (this._isCurrentlyDrawing) { pointer = this.getPointer(e); - this.freeDrawing._captureDrawingPath(pointer); - - // redraw curve - // clear top canvas - this.clearContext(this.contextTop); - this.freeDrawing._render(this.contextTop); + this.freeDrawingBrush.onMouseMove(pointer); } this.upperCanvasEl.style.cursor = this.freeDrawingCursor; this.fire('mouse:move', { e: e }); @@ -13203,7 +13366,9 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati if (this.fill) { ctx.fill(); } - this._removeShadow(ctx); + if (this.shadow && !this.shadow.affectStroke) { + this._removeShadow(ctx); + } if (this.stroke) { ctx.strokeStyle = this.stroke; @@ -13211,6 +13376,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati ctx.lineCap = ctx.lineJoin = 'round'; ctx.stroke(); } + this._removeShadow(ctx); + if (!noTransform && this.active) { this.drawBorders(ctx); this.hideCorners || this.drawCorners(ctx); @@ -15580,7 +15747,7 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { fabric.Text = fabric.util.createClass(fabric.Object, /** @scope fabric.Text.prototype */ { /** - * Font size + * Font size (in pixels) * @property * @type Number */ diff --git a/dist/all.min.js b/dist/all.min.js index 367decf6..d3492b3d 100644 --- a/dist/all.min.js +++ b/dist/all.min.js @@ -1,13 +1,5 @@ -<<<<<<< HEAD -/* build: `node build.js modules=ALL exclude=gestures` *//*! Fabric.js Copyright 2008-2012, Printio (Juriy Zaytsev, Maxim Chernyak) */var fabric=fabric||{version:"1.0.0"};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,c,n));if(i>r||o()){e.onComplete&&e.onComplete();return}l(h)}()}function c(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 h(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 p(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 d(e,t,n){if(n&&Object.prototype.toString.call(n)==="[object Array]")for(var r=0,i=n.length;r=r&&(r=e[n][t]);else while(n--)e[n]>=r&&(r=e[n]);return r}function r(e,t){if(!e||e.length===0)return undefined;var n=e.length-1,r=t?e[n][t]:e[n];if(t)while(n--)e[n][t] 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)