96e7f94c30d1c93139fc5ce202ea24df.json
52.4 KB
{"ast":null,"code":"/**\r\n * @author NHN. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Shape resize helper\r\n */\nimport { forEach, map, extend } from 'tui-code-snippet';\nimport { capitalizeString, flipObject, setCustomProperty, getCustomProperty } from '../util';\nimport resizeHelper from '../helper/shapeResizeHelper';\nconst FILTER_OPTION_MAP = {\n pixelate: 'blocksize',\n blur: 'blur'\n};\nconst POSITION_DIMENSION_MAP = {\n x: 'width',\n y: 'height'\n};\nconst FILTER_NAME_VALUE_MAP = flipObject(FILTER_OPTION_MAP);\n/**\r\n * Cached canvas image element for fill image\r\n * @type {boolean}\r\n * @private\r\n */\n\n_c = FILTER_NAME_VALUE_MAP;\nlet cachedCanvasImageElement = null;\n/**\r\n * Get background image of fill\r\n * @param {fabric.Object} shapeObj - Shape object\r\n * @returns {fabric.Image}\r\n * @private\r\n */\n\nexport function getFillImageFromShape(shapeObj) {\n const {\n patternSourceCanvas\n } = getCustomProperty(shapeObj, 'patternSourceCanvas');\n const [fillImage] = patternSourceCanvas.getObjects();\n return fillImage;\n}\n/**\r\n * Reset the image position in the filter type fill area.\r\n * @param {fabric.Object} shapeObj - Shape object\r\n * @private\r\n */\n\nexport function rePositionFilterTypeFillImage(shapeObj) {\n const {\n angle,\n flipX,\n flipY\n } = shapeObj;\n const fillImage = getFillImageFromShape(shapeObj);\n const rotatedShapeCornerDimension = getRotatedDimension(shapeObj);\n const {\n right,\n bottom\n } = rotatedShapeCornerDimension;\n let {\n width,\n height\n } = rotatedShapeCornerDimension;\n const diffLeft = (width - shapeObj.width) / 2;\n const diffTop = (height - shapeObj.height) / 2;\n const cropX = shapeObj.left - shapeObj.width / 2 - diffLeft;\n const cropY = shapeObj.top - shapeObj.height / 2 - diffTop;\n let left = width / 2 - diffLeft;\n let top = height / 2 - diffTop;\n const fillImageMaxSize = Math.max(width, height) + Math.max(diffLeft, diffTop);\n [left, top, width, height] = calculateFillImageDimensionOutsideCanvas({\n shapeObj,\n left,\n top,\n width,\n height,\n cropX,\n cropY,\n flipX,\n flipY,\n right,\n bottom\n });\n fillImage.set({\n angle: flipX === flipY ? -angle : angle,\n left,\n top,\n width,\n height,\n cropX,\n cropY,\n flipX,\n flipY\n });\n setCustomProperty(fillImage, {\n fillImageMaxSize\n });\n}\n/**\r\n * Make filter option from fabric image\r\n * @param {fabric.Image} imageObject - fabric image object\r\n * @returns {object}\r\n */\n\nexport function makeFilterOptionFromFabricImage(imageObject) {\n return map(imageObject.filters, filter => {\n const [key] = Object.keys(filter);\n return {\n [FILTER_NAME_VALUE_MAP[key]]: filter[key]\n };\n });\n}\n/**\r\n * Calculate fill image position and size for out of Canvas\r\n * @param {Object} options - options for position dimension calculate\r\n * @param {fabric.Object} shapeObj - shape object\r\n * @param {number} left - original left position\r\n * @param {number} top - original top position\r\n * @param {number} width - image width\r\n * @param {number} height - image height\r\n * @param {number} cropX - image cropX\r\n * @param {number} cropY - image cropY\r\n * @param {boolean} flipX - shape flipX\r\n * @param {boolean} flipY - shape flipY\r\n * @returns {Object}\r\n */\n\nfunction calculateFillImageDimensionOutsideCanvas({\n shapeObj,\n left,\n top,\n width,\n height,\n cropX,\n cropY,\n flipX,\n flipY,\n right,\n bottom\n}) {\n const overflowAreaPositionFixer = (type, outDistance, imageLeft, imageTop) => calculateDistanceOverflowPart({\n type,\n outDistance,\n shapeObj,\n flipX,\n flipY,\n left: imageLeft,\n top: imageTop\n });\n\n const [originalWidth, originalHeight] = [width, height];\n [left, top, width, height] = calculateDimensionLeftTopEdge(overflowAreaPositionFixer, {\n left,\n top,\n width,\n height,\n cropX,\n cropY\n });\n [left, top, width, height] = calculateDimensionRightBottomEdge(overflowAreaPositionFixer, {\n left,\n top,\n insideCanvasRealImageWidth: width,\n insideCanvasRealImageHeight: height,\n right,\n bottom,\n cropX,\n cropY,\n originalWidth,\n originalHeight\n });\n return [left, top, width, height];\n}\n/**\r\n * Calculate fill image position and size for for right bottom edge\r\n * @param {Function} overflowAreaPositionFixer - position fixer\r\n * @param {Object} options - options for position dimension calculate\r\n * @param {fabric.Object} shapeObj - shape object\r\n * @param {number} left - original left position\r\n * @param {number} top - original top position\r\n * @param {number} width - image width\r\n * @param {number} height - image height\r\n * @param {number} right - image right\r\n * @param {number} bottom - image bottom\r\n * @param {number} cropX - image cropX\r\n * @param {number} cropY - image cropY\r\n * @param {boolean} originalWidth - image original width\r\n * @param {boolean} originalHeight - image original height\r\n * @returns {Object}\r\n */\n\n\nfunction calculateDimensionRightBottomEdge(overflowAreaPositionFixer, {\n left,\n top,\n insideCanvasRealImageWidth,\n insideCanvasRealImageHeight,\n right,\n bottom,\n cropX,\n cropY,\n originalWidth,\n originalHeight\n}) {\n let [width, height] = [insideCanvasRealImageWidth, insideCanvasRealImageHeight];\n const {\n width: canvasWidth,\n height: canvasHeight\n } = cachedCanvasImageElement;\n\n if (right > canvasWidth && cropX > 0) {\n width = originalWidth - Math.abs(right - canvasWidth);\n }\n\n if (bottom > canvasHeight && cropY > 0) {\n height = originalHeight - Math.abs(bottom - canvasHeight);\n }\n\n const diff = {\n x: (insideCanvasRealImageWidth - width) / 2,\n y: (insideCanvasRealImageHeight - height) / 2\n };\n forEach(['x', 'y'], type => {\n const cropDistance2 = diff[type];\n\n if (cropDistance2 > 0) {\n [left, top] = overflowAreaPositionFixer(type, cropDistance2, left, top);\n }\n });\n return [left, top, width, height];\n}\n/**\r\n * Calculate fill image position and size for for left top\r\n * @param {Function} overflowAreaPositionFixer - position fixer\r\n * @param {Object} options - options for position dimension calculate\r\n * @param {fabric.Object} shapeObj - shape object\r\n * @param {number} left - original left position\r\n * @param {number} top - original top position\r\n * @param {number} width - image width\r\n * @param {number} height - image height\r\n * @param {number} cropX - image cropX\r\n * @param {number} cropY - image cropY\r\n * @returns {Object}\r\n */\n\n\nfunction calculateDimensionLeftTopEdge(overflowAreaPositionFixer, {\n left,\n top,\n width,\n height,\n cropX,\n cropY\n}) {\n const dimension = {\n width,\n height\n };\n forEach(['x', 'y'], type => {\n const cropDistance = type === 'x' ? cropX : cropY;\n const compareSize = dimension[POSITION_DIMENSION_MAP[type]];\n const standardSize = cachedCanvasImageElement[POSITION_DIMENSION_MAP[type]];\n\n if (compareSize > standardSize) {\n const outDistance = (compareSize - standardSize) / 2;\n dimension[POSITION_DIMENSION_MAP[type]] = standardSize;\n [left, top] = overflowAreaPositionFixer(type, outDistance, left, top);\n }\n\n if (cropDistance < 0) {\n [left, top] = overflowAreaPositionFixer(type, cropDistance, left, top);\n }\n });\n return [left, top, dimension.width, dimension.height];\n}\n/**\r\n * Make fill property of dynamic pattern type\r\n * @param {fabric.Image} canvasImage - canvas background image\r\n * @param {Array} filterOption - filter option\r\n * @param {fabric.StaticCanvas} patternSourceCanvas - fabric static canvas\r\n * @returns {Object}\r\n */\n\n\nexport function makeFillPatternForFilter(canvasImage, filterOption, patternSourceCanvas) {\n const copiedCanvasElement = getCachedCanvasImageElement(canvasImage);\n const fillImage = makeFillImage(copiedCanvasElement, canvasImage.angle, filterOption);\n patternSourceCanvas.add(fillImage);\n const fabricProperty = {\n fill: new fabric.Pattern({\n source: patternSourceCanvas.getElement(),\n repeat: 'no-repeat'\n })\n };\n setCustomProperty(fabricProperty, {\n patternSourceCanvas\n });\n return fabricProperty;\n}\n/**\r\n * Reset fill pattern canvas\r\n * @param {fabric.StaticCanvas} patternSourceCanvas - fabric static canvas\r\n */\n\nexport function resetFillPatternCanvas(patternSourceCanvas) {\n const [innerImage] = patternSourceCanvas.getObjects();\n let {\n fillImageMaxSize\n } = getCustomProperty(innerImage, 'fillImageMaxSize');\n fillImageMaxSize = Math.max(1, fillImageMaxSize);\n patternSourceCanvas.setDimensions({\n width: fillImageMaxSize,\n height: fillImageMaxSize\n });\n patternSourceCanvas.renderAll();\n}\n/**\r\n * Remake filter pattern image source\r\n * @param {fabric.Object} shapeObj - Shape object\r\n * @param {fabric.Image} canvasImage - canvas background image\r\n */\n\nexport function reMakePatternImageSource(shapeObj, canvasImage) {\n const {\n patternSourceCanvas\n } = getCustomProperty(shapeObj, 'patternSourceCanvas');\n const [fillImage] = patternSourceCanvas.getObjects();\n const filterOption = makeFilterOptionFromFabricImage(fillImage);\n patternSourceCanvas.remove(fillImage);\n const copiedCanvasElement = getCachedCanvasImageElement(canvasImage, true);\n const newFillImage = makeFillImage(copiedCanvasElement, canvasImage.angle, filterOption);\n patternSourceCanvas.add(newFillImage);\n}\n/**\r\n * Calculate a point line outside the canvas.\r\n * @param {fabric.Image} canvasImage - canvas background image\r\n * @param {boolean} reset - default is false\r\n * @returns {HTMLImageElement}\r\n */\n\nexport function getCachedCanvasImageElement(canvasImage, reset = false) {\n if (!cachedCanvasImageElement || reset) {\n cachedCanvasImageElement = canvasImage.toCanvasElement();\n }\n\n return cachedCanvasImageElement;\n}\n/**\r\n * Calculate fill image position for out of Canvas\r\n * @param {string} type - 'x' or 'y'\r\n * @param {fabric.Object} shapeObj - shape object\r\n * @param {number} outDistance - distance away\r\n * @param {number} left - original left position\r\n * @param {number} top - original top position\r\n * @returns {Array}\r\n */\n\nfunction calculateDistanceOverflowPart({\n type,\n shapeObj,\n outDistance,\n left,\n top,\n flipX,\n flipY\n}) {\n const shapePointNavigation = getShapeEdgePoint(shapeObj);\n const shapeNeighborPointNavigation = [[1, 2], [0, 3], [0, 3], [1, 2]];\n const linePointsOutsideCanvas = calculateLinePointsOutsideCanvas(type, shapePointNavigation, shapeNeighborPointNavigation);\n const reatAngles = calculateLineAngleOfOutsideCanvas(type, shapePointNavigation, linePointsOutsideCanvas);\n const {\n startPointIndex\n } = linePointsOutsideCanvas;\n const diffPosition = getReversePositionForFlip({\n outDistance,\n startPointIndex,\n flipX,\n flipY,\n reatAngles\n });\n return [left + diffPosition.left, top + diffPosition.top];\n}\n/**\r\n * Calculate fill image position for out of Canvas\r\n * @param {number} outDistance - distance away\r\n * @param {boolean} flipX - flip x statux\r\n * @param {boolean} flipY - flip y statux\r\n * @param {Array} reatAngles - Line angle of the rectangle vertex.\r\n * @returns {Object} diffPosition\r\n */\n\n\nfunction getReversePositionForFlip({\n outDistance,\n startPointIndex,\n flipX,\n flipY,\n reatAngles\n}) {\n const rotationChangePoint1 = outDistance * Math.cos(reatAngles[0] * Math.PI / 180);\n const rotationChangePoint2 = outDistance * Math.cos(reatAngles[1] * Math.PI / 180);\n const isForward = startPointIndex === 2 || startPointIndex === 3;\n const diffPosition = {\n top: isForward ? rotationChangePoint1 : rotationChangePoint2,\n left: isForward ? rotationChangePoint2 : rotationChangePoint1\n };\n\n if (isReverseLeftPositionForFlip(startPointIndex, flipX, flipY)) {\n diffPosition.left = diffPosition.left * -1;\n }\n\n if (isReverseTopPositionForFlip(startPointIndex, flipX, flipY)) {\n diffPosition.top = diffPosition.top * -1;\n }\n\n return diffPosition;\n}\n/**\r\n * Calculate a point line outside the canvas.\r\n * @param {string} type - 'x' or 'y'\r\n * @param {Array} shapePointNavigation - shape edge positions\r\n * @param {Object} shapePointNavigation.lefttop - left top position\r\n * @param {Object} shapePointNavigation.righttop - right top position\r\n * @param {Object} shapePointNavigation.leftbottom - lefttop position\r\n * @param {Object} shapePointNavigation.rightbottom - rightbottom position\r\n * @param {Array} shapeNeighborPointNavigation - Array to find adjacent edges.\r\n * @returns {Object}\r\n */\n\n\nfunction calculateLinePointsOutsideCanvas(type, shapePointNavigation, shapeNeighborPointNavigation) {\n let minimumPoint = 0;\n let minimumPointIndex = 0;\n forEach(shapePointNavigation, (point, index) => {\n if (point[type] < minimumPoint) {\n minimumPoint = point[type];\n minimumPointIndex = index;\n }\n });\n const [endPointIndex1, endPointIndex2] = shapeNeighborPointNavigation[minimumPointIndex];\n return {\n startPointIndex: minimumPointIndex,\n endPointIndex1,\n endPointIndex2\n };\n}\n/**\r\n * Calculate a point line outside the canvas.\r\n * @param {string} type - 'x' or 'y'\r\n * @param {Array} shapePointNavigation - shape edge positions\r\n * @param {object} shapePointNavigation.lefttop - left top position\r\n * @param {object} shapePointNavigation.righttop - right top position\r\n * @param {object} shapePointNavigation.leftbottom - lefttop position\r\n * @param {object} shapePointNavigation.rightbottom - rightbottom position\r\n * @param {Object} linePointsOfOneVertexIndex - Line point of one vertex\r\n * @param {Object} linePointsOfOneVertexIndex.startPoint - start point index\r\n * @param {Object} linePointsOfOneVertexIndex.endPointIndex1 - end point index\r\n * @param {Object} linePointsOfOneVertexIndex.endPointIndex2 - end point index\r\n * @returns {Object}\r\n */\n\n\nfunction calculateLineAngleOfOutsideCanvas(type, shapePointNavigation, linePointsOfOneVertexIndex) {\n const {\n startPointIndex,\n endPointIndex1,\n endPointIndex2\n } = linePointsOfOneVertexIndex;\n const horizontalVerticalAngle = type === 'x' ? 180 : 270;\n return map([endPointIndex1, endPointIndex2], pointIndex => {\n const startPoint = shapePointNavigation[startPointIndex];\n const endPoint = shapePointNavigation[pointIndex];\n const diffY = startPoint.y - endPoint.y;\n const diffX = startPoint.x - endPoint.x;\n return Math.atan2(diffY, diffX) * 180 / Math.PI - horizontalVerticalAngle;\n });\n}\n/* eslint-disable complexity */\n\n/**\r\n * Calculate a point line outside the canvas for horizontal.\r\n * @param {number} startPointIndex - start point index\r\n * @param {boolean} flipX - flip x statux\r\n * @param {boolean} flipY - flip y statux\r\n * @returns {boolean} flipY - flip y statux\r\n */\n\n\nfunction isReverseLeftPositionForFlip(startPointIndex, flipX, flipY) {\n return (!flipX && flipY || !flipX && !flipY) && startPointIndex === 0 || (flipX && flipY || flipX && !flipY) && startPointIndex === 1 || (!flipX && !flipY || !flipX && flipY) && startPointIndex === 2 || (flipX && !flipY || flipX && flipY) && startPointIndex === 3;\n}\n/* eslint-enable complexity */\n\n/* eslint-disable complexity */\n\n/**\r\n * Calculate a point line outside the canvas for vertical.\r\n * @param {number} startPointIndex - start point index\r\n * @param {boolean} flipX - flip x statux\r\n * @param {boolean} flipY - flip y statux\r\n * @returns {boolean} flipY - flip y statux\r\n */\n\n\nfunction isReverseTopPositionForFlip(startPointIndex, flipX, flipY) {\n return (flipX && !flipY || !flipX && !flipY) && startPointIndex === 0 || (!flipX && !flipY || flipX && !flipY) && startPointIndex === 1 || (flipX && flipY || !flipX && flipY) && startPointIndex === 2 || (!flipX && flipY || flipX && flipY) && startPointIndex === 3;\n}\n/* eslint-enable complexity */\n\n/**\r\n * Shape edge points\r\n * @param {fabric.Object} shapeObj - Selected shape object on canvas\r\n * @returns {Array} shapeEdgePoint - shape edge positions\r\n */\n\n\nfunction getShapeEdgePoint(shapeObj) {\n return [shapeObj.getPointByOrigin('left', 'top'), shapeObj.getPointByOrigin('right', 'top'), shapeObj.getPointByOrigin('left', 'bottom'), shapeObj.getPointByOrigin('right', 'bottom')];\n}\n/**\r\n * Rotated shape dimension\r\n * @param {fabric.Object} shapeObj - Shape object\r\n * @returns {Object} Rotated shape dimension\r\n */\n\n\nfunction getRotatedDimension(shapeObj) {\n const [{\n x: ax,\n y: ay\n }, {\n x: bx,\n y: by\n }, {\n x: cx,\n y: cy\n }, {\n x: dx,\n y: dy\n }] = getShapeEdgePoint(shapeObj);\n const left = Math.min(ax, bx, cx, dx);\n const top = Math.min(ay, by, cy, dy);\n const right = Math.max(ax, bx, cx, dx);\n const bottom = Math.max(ay, by, cy, dy);\n return {\n left,\n top,\n right,\n bottom,\n width: right - left,\n height: bottom - top\n };\n}\n/**\r\n * Make fill image\r\n * @param {HTMLImageElement} copiedCanvasElement - html image element\r\n * @param {number} currentCanvasImageAngle - current canvas angle\r\n * @param {Array} filterOption - filter option\r\n * @returns {fabric.Image}\r\n * @private\r\n */\n\n\nfunction makeFillImage(copiedCanvasElement, currentCanvasImageAngle, filterOption) {\n const fillImage = new fabric.Image(copiedCanvasElement);\n forEach(extend({}, ...filterOption), (value, key) => {\n const fabricFiterClassName = capitalizeString(key);\n const filter = new fabric.Image.filters[fabricFiterClassName]({\n [FILTER_OPTION_MAP[key]]: value\n });\n fillImage.filters.push(filter);\n });\n fillImage.applyFilters();\n setCustomProperty(fillImage, {\n originalAngle: currentCanvasImageAngle,\n fillImageMaxSize: Math.max(fillImage.width, fillImage.height)\n });\n resizeHelper.adjustOriginToCenter(fillImage);\n return fillImage;\n}\n\nvar _c;\n\n$RefreshReg$(_c, \"FILTER_NAME_VALUE_MAP\");","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/src/js/helper/shapeFilterFillHelper.js"],"names":["forEach","map","extend","capitalizeString","flipObject","setCustomProperty","getCustomProperty","resizeHelper","FILTER_OPTION_MAP","pixelate","blur","POSITION_DIMENSION_MAP","x","y","FILTER_NAME_VALUE_MAP","cachedCanvasImageElement","getFillImageFromShape","shapeObj","patternSourceCanvas","fillImage","getObjects","rePositionFilterTypeFillImage","angle","flipX","flipY","rotatedShapeCornerDimension","getRotatedDimension","right","bottom","width","height","diffLeft","diffTop","cropX","left","cropY","top","fillImageMaxSize","Math","max","calculateFillImageDimensionOutsideCanvas","set","makeFilterOptionFromFabricImage","imageObject","filters","filter","key","Object","keys","overflowAreaPositionFixer","type","outDistance","imageLeft","imageTop","calculateDistanceOverflowPart","originalWidth","originalHeight","calculateDimensionLeftTopEdge","calculateDimensionRightBottomEdge","insideCanvasRealImageWidth","insideCanvasRealImageHeight","canvasWidth","canvasHeight","abs","diff","cropDistance2","dimension","cropDistance","compareSize","standardSize","makeFillPatternForFilter","canvasImage","filterOption","copiedCanvasElement","getCachedCanvasImageElement","makeFillImage","add","fabricProperty","fill","fabric","Pattern","source","getElement","repeat","resetFillPatternCanvas","innerImage","setDimensions","renderAll","reMakePatternImageSource","remove","newFillImage","reset","toCanvasElement","shapePointNavigation","getShapeEdgePoint","shapeNeighborPointNavigation","linePointsOutsideCanvas","calculateLinePointsOutsideCanvas","reatAngles","calculateLineAngleOfOutsideCanvas","startPointIndex","diffPosition","getReversePositionForFlip","rotationChangePoint1","cos","PI","rotationChangePoint2","isForward","isReverseLeftPositionForFlip","isReverseTopPositionForFlip","minimumPoint","minimumPointIndex","point","index","endPointIndex1","endPointIndex2","linePointsOfOneVertexIndex","horizontalVerticalAngle","pointIndex","startPoint","endPoint","diffY","diffX","atan2","getPointByOrigin","ax","ay","bx","by","cx","cy","dx","dy","min","currentCanvasImageAngle","Image","value","fabricFiterClassName","push","applyFilters","originalAngle","adjustOriginToCenter"],"mappings":"AAAA;AACA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,GAAlB,EAAuBC,MAAvB,QAAqC,kBAArC;AACA,SAASC,gBAAT,EAA2BC,UAA3B,EAAuCC,iBAAvC,EAA0DC,iBAA1D,QAAmF,SAAnF;AACA,OAAOC,YAAP,MAAyB,6BAAzB;AAEA,MAAMC,iBAAiB,GAAG;AACxBC,EAAAA,QAAQ,EAAE,WADc;AAExBC,EAAAA,IAAI,EAAE;AAFkB,CAA1B;AAIA,MAAMC,sBAAsB,GAAG;AAC7BC,EAAAA,CAAC,EAAE,OAD0B;AAE7BC,EAAAA,CAAC,EAAE;AAF0B,CAA/B;AAKA,MAAMC,qBAAqB,GAAGV,UAAU,CAACI,iBAAD,CAAxC;AAEA;AACA;AACA;AACA;AACA;;KANMM,qB;AAON,IAAIC,wBAAwB,GAAG,IAA/B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAA+BC,QAA/B,EAAyC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAA0BZ,iBAAiB,CAACW,QAAD,EAAW,qBAAX,CAAjD;AACA,QAAM,CAACE,SAAD,IAAcD,mBAAmB,CAACE,UAApB,EAApB;AAEA,SAAOD,SAAP;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,6BAAT,CAAuCJ,QAAvC,EAAiD;AACtD,QAAM;AAAEK,IAAAA,KAAF;AAASC,IAAAA,KAAT;AAAgBC,IAAAA;AAAhB,MAA0BP,QAAhC;AACA,QAAME,SAAS,GAAGH,qBAAqB,CAACC,QAAD,CAAvC;AACA,QAAMQ,2BAA2B,GAAGC,mBAAmB,CAACT,QAAD,CAAvD;AACA,QAAM;AAAEU,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAoBH,2BAA1B;A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EAAqBE,EAArB,CAAf;AAEA,SAAO;AACLlG,IAAAA,IADK;AAELE,IAAAA,GAFK;AAGLT,IAAAA,KAHK;AAILC,IAAAA,MAJK;AAKLC,IAAAA,KAAK,EAAEF,KAAK,GAAGO,IALV;AAMLJ,IAAAA,MAAM,EAAEF,MAAM,GAAGQ;AANZ,GAAP;AAQD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASuC,aAAT,CAAuBF,mBAAvB,EAA4C6D,uBAA5C,EAAqE9D,YAArE,EAAmF;AACjF,QAAMrD,SAAS,GAAG,IAAI4D,MAAM,CAACwD,KAAX,CAAiB9D,mBAAjB,CAAlB;AAEAzE,EAAAA,OAAO,CAACE,MAAM,CAAC,EAAD,EAAK,GAAGsE,YAAR,CAAP,EAA8B,CAACgE,KAAD,EAAQ1F,GAAR,KAAgB;AACnD,UAAM2F,oBAAoB,GAAGtI,gBAAgB,CAAC2C,GAAD,CAA7C;AACA,UAAMD,MAAM,GAAG,IAAIkC,MAAM,CAACwD,KAAP,CAAa3F,OAAb,CAAqB6F,oBAArB,CAAJ,CAA+C;AAC5D,OAACjI,iBAAiB,CAACsC,GAAD,CAAlB,GAA0B0F;AADkC,KAA/C,CAAf;AAGArH,IAAAA,SAAS,CAACyB,OAAV,CAAkB8F,IAAlB,CAAuB7F,MAAvB;AACD,GANM,CAAP;AAOA1B,EAAAA,SAAS,CAACwH,YAAV;AAEAtI,EAAAA,iBAAiB,CAACc,SAAD,EAAY;AAC3ByH,IAAAA,aAAa,EAAEN,uBADY;AAE3BjG,IAAAA,gBAAgB,EAAEC,IAAI,CAACC,GAAL,CAASpB,SAAS,CAACU,KAAnB,EAA0BV,SAAS,CAACW,MAApC;AAFS,GAAZ,CAAjB;AAIAvB,EAAAA,YAAY,CAACsI,oBAAb,CAAkC1H,SAAlC;AAEA,SAAOA,SAAP;AACD","sourcesContent":["/**\r\n * @author NHN. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Shape resize helper\r\n */\r\nimport { forEach, map, extend } from 'tui-code-snippet';\r\nimport { capitalizeString, flipObject, setCustomProperty, getCustomProperty } from '../util';\r\nimport resizeHelper from '../helper/shapeResizeHelper';\r\n\r\nconst FILTER_OPTION_MAP = {\r\n pixelate: 'blocksize',\r\n blur: 'blur',\r\n};\r\nconst POSITION_DIMENSION_MAP = {\r\n x: 'width',\r\n y: 'height',\r\n};\r\n\r\nconst FILTER_NAME_VALUE_MAP = flipObject(FILTER_OPTION_MAP);\r\n\r\n/**\r\n * Cached canvas image element for fill image\r\n * @type {boolean}\r\n * @private\r\n */\r\nlet cachedCanvasImageElement = null;\r\n\r\n/**\r\n * Get background image of fill\r\n * @param {fabric.Object} shapeObj - Shape object\r\n * @returns {fabric.Image}\r\n * @private\r\n */\r\nexport function getFillImageFromShape(shapeObj) {\r\n const { patternSourceCanvas } = getCustomProperty(shapeObj, 'patternSourceCanvas');\r\n const [fillImage] = patternSourceCanvas.getObjects();\r\n\r\n return fillImage;\r\n}\r\n\r\n/**\r\n * Reset the image position in the filter type fill area.\r\n * @param {fabric.Object} shapeObj - Shape object\r\n * @private\r\n */\r\nexport function rePositionFilterTypeFillImage(shapeObj) {\r\n const { angle, flipX, flipY } = shapeObj;\r\n const fillImage = getFillImageFromShape(shapeObj);\r\n const rotatedShapeCornerDimension = getRotatedDimension(shapeObj);\r\n const { right, bottom } = rotatedShapeCornerDimension;\r\n let { width, height } = rotatedShapeCornerDimension;\r\n const diffLeft = (width - shapeObj.width) / 2;\r\n const diffTop = (height - shapeObj.height) / 2;\r\n const cropX = shapeObj.left - shapeObj.width / 2 - diffLeft;\r\n const cropY = shapeObj.top - shapeObj.height / 2 - diffTop;\r\n let left = width / 2 - diffLeft;\r\n let top = height / 2 - diffTop;\r\n const fillImageMaxSize = Math.max(width, height) + Math.max(diffLeft, diffTop);\r\n\r\n [left, top, width, height] = calculateFillImageDimensionOutsideCanvas({\r\n shapeObj,\r\n left,\r\n top,\r\n width,\r\n height,\r\n cropX,\r\n cropY,\r\n flipX,\r\n flipY,\r\n right,\r\n bottom,\r\n });\r\n\r\n fillImage.set({\r\n angle: flipX === flipY ? -angle : angle,\r\n left,\r\n top,\r\n width,\r\n height,\r\n cropX,\r\n cropY,\r\n flipX,\r\n flipY,\r\n });\r\n\r\n setCustomProperty(fillImage, { fillImageMaxSize });\r\n}\r\n\r\n/**\r\n * Make filter option from fabric image\r\n * @param {fabric.Image} imageObject - fabric image object\r\n * @returns {object}\r\n */\r\nexport function makeFilterOptionFromFabricImage(imageObject) {\r\n return map(imageObject.filters, (filter) => {\r\n const [key] = Object.keys(filter);\r\n\r\n return {\r\n [FILTER_NAME_VALUE_MAP[key]]: filter[key],\r\n };\r\n });\r\n}\r\n\r\n/**\r\n * Calculate fill image position and size for out of Canvas\r\n * @param {Object} options - options for position dimension calculate\r\n * @param {fabric.Object} shapeObj - shape object\r\n * @param {number} left - original left position\r\n * @param {number} top - original top position\r\n * @param {number} width - image width\r\n * @param {number} height - image height\r\n * @param {number} cropX - image cropX\r\n * @param {number} cropY - image cropY\r\n * @param {boolean} flipX - shape flipX\r\n * @param {boolean} flipY - shape flipY\r\n * @returns {Object}\r\n */\r\nfunction calculateFillImageDimensionOutsideCanvas({\r\n shapeObj,\r\n left,\r\n top,\r\n width,\r\n height,\r\n cropX,\r\n cropY,\r\n flipX,\r\n flipY,\r\n right,\r\n bottom,\r\n}) {\r\n const overflowAreaPositionFixer = (type, outDistance, imageLeft, imageTop) =>\r\n calculateDistanceOverflowPart({\r\n type,\r\n outDistance,\r\n shapeObj,\r\n flipX,\r\n flipY,\r\n left: imageLeft,\r\n top: imageTop,\r\n });\r\n const [originalWidth, originalHeight] = [width, height];\r\n\r\n [left, top, width, height] = calculateDimensionLeftTopEdge(overflowAreaPositionFixer, {\r\n left,\r\n top,\r\n width,\r\n height,\r\n cropX,\r\n cropY,\r\n });\r\n\r\n [left, top, width, height] = calculateDimensionRightBottomEdge(overflowAreaPositionFixer, {\r\n left,\r\n top,\r\n insideCanvasRealImageWidth: width,\r\n insideCanvasRealImageHeight: height,\r\n right,\r\n bottom,\r\n cropX,\r\n cropY,\r\n originalWidth,\r\n originalHeight,\r\n });\r\n\r\n return [left, top, width, height];\r\n}\r\n\r\n/**\r\n * Calculate fill image position and size for for right bottom edge\r\n * @param {Function} overflowAreaPositionFixer - position fixer\r\n * @param {Object} options - options for position dimension calculate\r\n * @param {fabric.Object} shapeObj - shape object\r\n * @param {number} left - original left position\r\n * @param {number} top - original top position\r\n * @param {number} width - image width\r\n * @param {number} height - image height\r\n * @param {number} right - image right\r\n * @param {number} bottom - image bottom\r\n * @param {number} cropX - image cropX\r\n * @param {number} cropY - image cropY\r\n * @param {boolean} originalWidth - image original width\r\n * @param {boolean} originalHeight - image original height\r\n * @returns {Object}\r\n */\r\nfunction calculateDimensionRightBottomEdge(\r\n overflowAreaPositionFixer,\r\n {\r\n left,\r\n top,\r\n insideCanvasRealImageWidth,\r\n insideCanvasRealImageHeight,\r\n right,\r\n bottom,\r\n cropX,\r\n cropY,\r\n originalWidth,\r\n originalHeight,\r\n }\r\n) {\r\n let [width, height] = [insideCanvasRealImageWidth, insideCanvasRealImageHeight];\r\n const { width: canvasWidth, height: canvasHeight } = cachedCanvasImageElement;\r\n\r\n if (right > canvasWidth && cropX > 0) {\r\n width = originalWidth - Math.abs(right - canvasWidth);\r\n }\r\n if (bottom > canvasHeight && cropY > 0) {\r\n height = originalHeight - Math.abs(bottom - canvasHeight);\r\n }\r\n\r\n const diff = {\r\n x: (insideCanvasRealImageWidth - width) / 2,\r\n y: (insideCanvasRealImageHeight - height) / 2,\r\n };\r\n\r\n forEach(['x', 'y'], (type) => {\r\n const cropDistance2 = diff[type];\r\n if (cropDistance2 > 0) {\r\n [left, top] = overflowAreaPositionFixer(type, cropDistance2, left, top);\r\n }\r\n });\r\n\r\n return [left, top, width, height];\r\n}\r\n\r\n/**\r\n * Calculate fill image position and size for for left top\r\n * @param {Function} overflowAreaPositionFixer - position fixer\r\n * @param {Object} options - options for position dimension calculate\r\n * @param {fabric.Object} shapeObj - shape object\r\n * @param {number} left - original left position\r\n * @param {number} top - original top position\r\n * @param {number} width - image width\r\n * @param {number} height - image height\r\n * @param {number} cropX - image cropX\r\n * @param {number} cropY - image cropY\r\n * @returns {Object}\r\n */\r\nfunction calculateDimensionLeftTopEdge(\r\n overflowAreaPositionFixer,\r\n { left, top, width, height, cropX, cropY }\r\n) {\r\n const dimension = {\r\n width,\r\n height,\r\n };\r\n\r\n forEach(['x', 'y'], (type) => {\r\n const cropDistance = type === 'x' ? cropX : cropY;\r\n const compareSize = dimension[POSITION_DIMENSION_MAP[type]];\r\n const standardSize = cachedCanvasImageElement[POSITION_DIMENSION_MAP[type]];\r\n\r\n if (compareSize > standardSize) {\r\n const outDistance = (compareSize - standardSize) / 2;\r\n\r\n dimension[POSITION_DIMENSION_MAP[type]] = standardSize;\r\n [left, top] = overflowAreaPositionFixer(type, outDistance, left, top);\r\n }\r\n if (cropDistance < 0) {\r\n [left, top] = overflowAreaPositionFixer(type, cropDistance, left, top);\r\n }\r\n });\r\n\r\n return [left, top, dimension.width, dimension.height];\r\n}\r\n\r\n/**\r\n * Make fill property of dynamic pattern type\r\n * @param {fabric.Image} canvasImage - canvas background image\r\n * @param {Array} filterOption - filter option\r\n * @param {fabric.StaticCanvas} patternSourceCanvas - fabric static canvas\r\n * @returns {Object}\r\n */\r\nexport function makeFillPatternForFilter(canvasImage, filterOption, patternSourceCanvas) {\r\n const copiedCanvasElement = getCachedCanvasImageElement(canvasImage);\r\n const fillImage = makeFillImage(copiedCanvasElement, canvasImage.angle, filterOption);\r\n patternSourceCanvas.add(fillImage);\r\n\r\n const fabricProperty = {\r\n fill: new fabric.Pattern({\r\n source: patternSourceCanvas.getElement(),\r\n repeat: 'no-repeat',\r\n }),\r\n };\r\n\r\n setCustomProperty(fabricProperty, { patternSourceCanvas });\r\n\r\n return fabricProperty;\r\n}\r\n\r\n/**\r\n * Reset fill pattern canvas\r\n * @param {fabric.StaticCanvas} patternSourceCanvas - fabric static canvas\r\n */\r\nexport function resetFillPatternCanvas(patternSourceCanvas) {\r\n const [innerImage] = patternSourceCanvas.getObjects();\r\n let { fillImageMaxSize } = getCustomProperty(innerImage, 'fillImageMaxSize');\r\n fillImageMaxSize = Math.max(1, fillImageMaxSize);\r\n\r\n patternSourceCanvas.setDimensions({\r\n width: fillImageMaxSize,\r\n height: fillImageMaxSize,\r\n });\r\n patternSourceCanvas.renderAll();\r\n}\r\n\r\n/**\r\n * Remake filter pattern image source\r\n * @param {fabric.Object} shapeObj - Shape object\r\n * @param {fabric.Image} canvasImage - canvas background image\r\n */\r\nexport function reMakePatternImageSource(shapeObj, canvasImage) {\r\n const { patternSourceCanvas } = getCustomProperty(shapeObj, 'patternSourceCanvas');\r\n const [fillImage] = patternSourceCanvas.getObjects();\r\n const filterOption = makeFilterOptionFromFabricImage(fillImage);\r\n\r\n patternSourceCanvas.remove(fillImage);\r\n\r\n const copiedCanvasElement = getCachedCanvasImageElement(canvasImage, true);\r\n const newFillImage = makeFillImage(copiedCanvasElement, canvasImage.angle, filterOption);\r\n\r\n patternSourceCanvas.add(newFillImage);\r\n}\r\n\r\n/**\r\n * Calculate a point line outside the canvas.\r\n * @param {fabric.Image} canvasImage - canvas background image\r\n * @param {boolean} reset - default is false\r\n * @returns {HTMLImageElement}\r\n */\r\nexport function getCachedCanvasImageElement(canvasImage, reset = false) {\r\n if (!cachedCanvasImageElement || reset) {\r\n cachedCanvasImageElement = canvasImage.toCanvasElement();\r\n }\r\n\r\n return cachedCanvasImageElement;\r\n}\r\n\r\n/**\r\n * Calculate fill image position for out of Canvas\r\n * @param {string} type - 'x' or 'y'\r\n * @param {fabric.Object} shapeObj - shape object\r\n * @param {number} outDistance - distance away\r\n * @param {number} left - original left position\r\n * @param {number} top - original top position\r\n * @returns {Array}\r\n */\r\nfunction calculateDistanceOverflowPart({ type, shapeObj, outDistance, left, top, flipX, flipY }) {\r\n const shapePointNavigation = getShapeEdgePoint(shapeObj);\r\n const shapeNeighborPointNavigation = [\r\n [1, 2],\r\n [0, 3],\r\n [0, 3],\r\n [1, 2],\r\n ];\r\n const linePointsOutsideCanvas = calculateLinePointsOutsideCanvas(\r\n type,\r\n shapePointNavigation,\r\n shapeNeighborPointNavigation\r\n );\r\n const reatAngles = calculateLineAngleOfOutsideCanvas(\r\n type,\r\n shapePointNavigation,\r\n linePointsOutsideCanvas\r\n );\r\n const { startPointIndex } = linePointsOutsideCanvas;\r\n const diffPosition = getReversePositionForFlip({\r\n outDistance,\r\n startPointIndex,\r\n flipX,\r\n flipY,\r\n reatAngles,\r\n });\r\n\r\n return [left + diffPosition.left, top + diffPosition.top];\r\n}\r\n\r\n/**\r\n * Calculate fill image position for out of Canvas\r\n * @param {number} outDistance - distance away\r\n * @param {boolean} flipX - flip x statux\r\n * @param {boolean} flipY - flip y statux\r\n * @param {Array} reatAngles - Line angle of the rectangle vertex.\r\n * @returns {Object} diffPosition\r\n */\r\nfunction getReversePositionForFlip({ outDistance, startPointIndex, flipX, flipY, reatAngles }) {\r\n const rotationChangePoint1 = outDistance * Math.cos((reatAngles[0] * Math.PI) / 180);\r\n const rotationChangePoint2 = outDistance * Math.cos((reatAngles[1] * Math.PI) / 180);\r\n const isForward = startPointIndex === 2 || startPointIndex === 3;\r\n const diffPosition = {\r\n top: isForward ? rotationChangePoint1 : rotationChangePoint2,\r\n left: isForward ? rotationChangePoint2 : rotationChangePoint1,\r\n };\r\n\r\n if (isReverseLeftPositionForFlip(startPointIndex, flipX, flipY)) {\r\n diffPosition.left = diffPosition.left * -1;\r\n }\r\n if (isReverseTopPositionForFlip(startPointIndex, flipX, flipY)) {\r\n diffPosition.top = diffPosition.top * -1;\r\n }\r\n\r\n return diffPosition;\r\n}\r\n\r\n/**\r\n * Calculate a point line outside the canvas.\r\n * @param {string} type - 'x' or 'y'\r\n * @param {Array} shapePointNavigation - shape edge positions\r\n * @param {Object} shapePointNavigation.lefttop - left top position\r\n * @param {Object} shapePointNavigation.righttop - right top position\r\n * @param {Object} shapePointNavigation.leftbottom - lefttop position\r\n * @param {Object} shapePointNavigation.rightbottom - rightbottom position\r\n * @param {Array} shapeNeighborPointNavigation - Array to find adjacent edges.\r\n * @returns {Object}\r\n */\r\nfunction calculateLinePointsOutsideCanvas(\r\n type,\r\n shapePointNavigation,\r\n shapeNeighborPointNavigation\r\n) {\r\n let minimumPoint = 0;\r\n let minimumPointIndex = 0;\r\n forEach(shapePointNavigation, (point, index) => {\r\n if (point[type] < minimumPoint) {\r\n minimumPoint = point[type];\r\n minimumPointIndex = index;\r\n }\r\n });\r\n\r\n const [endPointIndex1, endPointIndex2] = shapeNeighborPointNavigation[minimumPointIndex];\r\n\r\n return {\r\n startPointIndex: minimumPointIndex,\r\n endPointIndex1,\r\n endPointIndex2,\r\n };\r\n}\r\n\r\n/**\r\n * Calculate a point line outside the canvas.\r\n * @param {string} type - 'x' or 'y'\r\n * @param {Array} shapePointNavigation - shape edge positions\r\n * @param {object} shapePointNavigation.lefttop - left top position\r\n * @param {object} shapePointNavigation.righttop - right top position\r\n * @param {object} shapePointNavigation.leftbottom - lefttop position\r\n * @param {object} shapePointNavigation.rightbottom - rightbottom position\r\n * @param {Object} linePointsOfOneVertexIndex - Line point of one vertex\r\n * @param {Object} linePointsOfOneVertexIndex.startPoint - start point index\r\n * @param {Object} linePointsOfOneVertexIndex.endPointIndex1 - end point index\r\n * @param {Object} linePointsOfOneVertexIndex.endPointIndex2 - end point index\r\n * @returns {Object}\r\n */\r\nfunction calculateLineAngleOfOutsideCanvas(type, shapePointNavigation, linePointsOfOneVertexIndex) {\r\n const { startPointIndex, endPointIndex1, endPointIndex2 } = linePointsOfOneVertexIndex;\r\n const horizontalVerticalAngle = type === 'x' ? 180 : 270;\r\n\r\n return map([endPointIndex1, endPointIndex2], (pointIndex) => {\r\n const startPoint = shapePointNavigation[startPointIndex];\r\n const endPoint = shapePointNavigation[pointIndex];\r\n const diffY = startPoint.y - endPoint.y;\r\n const diffX = startPoint.x - endPoint.x;\r\n\r\n return (Math.atan2(diffY, diffX) * 180) / Math.PI - horizontalVerticalAngle;\r\n });\r\n}\r\n\r\n/* eslint-disable complexity */\r\n/**\r\n * Calculate a point line outside the canvas for horizontal.\r\n * @param {number} startPointIndex - start point index\r\n * @param {boolean} flipX - flip x statux\r\n * @param {boolean} flipY - flip y statux\r\n * @returns {boolean} flipY - flip y statux\r\n */\r\nfunction isReverseLeftPositionForFlip(startPointIndex, flipX, flipY) {\r\n return (\r\n (((!flipX && flipY) || (!flipX && !flipY)) && startPointIndex === 0) ||\r\n (((flipX && flipY) || (flipX && !flipY)) && startPointIndex === 1) ||\r\n (((!flipX && !flipY) || (!flipX && flipY)) && startPointIndex === 2) ||\r\n (((flipX && !flipY) || (flipX && flipY)) && startPointIndex === 3)\r\n );\r\n}\r\n/* eslint-enable complexity */\r\n\r\n/* eslint-disable complexity */\r\n/**\r\n * Calculate a point line outside the canvas for vertical.\r\n * @param {number} startPointIndex - start point index\r\n * @param {boolean} flipX - flip x statux\r\n * @param {boolean} flipY - flip y statux\r\n * @returns {boolean} flipY - flip y statux\r\n */\r\nfunction isReverseTopPositionForFlip(startPointIndex, flipX, flipY) {\r\n return (\r\n (((flipX && !flipY) || (!flipX && !flipY)) && startPointIndex === 0) ||\r\n (((!flipX && !flipY) || (flipX && !flipY)) && startPointIndex === 1) ||\r\n (((flipX && flipY) || (!flipX && flipY)) && startPointIndex === 2) ||\r\n (((!flipX && flipY) || (flipX && flipY)) && startPointIndex === 3)\r\n );\r\n}\r\n/* eslint-enable complexity */\r\n\r\n/**\r\n * Shape edge points\r\n * @param {fabric.Object} shapeObj - Selected shape object on canvas\r\n * @returns {Array} shapeEdgePoint - shape edge positions\r\n */\r\nfunction getShapeEdgePoint(shapeObj) {\r\n return [\r\n shapeObj.getPointByOrigin('left', 'top'),\r\n shapeObj.getPointByOrigin('right', 'top'),\r\n shapeObj.getPointByOrigin('left', 'bottom'),\r\n shapeObj.getPointByOrigin('right', 'bottom'),\r\n ];\r\n}\r\n\r\n/**\r\n * Rotated shape dimension\r\n * @param {fabric.Object} shapeObj - Shape object\r\n * @returns {Object} Rotated shape dimension\r\n */\r\nfunction getRotatedDimension(shapeObj) {\r\n const [\r\n { x: ax, y: ay },\r\n { x: bx, y: by },\r\n { x: cx, y: cy },\r\n { x: dx, y: dy },\r\n ] = getShapeEdgePoint(shapeObj);\r\n\r\n const left = Math.min(ax, bx, cx, dx);\r\n const top = Math.min(ay, by, cy, dy);\r\n const right = Math.max(ax, bx, cx, dx);\r\n const bottom = Math.max(ay, by, cy, dy);\r\n\r\n return {\r\n left,\r\n top,\r\n right,\r\n bottom,\r\n width: right - left,\r\n height: bottom - top,\r\n };\r\n}\r\n\r\n/**\r\n * Make fill image\r\n * @param {HTMLImageElement} copiedCanvasElement - html image element\r\n * @param {number} currentCanvasImageAngle - current canvas angle\r\n * @param {Array} filterOption - filter option\r\n * @returns {fabric.Image}\r\n * @private\r\n */\r\nfunction makeFillImage(copiedCanvasElement, currentCanvasImageAngle, filterOption) {\r\n const fillImage = new fabric.Image(copiedCanvasElement);\r\n\r\n forEach(extend({}, ...filterOption), (value, key) => {\r\n const fabricFiterClassName = capitalizeString(key);\r\n const filter = new fabric.Image.filters[fabricFiterClassName]({\r\n [FILTER_OPTION_MAP[key]]: value,\r\n });\r\n fillImage.filters.push(filter);\r\n });\r\n fillImage.applyFilters();\r\n\r\n setCustomProperty(fillImage, {\r\n originalAngle: currentCanvasImageAngle,\r\n fillImageMaxSize: Math.max(fillImage.width, fillImage.height),\r\n });\r\n resizeHelper.adjustOriginToCenter(fillImage);\r\n\r\n return fillImage;\r\n}\r\n"]},"metadata":{},"sourceType":"module"}