obj method canvaseditor alignEvenly {} { set before [$self undoRedoCode] $self dots -selected storeXY $self selected calcCenter set objL1 [my selection] foreach obj $objL1 { set centerDot [$obj private centerDot] lappend objL2\ [list $obj [$centerDot cget -x] [$centerDot cget -y]] } set width [-\ [max {*}[lmap el $objL2 {lindex $el 1}]]\ [min {*}[lmap el $objL2 {lindex $el 1}]]] set height [-\ [max {*}[lmap el $objL2 {lindex $el 2}]]\ [min {*}[lmap el $objL2 {lindex $el 2}]]] if {$width > $height} then { set objL3 [lsort -real -index 1 $objL2] } else { set objL3 [lsort -real -index 2 $objL2] } set segs [- [llength $objL3] 1] set dot0 [[lindex $objL3 0 0] private centerDot] set dot1 [[lindex $objL3 end 0] private centerDot] set x0 [$dot0 cget -x] set y0 [$dot0 cget -y] set x1 [$dot1 cget -x] set y1 [$dot1 cget -y] set dx [- $x1 $x0] set dy [- $y1 $y0] for {set i 1} {$i < $segs} {incr i} { set li [lindex $objL3 $i] lassign $li obj cx cy set zx [expr {$x0 + $dx / $segs * $i}] set zy [expr {$y0 + $dy / $segs * $i}] set xDist [- $zx $cx] set yDist [- $zy $cy] $obj dots transform moveHorizontal $xDist moveVertical $yDist $self select $obj $obj draw $self select $obj } set after [$self undoRedoCode] $self initUndoRedo $before $after }
© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z