'From etoys4.0 of 9 October 2008 [latest update: #2245] on 7 August 2009 at 7:46:17 pm'! "Change Set: PolygonFix-kfr Date: 3 May 2009 Author: Karl Ramberg, Tetsuya Hayashi Hayashi-san's February 2009 fixes for SQ-163 PolygonMorph issues, together with Karl's May 2009 tweak to StarMorph."! !Player methodsFor: 'vertices operation' stamp: 'tetha 2/26/2009 17:29'! setVerticesCount: aInteger self costume setVerticesCount: aInteger! ! !PolygonMorph methodsFor: 'vertices operations' stamp: 'tetha 2/26/2009 17:36'! setVerticesCount: anInteger | verticesCount | verticesCount := vertices size. verticesCount > anInteger ifTrue: [verticesCount - anInteger timesRepeat: [self removeVertexAtCursor]]. verticesCount < anInteger ifTrue: [anInteger - verticesCount timesRepeat: [self insertVertexAtCursor]]! ! !PolygonMorph methodsFor: 'editing' stamp: 'tetha 2/26/2009 17:15'! updateHandles | newVert oldVert midPts nextVertIx tweens | (handles at: self vertexCursor * 2 - 1) color: Color blue. smoothCurve ifTrue: [handles first center: vertices first. handles last center: vertices last. midPts := OrderedCollection new. nextVertIx := 2. tweens := OrderedCollection new. 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)]]. self lineSegmentsDo: [:p1 :p2 | tweens addLast: p2 asIntegerPoint. ((p2 = (vertices atWrap: nextVertIx)) and: [vertices size > 1]) ifTrue: ["Found endPoint." midPts addLast: (tweens at: 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 at: 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)]]]! ! !StarMorph methodsFor: 'initialization' stamp: 'kfr 5/3/2009 19:43'! setVerticesCount: aInteger | verticesCount int | verticesCount := self vertices size. int := aInteger max: 4. aInteger > verticesCount ifTrue: [int even ifFalse: [int := int + 1]] ifFalse: [int even ifFalse: [int := int - 1 max: 4]]. self makeVertices: int! !