import { SKLayer , SKFillItem , Background } from '../../../types' ; /**
 * fillStyle.patternFillType == 0   Mask_Tile repeat 平铺
 * fillStyle.patternFillType == 1  Mask_Fill  cover  填充
 * fillStyle.patternFillType == 2  Mask_Stretch  100% 100% 拉伸
 * fillStyle.patternFillType == 3   Mask_Fit  contain 包含
 */ export default ( fillStyle , layer ) : Background => { const background = { } ; if ( ! fillStyle . image ) { return ; } if ( fillStyle . patternFillType == 0 ) { background . repeat = 'repeat' ; } if ( fillStyle . patternFillType == 1 ) { background . repeat = 'no-repeat' ; background . position = { left : 'center' , top : 'center' } ; background . size = 'cover' ; } if ( fillStyle . patternFillType == 2 ) { background . repeat = 'no-repeat' ; background . position = { left : 'center' , top : 'center' } ; background . size = { width : '100%' , height : '100%' , } ; } if ( fillStyle . patternFillType == 3 ) { background . repeat = 'no-repeat' ; background . position = { left : 'center' , top : 'center' } ; background . size = 'contain' ; } let imgPath = fillStyle . image . _ref . slice ( fillStyle . image . _ref . lastIndexOf ( '/' ) + 1 ) ; if ( ! /.(png|pdf)$/ . test ( imgPath ) ) { imgPath = imgPath + '.png' ; } background . image = { url : imgPath } ; return background ; } ;