@@ -145,14 +145,14 @@ function _flipImage(originalImage: UIImage): UIImage {
145145 return flippedImage ;
146146}
147147
148- function cssValueToDevicePixels ( source : string , totalPx : number ) : number {
148+ function cssValueToDeviceIndependentPixels ( source : string , total : number ) : number {
149149 source = source . trim ( ) ;
150150 if ( source . indexOf ( "px" ) !== - 1 ) {
151- return parseFloat ( source . replace ( "px" , "" ) ) ;
152- } else if ( source . indexOf ( "%" ) !== - 1 && totalPx > 0 ) {
153- return ( parseFloat ( source . replace ( "%" , "" ) ) / 100 ) * totalPx ;
151+ return layout . toDeviceIndependentPixels ( parseFloat ( source . replace ( "px" , "" ) ) ) ;
152+ } else if ( source . indexOf ( "%" ) !== - 1 && total > 0 ) {
153+ return ( parseFloat ( source . replace ( "%" , "" ) ) / 100 ) * total ;
154154 } else {
155- return layout . toDevicePixels ( parseFloat ( source ) ) ;
155+ return parseFloat ( source ) ;
156156 }
157157}
158158
@@ -289,10 +289,10 @@ function drawClipPath(nativeView: UIView, background: Background) {
289289 const layerSize = layerBounds . size ;
290290
291291 const bounds = {
292- left : layout . toDevicePixels ( layerOrigin . x ) ,
293- top : layout . toDevicePixels ( layerOrigin . y ) ,
294- bottom : layout . toDevicePixels ( layerSize . height ) ,
295- right : layout . toDevicePixels ( layerSize . width )
292+ left : layerOrigin . x ,
293+ top : layerOrigin . y ,
294+ bottom : layerSize . height ,
295+ right : layerSize . width
296296 } ;
297297
298298 if ( bounds . right === 0 || bounds . bottom === 0 ) {
@@ -353,10 +353,10 @@ function drawClipPath(nativeView: UIView, background: Background) {
353353
354354function rectPath ( value : string , bounds : Rect ) : UIBezierPath {
355355 const arr = value . split ( / [ \s ] + / ) ;
356- const top = cssValueToDevicePixels ( arr [ 0 ] , bounds . top ) ;
357- const left = cssValueToDevicePixels ( arr [ 1 ] , bounds . left ) ;
358- const bottom = cssValueToDevicePixels ( arr [ 2 ] , bounds . bottom ) ;
359- const right = cssValueToDevicePixels ( arr [ 3 ] , bounds . right ) ;
356+ const top = cssValueToDeviceIndependentPixels ( arr [ 0 ] , bounds . top ) ;
357+ const left = cssValueToDeviceIndependentPixels ( arr [ 1 ] , bounds . left ) ;
358+ const bottom = cssValueToDeviceIndependentPixels ( arr [ 2 ] , bounds . bottom ) ;
359+ const right = cssValueToDeviceIndependentPixels ( arr [ 3 ] , bounds . right ) ;
360360
361361 return UIBezierPath . bezierPathWithRect ( CGRectMake ( left , top , right - left , bottom - top ) ) . CGPath ;
362362}
@@ -387,30 +387,30 @@ function insetPath(value: string, bounds: Rect): UIBezierPath {
387387 leftString = arr [ 3 ] ;
388388 }
389389
390- const top = cssValueToDevicePixels ( topString , bounds . bottom ) ;
391- const right = cssValueToDevicePixels ( "100%" , bounds . right ) - cssValueToDevicePixels ( rightString , bounds . right ) ;
392- const bottom = cssValueToDevicePixels ( "100%" , bounds . bottom ) - cssValueToDevicePixels ( bottomString , bounds . bottom ) ;
393- const left = cssValueToDevicePixels ( leftString , bounds . right ) ;
390+ const top = cssValueToDeviceIndependentPixels ( topString , bounds . bottom ) ;
391+ const right = cssValueToDeviceIndependentPixels ( "100%" , bounds . right ) - cssValueToDeviceIndependentPixels ( rightString , bounds . right ) ;
392+ const bottom = cssValueToDeviceIndependentPixels ( "100%" , bounds . bottom ) - cssValueToDeviceIndependentPixels ( bottomString , bounds . bottom ) ;
393+ const left = cssValueToDeviceIndependentPixels ( leftString , bounds . right ) ;
394394
395395 return UIBezierPath . bezierPathWithRect ( CGRectMake ( left , top , right - left , bottom - top ) ) . CGPath ;
396396}
397397
398398function circlePath ( value : string , bounds : Rect ) : UIBezierPath {
399399 const arr = value . split ( / [ \s ] + / ) ;
400- const radius = cssValueToDevicePixels ( arr [ 0 ] , ( bounds . right > bounds . bottom ? bounds . bottom : bounds . right ) / 2 ) ;
401- const y = cssValueToDevicePixels ( arr [ 2 ] , bounds . bottom ) ;
402- const x = cssValueToDevicePixels ( arr [ 3 ] , bounds . right ) ;
400+ const radius = cssValueToDeviceIndependentPixels ( arr [ 0 ] , ( bounds . right > bounds . bottom ? bounds . bottom : bounds . right ) / 2 ) ;
401+ const y = cssValueToDeviceIndependentPixels ( arr [ 2 ] , bounds . bottom ) ;
402+ const x = cssValueToDeviceIndependentPixels ( arr [ 3 ] , bounds . right ) ;
403403
404404 return UIBezierPath . bezierPathWithArcCenterRadiusStartAngleEndAngleClockwise ( CGPointMake ( x , y ) , radius , 0 , 360 , true ) . CGPath ;
405405}
406406
407407function ellipsePath ( value : string , bounds : Rect ) : UIBezierPath {
408408 const arr = value . split ( / [ \s ] + / ) ;
409409
410- const rX = cssValueToDevicePixels ( arr [ 0 ] , bounds . right ) ;
411- const rY = cssValueToDevicePixels ( arr [ 1 ] , bounds . bottom ) ;
412- const cX = cssValueToDevicePixels ( arr [ 3 ] , bounds . right ) ;
413- const cY = cssValueToDevicePixels ( arr [ 4 ] , bounds . bottom ) ;
410+ const rX = cssValueToDeviceIndependentPixels ( arr [ 0 ] , bounds . right ) ;
411+ const rY = cssValueToDeviceIndependentPixels ( arr [ 1 ] , bounds . bottom ) ;
412+ const cX = cssValueToDeviceIndependentPixels ( arr [ 3 ] , bounds . right ) ;
413+ const cY = cssValueToDeviceIndependentPixels ( arr [ 4 ] , bounds . bottom ) ;
414414
415415 const left = cX - rX ;
416416 const top = cY - rY ;
@@ -428,8 +428,8 @@ function polygonPath(value: string, bounds: Rect): UIBezierPath {
428428 for ( let i = 0 ; i < arr . length ; i ++ ) {
429429 const xy = arr [ i ] . trim ( ) . split ( / [ \s ] + / ) ;
430430 const point : Point = {
431- x : cssValueToDevicePixels ( xy [ 0 ] , bounds . right ) ,
432- y : cssValueToDevicePixels ( xy [ 1 ] , bounds . bottom )
431+ x : cssValueToDeviceIndependentPixels ( xy [ 0 ] , bounds . right ) ,
432+ y : cssValueToDeviceIndependentPixels ( xy [ 1 ] , bounds . bottom )
433433 } ;
434434
435435 if ( ! firstPoint ) {
0 commit comments