1- import { LayerBase , PropertyBase , CompBase } from "./expression-globals" ;
1+ import {
2+ LayerBase ,
3+ PropertyBase ,
4+ Vector2D ,
5+ Points ,
6+ } from 'expression-globals-typescript' ;
27
38// Creating layer and property mocks
49const thisLayer = Object . create ( LayerBase ) ;
510const thisProperty = Object . create ( PropertyBase ) ;
611
712// eBox types
8- type Points = [ Vector2D , Vector2D , Vector2D , Vector2D ] ;
9- type Anchor = "topLeft" | "topRight" | "bottomRight" | "bottomLeft" | "center" ;
13+ type Anchor = 'topLeft' | 'topRight' | 'bottomRight' | 'bottomLeft' | 'center' ;
1014interface BoxProps {
1115 size : Vector2D ;
1216 position : Vector2D ;
@@ -17,14 +21,14 @@ interface BoxProps {
1721function createBox ( {
1822 size = [ 100 , 100 ] ,
1923 position = [ 0 , 0 ] ,
20- anchor = " center" ,
24+ anchor = ' center' ,
2125 isClosed = true ,
2226} : BoxProps ) {
2327 const pointOrder : Anchor [ ] = [
24- " topLeft" ,
25- " topRight" ,
26- " bottomRight" ,
27- " bottomLeft" ,
28+ ' topLeft' ,
29+ ' topRight' ,
30+ ' bottomRight' ,
31+ ' bottomLeft' ,
2832 ] ;
2933
3034 function positionToCenter (
@@ -89,7 +93,7 @@ function createBox({
8993 ) as Points ;
9094 }
9195 function pointsToPath ( points : Points , isClosed : boolean ) {
92- thisProperty . createPath ( points , [ ] , [ ] , isClosed ) ;
96+ return thisProperty . createPath ( points , [ ] , [ ] , isClosed ) ;
9397 }
9498
9599 const centerPosition = positionToCenter ( position , size , anchor ) ;
@@ -118,15 +122,15 @@ function createBox({
118122 function scalePoints ( scale : Vector2D = [ 100 , 100 ] , anchor : Anchor ) : void {
119123 // Remap scale to [0..1]
120124 const normalizedScale : Vector2D = scale . map (
121- ( scale ) => scale / 100
125+ scale => scale / 100
122126 ) as Vector2D ;
123127
124128 // Get index of anchor point
125129 const anchorPointIndex : number = pointOrder . indexOf ( anchor ) ;
126130 const anchorPoint : Vector2D = boxPoints [ anchorPointIndex ] ;
127131
128132 // Calculate distance from anchor point
129- const pointDeltas : Points = boxPoints . map ( ( point ) => {
133+ const pointDeltas : Points = boxPoints . map ( point => {
130134 return point . map ( ( dimension , dimensionIndex ) : number => {
131135 return dimension - anchorPoint [ dimensionIndex ] ;
132136 } ) as Vector2D ;
0 commit comments