1 line
6.9 KiB
JSON
1 line
6.9 KiB
JSON
{"ast":null,"code":"var round = Math.round;\nexport function subPixelOptimizeLine(outputShape, inputShape, style) {\n if (!inputShape) {\n return;\n }\n\n var x1 = inputShape.x1;\n var x2 = inputShape.x2;\n var y1 = inputShape.y1;\n var y2 = inputShape.y2;\n outputShape.x1 = x1;\n outputShape.x2 = x2;\n outputShape.y1 = y1;\n outputShape.y2 = y2;\n var lineWidth = style && style.lineWidth;\n\n if (!lineWidth) {\n return outputShape;\n }\n\n if (round(x1 * 2) === round(x2 * 2)) {\n outputShape.x1 = outputShape.x2 = subPixelOptimize(x1, lineWidth, true);\n }\n\n if (round(y1 * 2) === round(y2 * 2)) {\n outputShape.y1 = outputShape.y2 = subPixelOptimize(y1, lineWidth, true);\n }\n\n return outputShape;\n}\nexport function subPixelOptimizeRect(outputShape, inputShape, style) {\n if (!inputShape) {\n return;\n }\n\n var originX = inputShape.x;\n var originY = inputShape.y;\n var originWidth = inputShape.width;\n var originHeight = inputShape.height;\n outputShape.x = originX;\n outputShape.y = originY;\n outputShape.width = originWidth;\n outputShape.height = originHeight;\n var lineWidth = style && style.lineWidth;\n\n if (!lineWidth) {\n return outputShape;\n }\n\n outputShape.x = subPixelOptimize(originX, lineWidth, true);\n outputShape.y = subPixelOptimize(originY, lineWidth, true);\n outputShape.width = Math.max(subPixelOptimize(originX + originWidth, lineWidth, false) - outputShape.x, originWidth === 0 ? 0 : 1);\n outputShape.height = Math.max(subPixelOptimize(originY + originHeight, lineWidth, false) - outputShape.y, originHeight === 0 ? 0 : 1);\n return outputShape;\n}\nexport function subPixelOptimize(position, lineWidth, positiveOrNegative) {\n if (!lineWidth) {\n return position;\n }\n\n var doubledPosition = round(position * 2);\n return (doubledPosition + round(lineWidth)) % 2 === 0 ? doubledPosition / 2 : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;\n}","map":{"version":3,"sources":["D:/Work/WorkSpace/GitWorkSpace/TenShop/resource/ElectronicMall/src/qingge-Market/qingge-vue/node_modules/zrender/lib/graphic/helper/subPixelOptimize.js"],"names":["round","Math","subPixelOptimizeLine","outputShape","inputShape","style","x1","x2","y1","y2","lineWidth","subPixelOptimize","subPixelOptimizeRect","originX","x","originY","y","originWidth","width","originHeight","height","max","position","positiveOrNegative","doubledPosition"],"mappings":"AAAA,IAAIA,KAAK,GAAGC,IAAI,CAACD,KAAjB;AACA,OAAO,SAASE,oBAAT,CAA8BC,WAA9B,EAA2CC,UAA3C,EAAuDC,KAAvD,EAA8D;AACjE,MAAI,CAACD,UAAL,EAAiB;AACb;AACH;;AACD,MAAIE,EAAE,GAAGF,UAAU,CAACE,EAApB;AACA,MAAIC,EAAE,GAAGH,UAAU,CAACG,EAApB;AACA,MAAIC,EAAE,GAAGJ,UAAU,CAACI,EAApB;AACA,MAAIC,EAAE,GAAGL,UAAU,CAACK,EAApB;AACAN,EAAAA,WAAW,CAACG,EAAZ,GAAiBA,EAAjB;AACAH,EAAAA,WAAW,CAACI,EAAZ,GAAiBA,EAAjB;AACAJ,EAAAA,WAAW,CAACK,EAAZ,GAAiBA,EAAjB;AACAL,EAAAA,WAAW,CAACM,EAAZ,GAAiBA,EAAjB;AACA,MAAIC,SAAS,GAAGL,KAAK,IAAIA,KAAK,CAACK,SAA/B;;AACA,MAAI,CAACA,SAAL,EAAgB;AACZ,WAAOP,WAAP;AACH;;AACD,MAAIH,KAAK,CAACM,EAAE,GAAG,CAAN,CAAL,KAAkBN,KAAK,CAACO,EAAE,GAAG,CAAN,CAA3B,EAAqC;AACjCJ,IAAAA,WAAW,CAACG,EAAZ,GAAiBH,WAAW,CAACI,EAAZ,GAAiBI,gBAAgB,CAACL,EAAD,EAAKI,SAAL,EAAgB,IAAhB,CAAlD;AACH;;AACD,MAAIV,KAAK,CAACQ,EAAE,GAAG,CAAN,CAAL,KAAkBR,KAAK,CAACS,EAAE,GAAG,CAAN,CAA3B,EAAqC;AACjCN,IAAAA,WAAW,CAACK,EAAZ,GAAiBL,WAAW,CAACM,EA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,SAAzB,EAAoC,KAApC,CAAhB,GAA6DP,WAAW,CAACa,CAAlF,EAAqFG,YAAY,KAAK,CAAjB,GAAqB,CAArB,GAAyB,CAA9G,CAArB;AACA,SAAOhB,WAAP;AACH;AACD,OAAO,SAASQ,gBAAT,CAA0BW,QAA1B,EAAoCZ,SAApC,EAA+Ca,kBAA/C,EAAmE;AACtE,MAAI,CAACb,SAAL,EAAgB;AACZ,WAAOY,QAAP;AACH;;AACD,MAAIE,eAAe,GAAGxB,KAAK,CAACsB,QAAQ,GAAG,CAAZ,CAA3B;AACA,SAAO,CAACE,eAAe,GAAGxB,KAAK,CAACU,SAAD,CAAxB,IAAuC,CAAvC,KAA6C,CAA7C,GACDc,eAAe,GAAG,CADjB,GAED,CAACA,eAAe,IAAID,kBAAkB,GAAG,CAAH,GAAO,CAAC,CAA9B,CAAhB,IAAoD,CAF1D;AAGH","sourcesContent":["var round = Math.round;\r\nexport function subPixelOptimizeLine(outputShape, inputShape, style) {\r\n if (!inputShape) {\r\n return;\r\n }\r\n var x1 = inputShape.x1;\r\n var x2 = inputShape.x2;\r\n var y1 = inputShape.y1;\r\n var y2 = inputShape.y2;\r\n outputShape.x1 = x1;\r\n outputShape.x2 = x2;\r\n outputShape.y1 = y1;\r\n outputShape.y2 = y2;\r\n var lineWidth = style && style.lineWidth;\r\n if (!lineWidth) {\r\n return outputShape;\r\n }\r\n if (round(x1 * 2) === round(x2 * 2)) {\r\n outputShape.x1 = outputShape.x2 = subPixelOptimize(x1, lineWidth, true);\r\n }\r\n if (round(y1 * 2) === round(y2 * 2)) {\r\n outputShape.y1 = outputShape.y2 = subPixelOptimize(y1, lineWidth, true);\r\n }\r\n return outputShape;\r\n}\r\nexport function subPixelOptimizeRect(outputShape, inputShape, style) {\r\n if (!inputShape) {\r\n return;\r\n }\r\n var originX = inputShape.x;\r\n var originY = inputShape.y;\r\n var originWidth = inputShape.width;\r\n var originHeight = inputShape.height;\r\n outputShape.x = originX;\r\n outputShape.y = originY;\r\n outputShape.width = originWidth;\r\n outputShape.height = originHeight;\r\n var lineWidth = style && style.lineWidth;\r\n if (!lineWidth) {\r\n return outputShape;\r\n }\r\n outputShape.x = subPixelOptimize(originX, lineWidth, true);\r\n outputShape.y = subPixelOptimize(originY, lineWidth, true);\r\n outputShape.width = Math.max(subPixelOptimize(originX + originWidth, lineWidth, false) - outputShape.x, originWidth === 0 ? 0 : 1);\r\n outputShape.height = Math.max(subPixelOptimize(originY + originHeight, lineWidth, false) - outputShape.y, originHeight === 0 ? 0 : 1);\r\n return outputShape;\r\n}\r\nexport function subPixelOptimize(position, lineWidth, positiveOrNegative) {\r\n if (!lineWidth) {\r\n return position;\r\n }\r\n var doubledPosition = round(position * 2);\r\n return (doubledPosition + round(lineWidth)) % 2 === 0\r\n ? doubledPosition / 2\r\n : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;\r\n}\r\n"]},"metadata":{},"sourceType":"module"} |