import { Filter } from '../types/filter.type' ; import { normalizeLength } from '../utils/filter.utils' ; export const dropShadow = ( context , offsetX , offsetY , blurOrColor ? , color ? ) => { const shadowContext = document . createElement ( 'canvas' ) . getContext ( '2d' ) ; shadowContext . shadowOffsetX = normalizeLength ( offsetX ) ; shadowContext . shadowOffsetY = normalizeLength ( offsetY ) ; shadowContext . shadowBlur = color ? normalizeLength ( blurOrColor || '0' ) : 0 ; shadowContext . shadowColor = color || blurOrColor || 'transparent' ; shadowContext . drawImage ( context . canvas , 0 , 0 ) ; const { width , height } = context . canvas ; context . putImageData ( shadowContext . getImageData ( 0 , 0 , width , height ) , 0 , 0 ) ; return context ; } ;