import { SKLayer , SKFillItem } from '../types' ; description param { Layer } layerA param { Layer } layerB returns { boolean } export const isAlignCenter = ( layerA , layerB ) : boolean => { return Math . abs ( ( layerA . frame . x + layerA . frame . width / 2 ) - ( layerB . frame . x + layerB . frame . width / 2 ) ) <= 5 ; } ; description param { number } color returns { number } export const calculateRGB = ( color ) : number => { return Math . round ( color * 255 ) ; } ; export const getEnabledFill = ( layer ) => { if ( layer . style ?. fills ) { return layer . style . fills . filter ( ( item ) => item . isEnabled ) . pop ( ) ; } return undefined ; } ; param data param num export const precisionControl = ( data , num = 1 ) => { const len = Math . round ( 1 / num ) . toString ( ) . length - 1 ; return + ( ( Math . round ( data / num ) * num ) . toFixed ( len ) ) ; } ; description param { * } export const transSketchColor = ( { red , green , blue , alpha } ) => ( { red : calculateRGB ( red ) , green : calculateRGB ( green ) , blue : calculateRGB ( blue ) , alpha : precisionControl ( alpha , 0.01 ) , } ) ;