22 * @Description :
33 * @Author : zk
44 * @Date : 2021-11-18 15:08:54
5- * @LastEditors : Do not edit
6- * @LastEditTime : 2022-05-12 15:52:44
5+ * @LastEditors : zk
6+ * @LastEditTime : 2022-06-13 19:14:58
77 */
8- import { fabric } from " fabric" ;
9- import PlotPolylineObject from " ../PlotPolylineObject" ;
8+ import { fabric } from ' fabric' ;
9+ import PlotPolylineObject from ' ../PlotPolylineObject' ;
1010
11- const PlotIrregularShape = fabric . util . createClass ( PlotPolylineObject , {
12- hasBorders : false ,
13- _calcBounds : function _calcBounds ( ctx ) {
14- const boundingBox = this . _elem . getBounds ( ) ;
15- this . m_coordsPx . forEach ( ( t ) => {
16- boundingBox . addPnt ( t . x , t . y ) ;
17- } ) ;
18- return boundingBox ;
19- } ,
20- _pathElementRender : function _pathElementRender ( ctx , coords ) {
21- const style = this . _elem . getContextStyle ( ) ;
22- const lineWidth = this . calcMapScaleLineWidth ( style . lineWidth ) ;
23- this . _pointsToPath ( ctx , { ...style , lineWidth } , coords ) ;
24- } ,
25- _comparePathElementRender : function _comparePathElementRender ( ctx , coords ) {
26- const style = this . _elem . getContextStyle ( ) ;
27- const lineWidth = this . calcMapScaleLineWidth ( style . lineWidth ) ;
28- const {
29- compareLine,
30- compareLineWidth,
31- compareLineColor,
32- compareLineOpacity,
33- } = this . _elem ;
34- const compareLineWidthMapScale =
35- this . calcMapScaleLineWidth ( compareLineWidth ) ;
36- const _compareStyle = this . _comparePathStyle ( {
37- compareLine,
38- compareLineWidth : compareLineWidthMapScale ,
39- compareLineColor,
40- compareLineOpacity,
41- ...style ,
42- lineWidth,
43- } ) ;
44- if ( _compareStyle ) {
45- this . _pointsToPath ( ctx , _compareStyle , coords ) ;
11+ const PlotIrregularShape = fabric . util . createClass ( PlotPolylineObject , {
12+ hasBorders : false ,
13+ _calcBounds : function _calcBounds ( ctx ) {
14+ const boundingBox = this . _elem . getBounds ( ) ;
15+ this . m_coordsPx . forEach ( ( t ) => {
16+ boundingBox . addPnt ( t . x , t . y ) ;
17+ } ) ;
18+ return boundingBox ;
19+ } ,
20+ _pathElementRender : function _pathElementRender ( ctx , coords ) {
21+ const style = this . _elem . getContextStyle ( ) ;
22+ const lineWidth = this . calcMapScaleLineWidth ( style . lineWidth ) ;
23+ style . lineWidth = lineWidth ;
24+ this . _pointsToPath ( ctx , style , coords ) ;
25+ } ,
26+ _comparePathElementRender : function _comparePathElementRender ( ctx , coords ) {
27+ const style = this . _elem . getContextStyle ( ) ;
28+ const lineWidth = this . calcMapScaleLineWidth ( style . lineWidth ) ;
29+ const { compareLine, compareLineWidth, compareLineColor, compareLineOpacity } = this . _elem ;
30+ const compareLineWidthMapScale = this . calcMapScaleLineWidth ( compareLineWidth ) ;
31+
32+ const _compareStyle = this . _comparePathStyle (
33+ Object . assign ( style , {
34+ compareLine,
35+ compareLineWidth : compareLineWidthMapScale ,
36+ compareLineColor,
37+ compareLineOpacity,
38+ lineWidth
39+ } )
40+ ) ;
41+ if ( _compareStyle ) {
42+ this . _pointsToPath ( ctx , _compareStyle , coords ) ;
43+ }
44+ } ,
45+ _render ( ctx ) {
46+ const coords = this . _elem . cacheCoords || this . _elem . getCoords ( ) ;
47+ this . _comparePathElementRender ( ctx , coords ) ;
48+ this . _pathElementRender ( ctx , coords ) ;
4649 }
47- } ,
48- _render ( ctx ) {
49- const coords = this . _elem . cacheCoords || this . _elem . getCoords ( ) ;
50- this . _comparePathElementRender ( ctx , coords ) ;
51- this . _pathElementRender ( ctx , coords ) ;
52- } ,
5350} ) ;
5451
5552fabric . PlotIrregularShape = PlotIrregularShape ;
56- export default PlotIrregularShape
53+ export default PlotIrregularShape ;
0 commit comments