-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraggy.tcl
executable file
·67 lines (52 loc) · 1.26 KB
/
draggy.tcl
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
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
# \
exec tclsh "$0" "$@" && exit
package require Tk
package require udp
set addr 127.0.0.1
set port 60440
set sock [udp_open]
fconfigure $sock -buffering none -translation binary
proc dest {addr port} {
# puts "-> $addr $port"
fconfigure $::sock -remote [list $addr $port]
}
dest $addr $port
proc wire {msg} {
puts $msg
puts -nonewline $::sock $msg
}
set voice 36
# wire v${::voice}w0f110G1F110R7l1
set FO 0
pack [scale .fo -orient hor -variable FO] -fill x
set FM 100
pack [scale .fm -orient hor -variable FM] -fill x
canvas .cvs -width 800 -height 600
pack .cvs
set RO 0
pack [scale .ro -orient hor -variable RO] -fill x
set RM 100
pack [scale .rm -orient hor -variable RM] -fill x
# add canvas items
.cvs create text 400 300 -text "?" -tag ct0
proc doit {x y} {
set x [expr { $x / 10.0 }]
set y [expr { $y / 50.0 }]
wire v${::voice}f${x}a${y}
return "$x $y"
}
# this one is for subsequent moves
bind .cvs <B1-Motion> {
set l [doit "%x" "%y"]
set x [lindex $l 0]
set y [lindex $l 1]
.cvs itemconfig ct0 -text "v${::voice} f${x} a${y}"
}
# this one is for the initial press
bind .cvs <Button-1> {
set l [doit "%x" "%y"]
set x [lindex $l 0]
set y [lindex $l 1]
.cvs itemconfig ct0 -text "v${::voice} f${x} a${y}"
}