[squeak-dev] The Trunk: Balloon-nice.15.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Dec 27 02:23:05 UTC 2009


Nicolas Cellier uploaded a new version of Balloon to project The Trunk:
http://source.squeak.org/trunk/Balloon-nice.15.mcz

==================== Summary ====================

Name: Balloon-nice.15
Author: nice
Time: 27 December 2009, 3:22:58 am
UUID: 6cf1cdb7-9cbf-4778-98a1-b8c596d6004d
Ancestors: Balloon-nice.14

Cosmetic: move or remove a few temps inside closures

=============== Diff against Balloon-nice.14 ===============

Item was changed:
  ----- Method: LineSegment>>bezierClipInterval: (in category 'bezier clipping') -----
  bezierClipInterval: aCurve
  	"Compute the new bezier clip interval for the argument,
  	based on the fat line (the direction aligned bounding box) of the receiver.
  	Note: This could be modified so that multiple clip intervals are returned.
  	The idea is that for a distance curve like
  
  			x		x
  	tMax----	--\-----/---\-------
  				x		x
  	tMin-------------------------
  
  	all the intersections intervals with tMin/tMax are reported, therefore
  	minimizing the iteration count. As it is, the process will slowly iterate
  	against tMax and then the curve will be split.
  	"
+ 	| nrm tStep pts eps inside tValue tMin tMax last lastV lastT lastInside next nextV nextT nextInside vMin vMax |
- 	| nrm tStep pts eps inside vValue vMin vMax tValue tMin tMax 
- 	last lastV lastT lastInside next nextV nextT nextInside |
  	eps := 0.00001.					"distance epsilon"
  	nrm := (start y - end y) @ (end x - start x). "normal direction for (end-start)"
  
  	"Map receiver's control point into fat line; compute vMin and vMax"
  	vMin := vMax := nil.
+ 	self controlPointsDo:[:pt| | vValue |
- 	self controlPointsDo:[:pt|
  		vValue := (nrm x * pt x) + (nrm y * pt y). "nrm dotProduct: pt."
  		vMin == nil	ifTrue:[	vMin := vMax := vValue]
  					ifFalse:[vValue < vMin ifTrue:[vMin := vValue].
  							vValue > vMax ifTrue:[vMax := vValue]]].
  	"Map the argument into fat line; compute tMin, tMax for clip"
  	tStep := 1.0 / aCurve degree.
  	pts := aCurve controlPoints.
  	last := pts at: pts size.
  	lastV := (nrm x * last x) + (nrm y * last y). "nrm dotProduct: last."
  	lastT := 1.0.
  	lastInside := lastV+eps < vMin ifTrue:[-1] ifFalse:[lastV-eps > vMax ifTrue:[1] ifFalse:[0]].
  
  	"Now compute new minimal and maximal clip boundaries"
  	inside := false.	"assume we're completely outside"
  	tMin := 2.0. tMax := -1.0. 	"clip interval"
  	1 to: pts size do:[:i|
  		next := pts at: i.
  		nextV := (nrm x * next x) + (nrm y * next y). "nrm dotProduct: next."
  		false ifTrue:[
  			(nextV - vMin / (vMax - vMin)) printString displayAt: 0@ (i-1*20)].
  		nextT := i-1 * tStep.
  		nextInside := nextV+eps < vMin ifTrue:[-1] ifFalse:[nextV-eps > vMax ifTrue:[1] ifFalse:[0]].
  		nextInside = 0 ifTrue:[
  			inside := true.
  			tValue := nextT.
  			tValue < tMin ifTrue:[tMin := tValue].
  			tValue > tMax ifTrue:[tMax := tValue].
  		].
  		lastInside = nextInside ifFalse:["At least one clip boundary"
  			inside := true.
  			"See if one is below vMin"
  			(lastInside + nextInside <= 0) ifTrue:[
  				tValue := lastT + ((nextT - lastT) * (vMin - lastV) / (nextV - lastV)).
  				tValue < tMin ifTrue:[tMin := tValue].
  				tValue > tMax ifTrue:[tMax := tValue].
  			].
  			"See if one is above vMax"
  			(lastInside + nextInside >= 0) ifTrue:[
  				tValue := lastT + ((nextT - lastT) * (vMax - lastV) / (nextV - lastV)).
  				tValue < tMin ifTrue:[tMin := tValue].
  				tValue > tMax ifTrue:[tMax := tValue].
  			].
  		].
  		last := next.
  		lastT := nextT.
  		lastV := nextV.
  		lastInside := nextInside.
  	].
  	inside
  		ifTrue:[^Array with: tMin with: tMax]
  		ifFalse:[^nil]!

Item was changed:
  ----- Method: BalloonEngineConstants class>>initializeInstVarNames:prefixedBy: (in category 'pool definition') -----
  initializeInstVarNames: aClass prefixedBy: aString
  
+ 	| token |
+ 	aClass instVarNames doWithIndex:[:instVarName :index| | value |
- 	| token value |
- 	aClass instVarNames doWithIndex:[:instVarName :index|
  		token := (aString, instVarName first asUppercase asString, (instVarName copyFrom: 2 to: instVarName size),'Index') asSymbol.
  		value := index - 1.
  		(self bindingOf: token) ifNil:[self addClassVarName: token].
  		(self bindingOf: token) value: value.
  	].
  	token := (aString, aClass name,'Size') asSymbol.
  	(self bindingOf: token) ifNil:[self addClassVarName: token].
  	(self bindingOf: token) value: aClass instSize.!

Item was changed:
  ----- Method: GradientFillStyle>>computePixelRampOfSize: (in category 'private') -----
  computePixelRampOfSize: length
  	"Compute the pixel ramp in the receiver"
+ 	| bits lastValue ramp lastColor lastIndex lastWord |
- 	| bits lastColor lastIndex nextIndex nextColor distance theta lastValue ramp lastWord nextWord step |
  	ramp := colorRamp asSortedCollection:[:a1 :a2| a1 key < a2 key].
  	bits := Bitmap new: length.
  	lastColor := ramp first value.
  	lastWord := lastColor pixelWordForDepth: 32.
  	lastIndex := 0.
+ 	ramp do:[:assoc| | nextIndex nextColor distance theta step nextWord |
- 	ramp do:[:assoc|
  		nextIndex := (assoc key * length) rounded.
  		nextColor := assoc value.
  		nextWord := nextColor pixelWordForDepth: 32.
  		distance := (nextIndex - lastIndex).
  		distance = 0 ifTrue:[distance := 1].
  		step := 1.0 / distance asFloat.
  		theta := 0.0.
  		lastIndex+1 to: nextIndex do:[:i|
  			theta := theta + step.
  			"The following is an open-coded version of:
  				color := nextColor alphaMixed: theta with: lastColor.
  				bits at: i put: (color scaledPixelValue32).
  			"
  			bits at: i put: (self scaledAlphaMix: theta of: lastWord with: nextWord).
  		].
  		lastIndex := nextIndex.
  		lastColor := nextColor.
  		lastWord := nextWord.
  	].
  	lastValue := lastColor scaledPixelValue32.
  	lastIndex+1 to: length do:[:i| bits at: i put: lastValue].
  	^bits!




More information about the Squeak-dev mailing list