Article View: fj.lang.tcl
Article #198Re: [Q] I can't line precisely on canvas..
From: Nagao Shijo
Date: Fri, 07 Nov 1997 00:00
Date: Fri, 07 Nov 1997 00:00
67 lines
2372 bytes
2372 bytes
<G94P0211.97Nov8020730@wise21.mn.waseda.ac.jp>$B$N5-;v$K$*$$$F(B
g94p0211@mn.waseda.ac.jp$B$5$s$O=q$-$^$7$?!#(B
>> $B=i$a$FEj9F$7$^$9!#(B
-- big snip --
S.Nagao@rimnet $B$H?=$7$^$9!#(B
$B$b$&2r7h$7$F$k$+$bCN$l$^$;$s$,(B ...
($B$3$3$+$i(B)
#-------------------------------------------------------------
wm withdraw . ;# added for testing.
toplevel .frame ;#
set work .frame.work
frame $work -relief raised
set c1 $work.canvas
canvas $c1 -scrollregion {0c 0c 362c 26.2c} -width 22c -height 26.2c \
-relief sunken -borderwidth 2 -xscrollcommand "$work.scroll set"
scrollbar $work.scroll -bd 2 -relief sunken -width 12 \
-orient horizontal -command "$work.canvas xview"
pack $work ;# added for testing.
pack $work.canvas -fill both -expand yes ;#
pack $work.scroll -fill x ;#
set count 1
set dx1($count) 0 ;### $B:BI8MQG[Ns$N=i4|@_Dj(B (dx1,dy1)-(dx2,dy2)
set dy1($count) 0
set dx2($count) 0
set dy2($count) 0
bind $c1 <ButtonPress-1> "CanvB1Press $c1 %x %y"
proc CanvB1Press {sheet x y} {
global dx1 dy1 dx2 dy2 count
set c $sheet
set sx [$c canvasx $x]
set sy [$c canvasy $y]
bind $c <ButtonRelease-1> "drawLine $c $x $y %x %y"
proc drawLine {c sx sy cx cy} {
global dx1 dy1 dx2 dy2 count
set cx [$c canvasx $cx]
set sx [$c canvasx $sx] ;# <<-------------- add this line.
$c create line $sx $sy $cx $sy -width 2 -fill red
set dx1($count) $sx
set dy1($count) $sy
set dx2($count) $cx
set dy2($count) $sy
puts ($sx,$sy)-($cx,$sy) ;### $B3NG'=PNO(B
incr count
}
}
#---------------------------------------------------------
($B$3$3$^$G(B)
--------------------------------------------------------
Shijo, Nagao
mailto:nagao@hf.rim.or.jp
http://www.hf.rim.or.jp/~nagao/
Technical Details
Message-ID:
<63vuk3$h9g$2@news2.na.rim.or.jp>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<G94P0211.97Nov8020730@wise21.mn.waseda.ac.jp>Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS X-Google-Thread: 15a83d,7659ec1e7f169b51 X-Google-Attributes: gid15a83d,public From: nagao@hf.rim.or.jp (Nagao Shijo) Subject: Re: [Q] I can't line precisely on canvas.. Date: 1997/11/07 Message-ID: <63vuk3$h9g$2@news2.na.rim.or.jp> X-Deja-AN: 287746312 Distribution: fj References: <G94P0211.97Nov8020730@wise21.mn.waseda.ac.jp> Organization: RIMNET Newsgroups: fj.lang.tcl