svg2ngc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. inpsvg="$1"
  3. #sf=`echo '72/25.4' | bc -l`
  4. #sf=`echo 1.0`
  5. #sf=`echo '72/254' | bc -l`
  6. sf='1'
  7. if [[ "$2" != "" ]] ; then
  8. sf="$2"
  9. fi
  10. premul=`echo "1000000" | bc -l`
  11. invmul=`echo "( 1 / $premul ) * $sf" | bc -l`
  12. frapid="F8000"
  13. fslow="F400"
  14. S="1.0"
  15. if [[ "$inpsvg" == "" ]] ; then
  16. echo "provide input svg"
  17. exit 1
  18. fi
  19. rawtype=`file $inpsvg`
  20. checktype=`file -b $inpsvg | cut -f1 -d' '`
  21. if [[ "$checktype" != "SVG" ]] ; then
  22. echo -e "file $inpsvg is of type:\n\n$rawtype\n\nNnot an SVG file? Exiting.\n"
  23. exit 1
  24. fi
  25. bn=`basename $inpsvg .svg`
  26. # causes duplicate paths otherwise
  27. #
  28. sed -i 's/fill="[^"]*"/fill="none"/g' $inpsvg
  29. echo "creating $bn.ps"
  30. rsvg-convert -f ps -o $bn.ps $inpsvg
  31. pstoedit -f gnuplot $bn.ps $bn.gp
  32. echo "# premul: $premul" > ${bn}-ord.gp
  33. #clipcli -s $bn.gp -F -x $premul -T >> ${bn}-ord.gp
  34. clipcli -S evenodd -s $bn.gp -F -x $premul -T >> ${bn}-ord.gp
  35. sfx_slow="$fslow S$S"
  36. sfx_rapid="$frapid S0"
  37. #echo gp2ngc -i ${bn}-ord.gp -s "$invmul" --sfx-rapid "$sfx_rapid" --sfx-slow "$sfx_slow" -o ${bn}.ngc
  38. #gp2ngc -i ${bn}-ord.gp --sfx-rapid "$sfx_rapid" --sfx-slow "$sfx_slow" | ngc_scale -s "$invmul" > ${bn}.ngc
  39. echo gp2ngc --preset laser -i ${bn}-ord.gp --rapid "$sfx_rapid" --slow "$sfx_slow" "|" ngc_scale -s "$invmul" "> ${bn}.ngc"
  40. gp2ngc --preset laser -i ${bn}-ord.gp --rapid "$sfx_rapid" --slow "$sfx_slow" | ngc_scale -s "$invmul" > ${bn}.ngc