'From Squeak3.2alpha of 4 October 2001 [latest update: #4422] on 6 October 2001 at 12:54:24 pm'! "Change Set: Arrowheads2-tk Date: 6 October 2001 Author: Ted Kaehler If movement of the pen is less than two pixels, don't make any arrowheads. There is an extra call on drawPenTrailFor:from:to: when a morph is unflexed at zero degrees. The morph moves a sub-pixel amount. I left this as it was."! !PasteUpMorph methodsFor: 'pen' stamp: 'tk 10/6/2001 10:20'! drawPenTrailFor: aMorph from: oldPoint to: targetPoint "Draw a pen trail for aMorph, using its pen state (the pen is assumed to be down)." "The turtleTrailsForm is created on demand when the first pen is put down and removed (to save space) when turtle trails are cleared." | origin mPenSize offset turtleTrailsDelta newPoint | turtleTrailsDelta _ self valueOfProperty: #turtleTrailsDelta ifAbsent:[0@0]. newPoint _ targetPoint - turtleTrailsDelta. oldPoint = newPoint ifTrue: [^ self]. self createOrResizeTrailsForm. origin _ self topLeft. mPenSize _ aMorph getPenSize. turtlePen sourceForm width ~= mPenSize ifTrue: [turtlePen squareNib: mPenSize]. offset _ (mPenSize // 2)@(mPenSize // 2). turtlePen color: aMorph getPenColor. turtlePen drawFrom: (oldPoint - origin - offset) asIntegerPoint to: (newPoint - origin - offset) asIntegerPoint. (aMorph player getPenArrowheads and: [oldPoint ~= newPoint]) ifTrue: [ turtlePen arrowHeadFrom: (oldPoint - origin - offset) to: (newPoint - origin - offset)]. self invalidRect: ((oldPoint rect: newPoint) expandBy: mPenSize) ! ! !Pen methodsFor: 'operations' stamp: 'tk 10/6/2001 10:46'! arrowHeadFrom: prevPt to: newPt "Put an arrowhead on the pen stroke from oldPt to newPt" " | pen | pen _ Pen new. 20 timesRepeat: [pen turn: 360//20; go: 20; arrowHead]." | pm af myColor finalPt delta | myColor _ self color. delta _ newPt - prevPt. delta r <= 2 "pixels" ifTrue: [^ self]. finalPt _ newPt + (Point r: sourceForm width degrees: delta degrees). "in same direction" pm _ PolygonMorph vertices: (Array with: prevPt asIntegerPoint with: finalPt asIntegerPoint) color: myColor "not used" borderWidth: sourceForm width borderColor: myColor. pm makeOpen; makeForwardArrow. af _ pm arrowForms first. "render it onto the destForm" (FormCanvas on: destForm "Display") stencil: af at: af offset + (1@1) color: myColor. ! !