Peace Jerome peace_the_dreamer at yahoo.com
Sun Mar 21 01:24:19 UTC 2004

Problem: After Polygon Drop Handles are fixed, One
vertex open curves do not get grow handles so they
can't be changed. This fix allows for a grow handle if
there is only one vertex.

This is a resubmission of some small fixes that I
originally tried to get looked at in Oct 2003.
In resubmitting them I've made each a fix separate and
atomic to ease the decision making process for the
harvesters. And removed extraneous changes not
directly concerned with the fix.
purpose of each fix.

Yours in Service, Jerome Peace

__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html
--0-1596787045-1079832259=:70919

'From Squeak3.7alpha of 11 September 2003 [latest update: #5816] on 13 March 2004 at 4:09:46 pm'!
Date:			13 March 2004
Author:			wiz (Jerome Peace)

Add 'tween' add handles to one vertex lines, curves and polygons so they can grow."!

!PolygonMorph methodsFor: 'editing' stamp: 'wiz 3/13/2004 16:02'!
| handle newVert tri |
self removeHandles.
handles _ OrderedCollection new.
tri _ Array with: 0 at -4 with: 4 at 3 with: -3 at 3.
vertices withIndexDo:
[:vertPt :vertIndex |
handle _ EllipseMorph newBounds: (Rectangle center: vertPt extent: 8 at 8)
color: Color yellow.
handle on: #mouseMove send: #dragVertex:event:fromHandle:
to: self withValue: vertIndex.
handle on: #mouseUp send: #dropVertex:event:fromHandle:
to: self withValue: vertIndex.
"Give a small polygon a chance to grow. -wiz"
(closed or: [(1 = vertices size) or: [vertIndex < vertices size]]) ifTrue:
[newVert _ PolygonMorph
vertices: (tri collect: [:p | p + (vertPt + (vertices atWrap: vertIndex+1) // 2)])
color: Color green borderWidth: 1 borderColor: Color black.
newVert on: #mouseDown send: #newVertex:event:fromHandle:
to: self withValue: vertIndex.
smoothCurve ifTrue: [self updateHandles; layoutChanged].
self changed! !

!PolygonMorph methodsFor: 'editing' stamp: 'wiz 3/13/2004 16:06'!
updateHandles
| newVert oldVert midPts nextVertIx tweens |
smoothCurve
ifTrue: [
handles first center: vertices first.
handles last center: vertices last.
midPts _ OrderedCollection new.
nextVertIx _ 2.
tweens _ OrderedCollection new.
self
lineSegmentsDo: [:p1 :p2 |
p2
= (vertices atWrap: nextVertIx)
ifTrue: ["Found endPoint."
midPts addLast: (tweens atWrap: tweens size // 2)
+ (tweens at: tweens size + 1 // 2) // 2.
tweens _ OrderedCollection new.
nextVertIx _ nextVertIx + 1]].
midPts
withIndexDo: [:midPt :vertIndex | (closed
or: [vertIndex < vertices size])
ifTrue: [newVert _ handles atWrap: vertIndex * 2.
newVert position: midPt - (newVert extent // 2)]]]
ifFalse: [vertices
withIndexDo: [:vertPt :vertIndex |
oldVert _ handles at: vertIndex * 2 - 1.
oldVert position: vertPt - (oldVert extent // 2).
(closed
or: [vertIndex < vertices size])
ifTrue: [newVert _ handles at: vertIndex * 2.
newVert position: vertPt
+ (vertices atWrap: vertIndex + 1) - newVert extent // 2 + (1 @ -1)]]]! !