shadow.js 682 B

12345678910111213141516171819
  1. import { getSolidFill } from './fill'
  2. import { RATIO_EMUs_Points } from './constants'
  3. export function getShadow(node, warpObj) {
  4. const chdwClrNode = getSolidFill(node, undefined, undefined, warpObj)
  5. const outerShdwAttrs = node['attrs']
  6. const dir = outerShdwAttrs['dir'] ? (parseInt(outerShdwAttrs['dir']) / 60000) : 0
  7. const dist = parseInt(outerShdwAttrs['dist']) * RATIO_EMUs_Points
  8. const blurRad = outerShdwAttrs['blurRad'] ? parseInt(outerShdwAttrs['blurRad']) * RATIO_EMUs_Points : ''
  9. const vx = dist * Math.sin(dir * Math.PI / 180)
  10. const hx = dist * Math.cos(dir * Math.PI / 180)
  11. return {
  12. h: hx,
  13. v: vx,
  14. blur: blurRad,
  15. color: chdwClrNode,
  16. }
  17. }