shearSelection

$canvaseditor shearSelection dot dot0 cx cy phi mode
shears selected objects along arbitrary axis

obj method canvaseditor shearSelection {dot dot0 cx cy phi {mode parallel}} {
  set transformL [list rotate [list $phi $cx $cy]]
  #
  lassign [$dot storeXY info] baseX baseY
  $dot storeXY
  $dot transform {*}$transformL
  $dot storeXY $baseX $baseY
  #
  $dot0 transform {*}$transformL
  set x [$dot cget -x]
  set y [$dot cget -y]
  set x0 [$dot0 cget -x]
  set y0 [$dot0 cget -y]
  lappend transformL shearHorizontal [list $cy $y0 [- $x $x0]]
  if {$mode ne "parallel"} then {
    set fac [expr {($y - $cy) / ($y0 - $cy)}]
    lappend transformL scaleVertical [list $cy $fac]
  }
  lappend transformL rotate [list [- $phi] $cx $cy]
  foreach obj [my selection] {
    foreach dot [$obj dots] {
      $dot transform {*}$transformL
    }
    if {[$obj isa line]} then {
      $obj dots lines draw coords
    } else {
      $obj draw
    }
  }
}

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