obj method canvaseditor scaleMode {{mode both}} { set canvas [my canvas] $self selected dots storeXY $self selected calcCenter $self selected blink off $self snapMode on set nearDot [$self nearestDot -selected -end] # $self memory currentDot $nearDot $self memory transformation "scale $mode" # switch -exact -- $mode { horizontal { if { [min {*}[$self dots -selected -gravity cget -x]] == [max {*}[$self dots -selected -gravity cget -x]] } then { return -code error "Sorry, zero width!" } set leftDot [$self leftmostDot -gravity] set rightDot [$self rightmostDot -gravity] set centerX [expr {([$leftDot cget -x] + [$rightDot cget -x]) / 2}] # if {[$nearDot cget -x] < $centerX} then { set farDot $rightDot } else { set farDot $leftDot } } vertical { if { [min {*}[$self dots -selected -gravity cget -y]] == [max {*}[$self dots -selected -gravity cget -y]] } then { return -code error "Sorry, zero height!" } set topDot [$self uppermostDot -gravity] set botDot [$self lowermostDot -gravity] set midY [expr {([$topDot cget -y] + [$botDot cget -y]) / 2}] # if {[$nearDot cget -y] > $midY} then { set farDot $topDot } else { set farDot $botDot } } default { set farDot [$self farmostDot -selected -gravity] } } if {[$farDot cget -x] == [$nearDot cget -x]} then { set mode vertical } elseif {[$farDot cget -y] == [$nearDot cget -y]} then { set mode horizontal } $self pointerToDot $nearDot $self memory currentDot $nearDot $farDot show # $self memory before [$self undoRedoCode] # set farXY [$farDot storeXY info] set nearXY [$nearDot storeXY info] # after idle [list bind $canvas <Motion>\ [subst -nocommand {$self scaleSelection\ [$self canvasx %x] [$self canvasy %y]\ $farXY $nearXY $mode}]] $self basicBindings off $self statusLine Scale objects $mode bind $canvas <<Click>> " $self finishTransform $farDot show no " $canvas configure -cursor crosshair }
© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z