[Etoys] Polygon fixes

Karl karl.ramberg at comhem.se
Thu May 10 09:43:07 EDT 2007


Here is a change set which makes the control points of polygons larger 
and it also makes the default size of the polygon bigger when it is 
pulled out from the Objects tool.

Karl
-------------- next part --------------
'From OLPC2.0 of ''24 October 2006'' [latest update: #1340] on 10 May 2007 at 3:37:30 pm'!

!PolygonMorph methodsFor: 'editing' stamp: 'kfr 5/9/2007 15:12'!
addHandles
	| handle newVert tri |
	self removeHandles.
	handles _ OrderedCollection new.
	tri _ Array with: 0 at -8 with: 8 at 6 with: -6 at 6.
	vertices withIndexDo:
		[:vertPt :vertIndex |
		handle _ EllipseMorph newBounds: (Rectangle center: vertPt extent: 16 at 16)
				color: (vertIndex = self vertexCursor ifTrue: [Color blue] ifFalse: [Color yellow]).
		handle on: #mouseMove send: #dragVertex:event:fromHandle:
				to: self withValue: vertIndex.
		handle on: #mouseUp send: #dropVertex:event:fromHandle:
				to: self withValue: vertIndex.
		self addMorph: handle.
		handles addLast: handle.
		(closed 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.
			self addMorph: newVert.
			handles addLast: newVert]].
	smoothCurve ifTrue: [self updateHandles; layoutChanged].
	self changed! !

!PolygonMorph methodsFor: 'initialization' stamp: 'kfr 5/10/2007 15:33'!
initialize
"initialize the state of the receiver"
	super initialize.
""
	vertices _ Array
				with: 15 @ 0
				with: 60 @ 30
				with: 0 @ 60.
	vertexCursor _ 1.
	closed _ true.
	smoothCurve _ false.
	arrows _ #none.
	self computeBounds! !



More information about the etoys-dev mailing list