import { SKLayer , Fill } from '../types' ; import { transSketchColor } from '../common/utils' ; param layer export const parseFill = ( layer ) : Fill [ ] => { if ( layer . _class === 'artboard' && layer . hasBackgroundColor ) { return [ { type : 0 , color : transSketchColor ( layer . backgroundColor ) , } ] ; } const { fills = [ ] } = layer . style ; return fills . filter ( ( { isEnabled , fillType } ) => isEnabled && ( [ 0 , 1 ] . includes ( fillType ) ) ) . map ( ( { fillType , color , gradient } ) => { if ( fillType === 0 ) { return { type : 0 , color : transSketchColor ( color ) } ; } if ( fillType === 1 && [ 0 , 1 , 2 ] . includes ( gradient . gradientType ) ) { return { type : gradient . gradientType + 1 , stops : gradient . stops . map ( ( { position , color } ) => ( { position , color : transSketchColor ( color ) , } ) ) } ; } } ) ; } ;