shapegen.tcl 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/usr/bin/tclsh
  2. set shapes {
  3. box {}
  4. polygon {sides=7 label="" style=filled}
  5. ellipse {}
  6. circle {}
  7. point {}
  8. egg {}
  9. triangle {}
  10. plaintext { }
  11. diamond {}
  12. trapezium {}
  13. parallelogram {}
  14. house {}
  15. pentagon {}
  16. hexagon {}
  17. septagon {}
  18. octagon {}
  19. doublecircle {}
  20. doubleoctagon {}
  21. tripleoctagon {}
  22. invtriangle {}
  23. invtrapezium {}
  24. invhouse {}
  25. Mdiamond {}
  26. Msquare {}
  27. Mcircle {}
  28. rect {}
  29. rectangle {}
  30. none { }
  31. note {}
  32. tab {}
  33. folder {}
  34. box3d {}
  35. component {}
  36. }
  37. set rowsize 4
  38. set h [open temp.html w]
  39. set count 0
  40. puts $h "<TABLE ALIGN=\"CENTER\">"
  41. foreach {shape attrs} $shapes {
  42. if {$count % $rowsize == 0} {
  43. if {$count != 0} {
  44. puts $h " </TR>"
  45. }
  46. puts $h " <TR ALIGN=\"CENTER\">"
  47. }
  48. puts $h " <TD><IMG SRC=\"$shape.gif\"><BR><A NAME=\"d:$shape\">$shape</A></TD>"
  49. incr count
  50. set f [open $shape.dot w]
  51. puts $f "digraph G \{"
  52. puts $f "graph \[pad=\".15\"\]"
  53. if {[string length $attrs]} {
  54. puts $f "$shape \[shape=$shape $attrs\]"
  55. } {
  56. puts $f "$shape \[label=\"\" shape=$shape style=filled\]"
  57. }
  58. puts $f "\}"
  59. close $f
  60. exec dot -Tgif $shape.dot -o $shape.gif
  61. file delete $shape.dot
  62. }
  63. puts $h " </TR>"
  64. puts $h "</TABLE>"
  65. close $h