1
1
import { Point } from './Point' ;
2
- import * as _ from 'lodash' ;
2
+ import _forEach from 'lodash/forEach' ;
3
+ import _map from 'lodash/map' ;
3
4
import { Matrix } from './Matrix' ;
4
5
import { boundingBoxFromPoints } from './toolkit' ;
5
6
import { Bounds , BoundsCorner } from './Bounds' ;
@@ -12,26 +13,26 @@ export class Polygon {
12
13
}
13
14
14
15
serialize ( ) {
15
- return _ . map ( this . points , ( point ) => {
16
+ return _map ( this . points , ( point ) => {
16
17
return [ point . x , point . y ] ;
17
18
} ) ;
18
19
}
19
20
20
21
deserialize ( data : any ) {
21
- this . points = _ . map ( data , ( point ) => {
22
+ this . points = _map ( data , ( point ) => {
22
23
return new Point ( point [ 0 ] , point [ 1 ] ) ;
23
24
} ) ;
24
25
}
25
26
26
27
scale ( x , y , origin : Point ) {
27
28
let matrix = Matrix . createScaleMatrix ( x , y , origin ) ;
28
- _ . forEach ( this . points , ( point ) => {
29
+ _forEach ( this . points , ( point ) => {
29
30
point . transform ( matrix ) ;
30
31
} ) ;
31
32
}
32
33
33
34
transform ( matrix : Matrix ) {
34
- _ . forEach ( this . points , ( point ) => {
35
+ _forEach ( this . points , ( point ) => {
35
36
point . transform ( matrix ) ;
36
37
} ) ;
37
38
}
@@ -49,13 +50,13 @@ export class Polygon {
49
50
}
50
51
51
52
translate ( offsetX : number , offsetY : number ) {
52
- _ . forEach ( this . points , ( point ) => {
53
+ _forEach ( this . points , ( point ) => {
53
54
point . translate ( offsetX , offsetY ) ;
54
55
} ) ;
55
56
}
56
57
57
58
doClone ( ob : this) {
58
- this . points = _ . map ( ob . points , ( point ) => {
59
+ this . points = _map ( ob . points , ( point ) => {
59
60
return point . clone ( ) ;
60
61
} ) ;
61
62
}
0 commit comments