File: graph-arc.e

package info (click to toggle)
entity 0.7.2-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,352 kB
  • ctags: 5,272
  • sloc: ansic: 61,707; sh: 7,921; makefile: 732; perl: 399
file content (55 lines) | stat: -rwxr-xr-x 1,948 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env entity

<object default-lang="tcl">
  <?tcl proc quit {node args} { if {"q" == [lindex $args 0]} { $node entity:exit } } ?>
  <window onkeypress = "quit" ondelete = "entity:exit" title = "Arc Test (q to quit)" width = "500" height = "400">
    <object expand = "true" fill = "true" default-lang = "tcl">
      <timer interval = "60" action = "motion"/>
      <graph name="graph-arc" expand="true" fill="true">

        <!-- simple disc -->
        <graph-point x="20" y="50" width="20" type = "arc" color="#ff0000"/>

        <!-- green ellipse -->
        <graph-point x="50" y="100" width="80" height="50" size = "7" type = "arc" color="#00ff00" filled = "no"/>

        <!-- big (magenta) rotating pie in the center -->
        <graph-point name = "mag" x="50" y="70" width="120" height="180"
        type = "arc" angle-start = "30" angle-range = "310" color="#ff00ff"
        filled = "1"/>

        <!-- blue pie -->
        <graph-point x="100" y="50" width="60" type = "arc" angle-start="30" angle-range="80" color="#0000ff"/>
      </graph>
      <?tcl
        set fact 5.0
        set calls 0
        proc motion {node args} {
          global fact calls
          set point [enode graph-point.mag]
          # set graph [enode graph]
          # $graph attrib frozen 1

          set angle_start [$point attrib angle-start]
          incr angle_start 5

          set width [$point attrib width]
          if {$width > 250} {
            set fact -5.0
          } elseif {$width < 50} {
            set fact 5.0
          }
          incr calls
          if {$calls > 10} {
            set calls 0
            set filled [$point attrib filled]
            $point attrib filled [expr $filled ? 0 : 1]
          }
          # set filled [$point attrib filled]
          incr width [expr int(rand() * $fact)]
          $point attrib angle-start $angle_start width $width
        }
      ?>
    </object>
  </window>
</object>