[Pkg] The Trunk: Graphics-ul.186.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Jun 18 08:50:12 UTC 2011


Levente Uzonyi uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-ul.186.mcz

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

Name: Graphics-ul.186
Author: ul
Time: 17 June 2011, 4:32:51.548 pm
UUID: 70931a0c-97fc-8b4f-b8b4-2fa5657baa72
Ancestors: Graphics-cmm.185

- Use #repeat instead of [ true ] whileTrue and friends.

=============== Diff against Graphics-cmm.185 ===============

Item was changed:
  ----- Method: CompositionScanner>>composeFrom:inRectangle:firstLine:leftSide:rightSide: (in category 'scanning') -----
  composeFrom: startIndex inRectangle: lineRectangle
  	firstLine: firstLine leftSide: leftSide rightSide: rightSide
  	"Answer an instance of TextLineInterval that represents the next line in the paragraph."
  	| runLength stopCondition |
  	"Set up margins"
  	leftMargin := lineRectangle left.
  	leftSide ifTrue: [leftMargin := leftMargin +
  						(firstLine ifTrue: [textStyle firstIndent]
  								ifFalse: [textStyle restIndent])].
  	destX := spaceX := leftMargin.
  	rightMargin := lineRectangle right.
  	rightSide ifTrue: [rightMargin := rightMargin - textStyle rightIndent].
  	lastIndex := startIndex.	"scanning sets last index"
  	destY := lineRectangle top.
  	lineHeight := baseline := 0.  "Will be increased by setFont"
  	line := (TextLine start: lastIndex stop: 0 internalSpaces: 0 paddingWidth: 0)
  				rectangle: lineRectangle.
  	self setStopConditions.	"also sets font"
  	runLength := text runLengthFor: startIndex.
  	runStopIndex := (lastIndex := startIndex) + (runLength - 1).
  	spaceCount := 0.
  	self handleIndentation.
  	leftMargin := destX.
  	line leftMargin: leftMargin.
  
+ 	[stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
+ 		in: text string rightX: rightMargin stopConditions: stopConditions
+ 		kern: kern.
+ 	"See setStopConditions for stopping conditions for composing."
+ 	(self perform: stopCondition)
+ 		ifTrue: [^ line lineHeight: lineHeight + textStyle leading
+ 						baseline: baseline + textStyle leading]] repeat!
- 	[false]
- 		whileFalse: 
- 			[stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
- 				in: text string rightX: rightMargin stopConditions: stopConditions
- 				kern: kern.
- 			"See setStopConditions for stopping conditions for composing."
- 			(self perform: stopCondition)
- 				ifTrue: [^ line lineHeight: lineHeight + textStyle leading
- 							baseline: baseline + textStyle leading]]!

Item was changed:
  ----- Method: CompositionScanner>>composeLine:fromCharacterIndex:inParagraph: (in category 'scanning') -----
  composeLine: lineIndex fromCharacterIndex: startIndex inParagraph: aParagraph 
  	"Answer an instance of TextLineInterval that represents the next line in the paragraph."
  	| runLength stopCondition |
  	destX := spaceX := leftMargin := aParagraph leftMarginForCompositionForLine: lineIndex.
  	destY := 0.
  	rightMargin := aParagraph rightMarginForComposition.
  	leftMargin >= rightMargin ifTrue: [self error: 'No room between margins to compose'].
  	lastIndex := startIndex.	"scanning sets last index"
  	lineHeight := textStyle lineGrid.  "may be increased by setFont:..."
  	baseline := textStyle baseline.
  	self setStopConditions.	"also sets font"
  	self handleIndentation.
  	runLength := text runLengthFor: startIndex.
  	runStopIndex := (lastIndex := startIndex) + (runLength - 1).
  	line := TextLineInterval
  		start: lastIndex
  		stop: 0
  		internalSpaces: 0
  		paddingWidth: 0.
  	spaceCount := 0.
+ 	
+ 	[stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
+ 		in: text string rightX: rightMargin stopConditions: stopConditions
+ 		kern: kern.
+ 	"See setStopConditions for stopping conditions for composing."
+ 	(self perform: stopCondition)
+ 		ifTrue: [^line lineHeight: lineHeight + textStyle leading
+ 					baseline: baseline + textStyle leading]] repeat!
- 	[false]
- 		whileFalse: 
- 			[stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
- 				in: text string rightX: rightMargin stopConditions: stopConditions
- 				kern: kern.
- 			"See setStopConditions for stopping conditions for composing."
- 			(self perform: stopCondition)
- 				ifTrue: [^line lineHeight: lineHeight + textStyle leading
- 							baseline: baseline + textStyle leading]]!

Item was changed:
  ----- Method: Form class>>toothpaste: (in category 'examples') -----
  toothpaste: diam		"Display restoreAfter: [Form toothpaste: 30]"
  	"Draws wormlike lines by laying down images of spheres.
  	See Ken Knowlton, Computer Graphics, vol. 15 no. 4 p352.
  	Draw with mouse button down; terminate by option-click."
  	| facade ball filter point queue port color q colors colr colr2 |
  	colors := Display depth = 1
  		ifTrue: [Array with: Color black]
  		ifFalse: [Color red wheel: 12].
  	facade := Form extent: diam at diam offset: (diam // -2) asPoint.
  	(Form dotOfSize: diam) displayOn: facade
  			at: (diam // 2) asPoint clippingBox: facade boundingBox
  			rule: Form under fillColor: Color white.
  	#(1 2 3) do:
  		[:x |  "simulate facade by circles of gray"
  		(Form dotOfSize: x * diam // 5) displayOn: facade
  			at: (diam * 2 // 5) asPoint clippingBox: facade boundingBox
  			rule: Form under
  			fillColor: (Color perform: 
  					(#(black gray lightGray) at: x)).
  		"facade displayAt: 50*x at 50"].
  	ball := Form dotOfSize: diam.
  	color := 8.
+ 	[port := BitBlt current toForm: Display.
+ 	"Expand 1-bit forms to any pixel depth"
+ 	port colorMap: (Bitmap with: 0 with: 16rFFFFFFFF).
+ 	queue := OrderedCollection new: 32.
+ 	16 timesRepeat: [queue addLast: -20 @ -20].
+ 	Sensor waitButton.
+ 	Sensor yellowButtonPressed ifTrue: [^ self].
+ 	filter := Sensor cursorPoint.
+ 	colr := colors atWrap: (color := color + 5).  "choose increment relatively prime to colors size"
+ 	colr2 := colr alphaMixed: 0.3 with: Color white.
+ 	[Sensor redButtonPressed or: [queue size > 0]] whileTrue:
+ 		[filter := filter * 4 + Sensor cursorPoint  //  5.
+ 		point := Sensor redButtonPressed
+ 			ifTrue: [filter] ifFalse: [-20 @ -20].
+ 		port copyForm: ball to: point rule: Form paint fillColor: colr.
+ 		(q := queue removeFirst) == nil ifTrue: [^ self].	"exit"
+ 		Display depth = 1
+ 			ifTrue: [port copyForm: facade to: q rule: Form erase]
+ 			ifFalse: [port copyForm: facade to: q rule: Form paint fillColor: colr2].
+ 		Sensor redButtonPressed ifTrue: [queue addLast: point]]] repeat.
- 	[ true ] whileTrue:
- 		[port := BitBlt current toForm: Display.
- 		"Expand 1-bit forms to any pixel depth"
- 		port colorMap: (Bitmap with: 0 with: 16rFFFFFFFF).
- 		queue := OrderedCollection new: 32.
- 		16 timesRepeat: [queue addLast: -20 @ -20].
- 		Sensor waitButton.
- 		Sensor yellowButtonPressed ifTrue: [^ self].
- 		filter := Sensor cursorPoint.
- 		colr := colors atWrap: (color := color + 5).  "choose increment relatively prime to colors size"
- 		colr2 := colr alphaMixed: 0.3 with: Color white.
- 		[Sensor redButtonPressed or: [queue size > 0]] whileTrue:
- 			[filter := filter * 4 + Sensor cursorPoint  //  5.
- 			point := Sensor redButtonPressed
- 				ifTrue: [filter] ifFalse: [-20 @ -20].
- 			port copyForm: ball to: point rule: Form paint fillColor: colr.
- 			(q := queue removeFirst) == nil ifTrue: [^ self].	"exit"
- 			Display depth = 1
- 				ifTrue: [port copyForm: facade to: q rule: Form erase]
- 				ifFalse: [port copyForm: facade to: q rule: Form paint fillColor: colr2].
- 			Sensor redButtonPressed ifTrue: [queue addLast: point]]].
  !

Item was changed:
  ----- Method: Pen>>web (in category 'geometric designs') -----
  web   "Display restoreAfter: [Pen new web]"
  	"Draw pretty web-like patterns from the mouse movement on the screen.
  	Press the mouse button to draw, option-click to exit.
  	By Dan Ingalls and Mark Lentczner. "
  	| history newPoint ancientPoint lastPoint filter color |
  	"self erase."
  	color := 1.
+ 	[ history := OrderedCollection new.
+ 	Sensor waitButton.
+ 	Sensor yellowButtonPressed ifTrue: [^ self].
+ 	filter := lastPoint := Sensor mousePoint.
+ 	20 timesRepeat: [ history addLast: lastPoint ].
+ 	self color: (color := color + 1).
+ 	[ Sensor redButtonPressed ] whileTrue: 
+ 		[ newPoint := Sensor mousePoint.
+ 		(newPoint = lastPoint) ifFalse:
+ 			[ ancientPoint := history removeFirst.
+ 			filter := filter * 4 + newPoint // 5.
+ 			self place: filter.
+ 			self goto: ancientPoint.
+ 			lastPoint := newPoint.
+ 			history addLast: filter ] ] ] repeat!
- 	[ true ] whileTrue:
- 		[ history := OrderedCollection new.
- 		Sensor waitButton.
- 		Sensor yellowButtonPressed ifTrue: [^ self].
- 		filter := lastPoint := Sensor mousePoint.
- 		20 timesRepeat: [ history addLast: lastPoint ].
- 		self color: (color := color + 1).
- 		[ Sensor redButtonPressed ] whileTrue: 
- 			[ newPoint := Sensor mousePoint.
- 			(newPoint = lastPoint) ifFalse:
- 				[ ancientPoint := history removeFirst.
- 				filter := filter * 4 + newPoint // 5.
- 				self place: filter.
- 				self goto: ancientPoint.
- 				lastPoint := newPoint.
- 				history addLast: filter ] ] ]!



More information about the Packages mailing list