Posted to tcl by chw at Fri Aug 05 21:00:04 GMT 2016view raw

  1. package require tkpath 0.3.0
  2. package require pdf4tcl
  3.  
  4. set w .c
  5. pack [tkp::canvas $w -width 400 -height 400 -bg white]
  6.  
  7. set grad [$w gradient create linear -stops \
  8. {{0.0 "#00bb00"} {0.35 "#00bb00"} {0.35 "#ffff00"} {0.50 "#ffff00"} \
  9. {0.50 "#ff6600"} {0.65 "#ff6600"} {0.65 "#dd0000"} {0.8 "#dd0000"} \
  10. {0.8 "#3366cc"} {1.0 "#3366cc"}} \
  11. -lineartransition {0 0 0 1}]
  12.  
  13. $w create path "M 0 0 C 20 0 40 -20 70 -20 S 130 30 130 60 \
  14. 110 200 60 200 20 180 0 180 \
  15. -10 200 -60 200 -130 90 -130 60 \
  16. -110 -20 -70 -20 -20 0 0 0 z \
  17. M 0 -10 Q -10 -60 50 -80 Q 50 -20 0 -10 z" \
  18. -fill $grad -stroke "" -tags apple
  19. # -fill blue -stroke "" -tags apple
  20.  
  21.  
  22. $w move apple 200 120
  23.  
  24. pdf4tcl::new mypdf -paper a4
  25. mypdf startPage
  26. mypdf canvas $w
  27. mypdf write -file out.pdf
  28. mypdf destroy
  29.