Sharing a little stack

Michael Kristensen michael-kristensen at dsa-net.dk
Wed Nov 21 02:04:47 EST 2012


Hi David

Line = Poly1

Yellow Rect = Poly2

Field = Thicknes

This is the script inside one of the small squares.
Adjust the script for the other one accordingly.


local gDragging,loc2,T

on mouseDown
   put true into gDragging
   put line 2 of points of grc Poly1 into loc2
   put fld Thicknes into T
end mouseDown

on mouseUp
   put false into gDragging
end mouseUp

on mouseRelease
   put false into gDragging
end mouseRelease


on mouseMove x,y
if x,y is within the rect of this cd then 
   if gDragging is true then
      set loc of me to x,y
      set points of grc Poly1 to x,y & return & loc2
      
      ------Vinger-----------------------------------
      put points of grc Poly1 into xPoints
      
      put item 1 of line 1 of xPoints into x1
      put item 2 of line 1 of xPoints into y1
      put item 1 of line 2 of xPoints into x2
      put item 2 of line 2 of xPoints into y2
      
      put x2-x1 into dX
      put y2-y1 into dY
      
      put sqrt(dX^2 + dY^2) into Læng
      
      if Læng = 0 then exit mouseMove
      
      put T/Læng into Skala
      
      
      put round(-dX*Skala) into dYny
      put round(dY*Skala) into dXny
      
      put round(dX*Skala) into dYny2
      put round(-dY*Skala) into dXny2
      
      put x1+dXny,y1+dYny & return into xBox
      put x2+dXny,y2+dYny & return after xBox
      put x2+dXny2,y2+dYny2 & return after xBox
      put x1+dXny2,y1+dYny2 & return after xBox
      put x1+dXny,y1+dYny after xBox
      
      set points of grc Poly2 to xBox
      -----------------------------------------------------
   end if
end if	
end mouseMove


Michael



More information about the use-livecode mailing list