rotateMode

$canvaseditor rotateMode
manages canvas bindings to rotate selection interactively

obj method canvaseditor rotateMode {{scaling no}} {
  set canvas [my canvas]
  $self selected dots storeXY
  $self selected calcCenter
  $self selected blink off
  $self snapMode on
  #
  set min [min {*}[$self dots -selected -gravity cget -x]]
  set max [max {*}[$self dots -selected -gravity cget -x]]
  set xC [* 0.5 [+ $min $max]]
  #
  set min [min {*}[$self dots -selected -gravity cget -y]]
  set max [max {*}[$self dots -selected -gravity cget -y]]
  set yC [* 0.5 [+ $min $max]]
  set nDot [$self nearestDot -selected -end]
  #
  $self pointerToDot $nDot
  $self memory currentDot $nDot
  $self memory transformation "rotate $scaling"
  #
  set dx [- $xC [$nDot cget -x]]
  set dy [- $yC [$nDot cget -y]]
  set distance [hypot $dx $dy]
  set dPhi [atan2 $dx $dy]
  #
  $self memory before [$self undoRedoCode]
  #
  $self basicBindings no
  after idle [list bind $canvas <Motion> [subst -nocommand {
      $self rotateSelection\
        [$self canvasx %x] [$self canvasy %y]\
        $xC $yC $distance $dPhi $scaling
    }]]
  bind $canvas <<Click>> "
    $self canvas delete center
    $self finishTransform
    "
}

© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z