Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mt.440.mcz ==================== Summary ==================== Name: Graphics-mt.440 Author: mt Time: 14 October 2020, 1:57:54.772569 pm UUID: 1e0ca5ca-9744-a341-8ec3-dd0079a9bb53 Ancestors: Graphics-pre.439 Rename #doWithIndex: to #withIndexDo:. See http://forum.world.st/The-Inbox-60Deprecated-ct-80-mcz-td5120706.html =============== Diff against Graphics-pre.439 =============== Item was changed: ----- Method: Color class>>colorFrom: (in category 'instance creation') ----- colorFrom: parm "Return an instantiated color from parm. If parm is already a color, return it, else return the result of my performing it if it's a symbol or, if it is a list, it can either be an array of three numbers, which will be interpreted as RGB values, or a list of symbols, the first of which is sent to me and then the others of which are in turn sent to the prior result, thus allowing entries of the form #(blue darker). Else just return the thing" | aColor firstParm | (parm isKindOf: Color) ifTrue: [^ parm]. (parm isSymbol) ifTrue: [^ self perform: parm]. (parm isString) ifTrue: [^ self fromString: parm]. ((parm isKindOf: SequenceableCollection) and: [parm size > 0]) ifTrue: [firstParm := parm first. (firstParm isKindOf: Number) ifTrue: [^ self fromRgbTriplet: parm]. aColor := self colorFrom: firstParm. + parm withIndexDo: - parm doWithIndex: [:sym :ind | ind > 1 ifTrue: [aColor := aColor perform: sym]]. ^ aColor]. ^ parm " Color colorFrom: #(blue darker) Color colorFrom: Color blue darker Color colorFrom: #blue Color colorFrom: #(0.0 0.0 1.0) "! Item was changed: ----- Method: ColorForm>>colorsUsed (in category 'color manipulation') ----- colorsUsed "Return a list of the colors actually used by this ColorForm." | myColor list | myColor := self colors. list := OrderedCollection new. + self tallyPixelValues withIndexDo: [:count :i | - self tallyPixelValues doWithIndex: [:count :i | count > 0 ifTrue: [list add: (myColor at: i)]]. ^ list asArray ! Item was changed: ----- Method: Form>>cgForPixelValue:orNot: (in category 'analyzing') ----- cgForPixelValue: pv orNot: not "Return the center of gravity for all pixels of value pv. Note: If orNot is true, then produce the center of gravity for all pixels that are DIFFERENT from the supplied (background) value" | xAndY | xAndY := (Array with: (self xTallyPixelValue: pv orNot: not) with: (self yTallyPixelValue: pv orNot: not)) collect: [:profile | | pixCount weighted | "For both x and y profiles..." pixCount := 0. weighted := 0. + profile withIndexDo: - profile doWithIndex: [:t :i | pixCount := pixCount + t. weighted := weighted + (t*i)]. pixCount = 0 "Produce average of nPixels weighted by coordinate" ifTrue: [0.0] ifFalse: [weighted asFloat / pixCount asFloat - 1.0]]. ^ xAndY first @ xAndY last " | f cg | [Sensor anyButtonPressed] whileFalse: [f := Form fromDisplay: (Sensor cursorPoint extent: 50@50). cg := f cgForPixelValue: (Color black pixelValueForDepth: f depth) orNot: false. f displayAt: 0@0. Display fill: (cg extent: 2@2) fillColor: Color red]. ScheduledControllers restore "! Item was changed: ----- Method: Form>>colorsUsed (in category 'analyzing') ----- colorsUsed "Return a list of the Colors this form uses." | tallies tallyDepth usedColors | tallies := self tallyPixelValues. tallyDepth := (tallies size log: 2) asInteger. usedColors := OrderedCollection new. + tallies withIndexDo: [:count :i | - tallies doWithIndex: [:count :i | count > 0 ifTrue: [ usedColors add: (Color colorFromPixelValue: i - 1 depth: tallyDepth)]]. ^ usedColors asArray ! Item was changed: ----- Method: FormSetFont>>fromFormArray:asciiStart:ascent: (in category 'initialize-release') ----- fromFormArray: formArray asciiStart: asciiStart ascent: ascentVal | height width x badChar | type := 2. name := 'aFormFont'. minAscii := asciiStart. maxAscii := minAscii + formArray size - 1. ascent := ascentVal. subscript := superscript := emphasis := 0. height := width := 0. maxWidth := 0. formArray do: [:f | width := width + f width. maxWidth := maxWidth max: f width. height := height max: f height + f offset y]. badChar := (Form extent: 7@height) borderWidth: 1. width := width + badChar width. descent := height - ascent. pointSize := height. glyphs := Form extent: width @ height depth: formArray first depth. xTable := Array new: maxAscii + 3 withAll: 0. x := 0. + formArray withIndexDo: - formArray doWithIndex: [:f :i | f displayOn: glyphs at: x@0. xTable at: minAscii + i+1 put: (x := x + f width)]. badChar displayOn: glyphs at: x@0. xTable at: maxAscii + 3 put: x + badChar width. characterToGlyphMap := nil.! |
Free forum by Nabble | Edit this page |