Matthew Fulmer uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mtf.166.mcz
==================== Summary ====================
Name: Graphics-mtf.166
Author: mtf
Time: 29 December 2010, 12:18:13.549 am
UUID: 3699b0e8-b9af-004c-8838-79c154a58c8e
Ancestors: Graphics-mtf.165
- fix 16->32 bit WarpBlt w/ smoothing. Cherrypicked from Croquet:
Name: Graphics-ar.19
Author: ar
Time: 26 April 2007, 10:27:46 pm
UUID: 168b5074-6c71-cc45-902a-b8df103114e4
Ancestors: Graphics-bf.18
- fix 16->32 bit WarpBlt w/ smoothing
=============== Diff against Graphics-mtf.165 ===============
Item was changed:
----- Method: WarpBlt>>cellSize: (in category 'setup') -----
cellSize: s
+ "Set the number of samples used for averaging"
cellSize := s.
cellSize = 1 ifTrue: [^ self].
+ "Install the colorMap to used for mapping the averaged RGBA 32bit pixels to the
+ destination depth. Note that we need to install the 32->32 color map explicitly because
+ the VM will substitute a colorMap derived from sourceForm->destForm mapping which
+ is just plain wrong for <32 source and 32bit dest depth"
+ (destForm depth = 32 and: [sourceForm notNil] and: [sourceForm depth < 32])
+ ifTrue:[colorMap := ColorMap shifts: #(0 0 0 0) masks:#(16rFF0000 16rFF00 16rFF 16rFF000000) colors: nil]
+ ifFalse:[colorMap := Color colorMapIfNeededFrom: 32 to: destForm depth].
- colorMap := Color colorMapIfNeededFrom: 32 to: destForm depth.
!
Matthew Fulmer uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mtf.166.mcz
==================== Summary ====================
Name: Graphics-mtf.166
Author: mtf
Time: 29 December 2010, 12:18:13.549 am
UUID: 3699b0e8-b9af-004c-8838-79c154a58c8e
Ancestors: Graphics-mtf.165
- fix 16->32 bit WarpBlt w/ smoothing. Cherrypicked from Croquet:
Name: Graphics-ar.19
Author: ar
Time: 26 April 2007, 10:27:46 pm
UUID: 168b5074-6c71-cc45-902a-b8df103114e4
Ancestors: Graphics-bf.18
- fix 16->32 bit WarpBlt w/ smoothing
=============== Diff against Graphics-mtf.165 ===============
Item was changed:
----- Method: WarpBlt>>cellSize: (in category 'setup') -----
cellSize: s
+ "Set the number of samples used for averaging"
cellSize := s.
cellSize = 1 ifTrue: [^ self].
+ "Install the colorMap to used for mapping the averaged RGBA 32bit pixels to the
+ destination depth. Note that we need to install the 32->32 color map explicitly because
+ the VM will substitute a colorMap derived from sourceForm->destForm mapping which
+ is just plain wrong for <32 source and 32bit dest depth"
+ (destForm depth = 32 and: [sourceForm notNil] and: [sourceForm depth < 32])
+ ifTrue:[colorMap := ColorMap shifts: #(0 0 0 0) masks:#(16rFF0000 16rFF00 16rFF 16rFF000000) colors: nil]
+ ifFalse:[colorMap := Color colorMapIfNeededFrom: 32 to: destForm depth].
- colorMap := Color colorMapIfNeededFrom: 32 to: destForm depth.
!
Matthew Fulmer uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mtf.166.mcz
==================== Summary ====================
Name: Graphics-mtf.166
Author: mtf
Time: 29 December 2010, 12:18:13.549 am
UUID: 3699b0e8-b9af-004c-8838-79c154a58c8e
Ancestors: Graphics-mtf.165
- fix 16->32 bit WarpBlt w/ smoothing. Cherrypicked from Croquet:
Name: Graphics-ar.19
Author: ar
Time: 26 April 2007, 10:27:46 pm
UUID: 168b5074-6c71-cc45-902a-b8df103114e4
Ancestors: Graphics-bf.18
- fix 16->32 bit WarpBlt w/ smoothing
=============== Diff against Graphics-mtf.165 ===============
Item was changed:
----- Method: WarpBlt>>cellSize: (in category 'setup') -----
cellSize: s
+ "Set the number of samples used for averaging"
cellSize := s.
cellSize = 1 ifTrue: [^ self].
+ "Install the colorMap to used for mapping the averaged RGBA 32bit pixels to the
+ destination depth. Note that we need to install the 32->32 color map explicitly because
+ the VM will substitute a colorMap derived from sourceForm->destForm mapping which
+ is just plain wrong for <32 source and 32bit dest depth"
+ (destForm depth = 32 and: [sourceForm notNil] and: [sourceForm depth < 32])
+ ifTrue:[colorMap := ColorMap shifts: #(0 0 0 0) masks:#(16rFF0000 16rFF00 16rFF 16rFF000000) colors: nil]
+ ifFalse:[colorMap := Color colorMapIfNeededFrom: 32 to: destForm depth].
- colorMap := Color colorMapIfNeededFrom: 32 to: destForm depth.
!
Matthew Fulmer uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mtf.165.mcz
==================== Summary ====================
Name: Graphics-mtf.165
Author: mtf
Time: 29 December 2010, 12:10:24.297 am
UUID: ad093cc3-3d69-7f42-969e-a103e2dca6a3
Ancestors: Graphics-mtf.164
added u, v accessors to Point, for convenience when dealing with textures. cherrypicked from Cobalt:
Name: Graphics-jrd.22
Author: jrd
Time: 30 June 2010, 12:43:30 am
UUID: 4dbde08d-b493-4013-b645-5ea17194d447
Ancestors: Graphics-mtf.21
Changed:
- Added convenience methods to create and access a point using u and v (as is the usage in texture coordinates) instead of x and y
=============== Diff against Graphics-mtf.164 ===============
Item was added:
+ ----- Method: Point class>>u:v: (in category 'instance creation') -----
+ u: xInteger v: yInteger
+ "Answer an instance of me with coordinates xInteger and yInteger."
+
+ ^self new setX: xInteger setY: yInteger!
Item was added:
+ ----- Method: Point>>u (in category 'accessing') -----
+ u
+ ^x!
Item was added:
+ ----- Method: Point>>v (in category 'accessing') -----
+ v
+ ^y!
Matthew Fulmer uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mtf.165.mcz
==================== Summary ====================
Name: Graphics-mtf.165
Author: mtf
Time: 29 December 2010, 12:10:24.297 am
UUID: ad093cc3-3d69-7f42-969e-a103e2dca6a3
Ancestors: Graphics-mtf.164
added u, v accessors to Point, for convenience when dealing with textures. cherrypicked from Cobalt:
Name: Graphics-jrd.22
Author: jrd
Time: 30 June 2010, 12:43:30 am
UUID: 4dbde08d-b493-4013-b645-5ea17194d447
Ancestors: Graphics-mtf.21
Changed:
- Added convenience methods to create and access a point using u and v (as is the usage in texture coordinates) instead of x and y
=============== Diff against Graphics-mtf.164 ===============
Item was added:
+ ----- Method: Point class>>u:v: (in category 'instance creation') -----
+ u: xInteger v: yInteger
+ "Answer an instance of me with coordinates xInteger and yInteger."
+
+ ^self new setX: xInteger setY: yInteger!
Item was added:
+ ----- Method: Point>>u (in category 'accessing') -----
+ u
+ ^x!
Item was added:
+ ----- Method: Point>>v (in category 'accessing') -----
+ v
+ ^y!
Matthew Fulmer uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mtf.165.mcz
==================== Summary ====================
Name: Graphics-mtf.165
Author: mtf
Time: 29 December 2010, 12:10:24.297 am
UUID: ad093cc3-3d69-7f42-969e-a103e2dca6a3
Ancestors: Graphics-mtf.164
added u, v accessors to Point, for convenience when dealing with textures. cherrypicked from Cobalt:
Name: Graphics-jrd.22
Author: jrd
Time: 30 June 2010, 12:43:30 am
UUID: 4dbde08d-b493-4013-b645-5ea17194d447
Ancestors: Graphics-mtf.21
Changed:
- Added convenience methods to create and access a point using u and v (as is the usage in texture coordinates) instead of x and y
=============== Diff against Graphics-mtf.164 ===============
Item was added:
+ ----- Method: Point class>>u:v: (in category 'instance creation') -----
+ u: xInteger v: yInteger
+ "Answer an instance of me with coordinates xInteger and yInteger."
+
+ ^self new setX: xInteger setY: yInteger!
Item was added:
+ ----- Method: Point>>u (in category 'accessing') -----
+ u
+ ^x!
Item was added:
+ ----- Method: Point>>v (in category 'accessing') -----
+ v
+ ^y!
Matthew Fulmer uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mtf.164.mcz
==================== Summary ====================
Name: Graphics-mtf.164
Author: mtf
Time: 28 December 2010, 11:51:46.6 pm
UUID: f7f4e7f9-bd12-e84d-9a0a-106a460ea3f7
Ancestors: Graphics-ar.163
Imports from Cobalt:
- added Color pantonePurpleU
- use a configurable error dump file
=============== Diff against Graphics-ar.163 ===============
Item was changed:
Object subclass: #Color
instanceVariableNames: 'rgb cachedDepth cachedBitPattern'
+ classVariableNames: 'Black Blue BlueShift Brown CachedColormaps ColorChart ColorNames ComponentMask ComponentMax Cyan DarkGray Gray GrayToIndexMap Green GreenShift HalfComponentMask HighLightBitmaps IndexedColors LightBlue LightBrown LightCyan LightGray LightGreen LightMagenta LightOrange LightRed LightYellow Magenta MaskingMap Orange PaleBlue PaleBuff PaleGreen PaleMagenta PaleOrange PalePeach PaleRed PaleTan PaleYellow PantonePurpleU PureBlue PureCyan PureGreen PureMagenta PureRed PureYellow RandomStream Red RedShift TranslucentPatterns Transparent VeryDarkGray VeryLightGray VeryPaleRed VeryVeryDarkGray VeryVeryLightGray White Yellow'
- classVariableNames: 'Black Blue BlueShift Brown CachedColormaps ColorChart ColorNames ComponentMask ComponentMax Cyan DarkGray Gray GrayToIndexMap Green GreenShift HalfComponentMask HighLightBitmaps IndexedColors LightBlue LightBrown LightCyan LightGray LightGreen LightMagenta LightOrange LightRed LightYellow Magenta MaskingMap Orange PaleBlue PaleBuff PaleGreen PaleMagenta PaleOrange PalePeach PaleRed PaleTan PaleYellow PureBlue PureCyan PureGreen PureMagenta PureRed PureYellow RandomStream Red RedShift TranslucentPatterns Transparent VeryDarkGray VeryLightGray VeryPaleRed VeryVeryDarkGray VeryVeryLightGray White Yellow'
poolDictionaries: ''
category: 'Graphics-Primitives'!
!Color commentStamp: '<historical>' prior: 0!
This class represents abstract color, regardless of the depth of bitmap it will be shown in. At the very last moment a Color is converted to a pixelValue that depends on the depth of the actual Bitmap inside the Form it will be used with. The supported depths (in bits) are 1, 2, 4, 8, 16, and 32. The number of actual colors at these depths are: 2, 4, 16, 256, 32768, and 16 million. (See comment in BitBlt.) To change the depth of the Display and set how many colors you can see, execute: (Display newDepth: 8). (See comment in DisplayMedium)
Color is represented as the amount of light in red, green, and blue. White is (1.0, 1.0, 1.0) and black is (0, 0, 0). Pure red is (1.0, 0, 0). These colors are "additive". Think of Color's instance variables as:
r amount of red, a Float between 0.0 and 1.0.
g amount of green, a Float between 0.0 and 1.0.
b amount of blue, a Float between 0.0 and 1.0.
(But, in fact, the three are encoded as values from 0 to 1023 and combined in a single integer, rgb. The user does not need to know this.)
Many colors are named. You find a color by name by sending a message to class Color, for example (Color lightBlue). Also, (Color red: 0.2 green: 0.6 blue: 1.0) or (Color r: 0.2 g: 0.6 b: 1.0) creates a color. (see below)
A color is essentially immutable. Once you set red, green, and blue, you cannot change them. Instead, create a new Color and use it.
Applications such as contour maps and bar graphs will want to display one of a set of shades based on a number. Convert the range of this number to an integer from 1 to N. Then call (Color green lightShades: N) to get an Array of colors from white to green. Use the Array messages at:, atPin:, or atWrap: to pull out the correct color from the array. atPin: gives the first (or last) color if the index is out of range. atWrap: wraps around to the other end if the index is out of range.
Here are some fun things to run in when your screen has color:
Pen new mandala: 30 diameter: Display height-100.
Pen new web "Draw with the mouse, opt-click to end"
Display fillWhite. Pen new hilberts: 5.
Form toothpaste: 30 "Draw with mouse, opt-click to end"
You might also want to try the comment in
Form>class>examples>tinyText...
Messages:
mixed: proportion with: aColor Answer this color mixed with the given color additively. The proportion, a number between 0.0 and 1.0, determines what what fraction of the receiver to use in the mix.
+ add two colors
- subtract two colors
* multiply the values of r, g, b by a number or an Array of factors. ((Color named: #white) * 0.3) gives a darkish gray. (aColor * #(0 0 0.9)) gives a color with slightly less blue.
/ divide a color by a factor or an array of three factors.
errorForDepth: d How close the nearest color at this depth is to this abstract color. Sum of the squares of the RGB differences, square rooted and normalized to 1.0. Multiply by 100 to get percent.
hue Returns the hue of the color. On a wheel from 0 to 360 with pure red at 0 and again at 360.
saturation Returns the saturation of the color. 0.0 to 1.0
brightness Returns the brightness of the color. 0.0 to 1.0
name Look to see if this Color has a name.
display Show a swatch of this color tracking the cursor.
lightShades: thisMany An array of thisMany colors from white to the receiver.
darkShades: thisMany An array of thisMany colors from black to the receiver. Array is of length num.
mix: color2 shades: thisMany An array of thisMany colors from the receiver to color2.
wheel: thisMany An array of thisMany colors around the color wheel starting and ending at the receiver.
pixelValueForDepth: d Returns the bits that appear be in a Bitmap of this depth for this color. Represents the nearest available color at this depth. Normal users do not need to know which pixelValue is used for which color.
Messages to Class Color.
red: r green: g blue: b Return a color with the given r, g, and b components.
r: g: b: Same as above, for fast typing.
hue: h saturation: s brightness: b Create a color with the given hue, saturation, and brightness.
pink
blue
red ... Many colors have messages that return an instance of Color.
canUnderstand: #brown Returns true if #brown is a defined color.
names An OrderedCollection of the names of the colors.
named: #notAllThatGray put: aColor Add a new color to the list and create an access message and a class variable for it.
fromUser Shows the palette of colors available at this display depth. Click anywhere to return the color you clicked on.
hotColdShades: thisMany An array of thisMany colors showing temperature from blue to red to white hot.
stdColorsForDepth: d An Array of colors available at this depth. For 16 bit and 32 bits, returns a ColorGenerator. It responds to at: with a Color for that index, simulating a very big Array.
colorFromPixelValue: value depth: d Returns a Color whose bit pattern (inside a Bitmap) at this depth is the number specified. Normal users do not need to use this.
(See also comments in these classes: Form, Bitmap, BitBlt, Pattern, MaskedForm.)!
Item was changed:
----- Method: Color class>>initializeNames (in category 'class initialization') -----
initializeNames
"Name some colors."
"Color initializeNames"
ColorNames := Set new.
self named: #black put: (Color r: 0 g: 0 b: 0).
self named: #veryVeryDarkGray put: (Color r: 0.125 g: 0.125 b: 0.125).
self named: #veryDarkGray put: (Color r: 0.25 g: 0.25 b: 0.25).
self named: #darkGray put: (Color r: 0.375 g: 0.375 b: 0.375).
self named: #gray put: (Color r: 0.5 g: 0.5 b: 0.5).
self named: #lightGray put: (Color r: 0.625 g: 0.625 b: 0.625).
self named: #veryLightGray put: (Color r: 0.75 g: 0.75 b: 0.75).
self named: #veryVeryLightGray put: (Color r: 0.875 g: 0.875 b: 0.875).
self named: #white put: (Color r: 1.0 g: 1.0 b: 1.0).
self named: #red put: (Color r: 1.0 g: 0 b: 0).
self named: #yellow put: (Color r: 1.0 g: 1.0 b: 0).
self named: #green put: (Color r: 0 g: 1.0 b: 0).
self named: #cyan put: (Color r: 0 g: 1.0 b: 1.0).
self named: #blue put: (Color r: 0 g: 0 b: 1.0).
self named: #magenta put: (Color r: 1.0 g: 0 b: 1.0).
self named: #brown put: (Color r: 0.6 g: 0.2 b: 0).
self named: #orange put: (Color r: 1.0 g: 0.6 b: 0).
self named: #lightRed put: (Color r: 1.0 g: 0.8 b: 0.8).
self named: #lightYellow put: (Color r: 1.0 g: 1.0 b: 0.8).
self named: #lightGreen put: (Color r: 0.8 g: 1.0 b: 0.6).
self named: #lightCyan put: (Color r: 0.4 g: 1.0 b: 1.0).
self named: #lightBlue put: (Color r: 0.8 g: 1.0 b: 1.0).
self named: #lightMagenta put: (Color r: 1.0 g: 0.8 b: 1.0).
self named: #lightBrown put: (Color r: 1.0 g: 0.6 b: 0.2).
self named: #lightOrange put: (Color r: 1.0 g: 0.8 b: 0.4).
self named: #transparent put: (TranslucentColor new alpha: 0.0).
self named: #paleBuff put: (Color r: 254 g: 250 b: 235 range: 255).
self named: #paleBlue put: (Color r: 222 g: 249 b: 254 range: 255).
self named: #paleYellow put: (Color r: 255 g: 255 b: 217 range: 255).
self named: #paleGreen put: (Color r: 223 g: 255 b: 213 range: 255).
self named: #paleRed put: (Color r: 255 g: 230 b: 230 range: 255).
self named: #veryPaleRed put: (Color r: 255 g: 242 b: 242 range: 255).
self named: #paleTan put: (Color r: 235 g: 224 b: 199 range: 255).
self named: #paleMagenta put: (Color r: 255 g: 230 b: 255 range: 255).
self named: #paleOrange put: (Color r: 253 g: 237 b: 215 range: 255).
self named: #palePeach put: (Color r: 255 g: 237 b: 213 range: 255).
+ self named: #pantonePurpleU put: (Color r: 193 g: 81 b: 184 range: 255).
!
Item was added:
+ ----- Method: Color class>>pantonePurpleU (in category 'named colors') -----
+ pantonePurpleU
+ ^PantonePurpleU!
Item was changed:
----- Method: DisplayScreen>>findAnyDisplayDepth (in category 'private') -----
findAnyDisplayDepth
"Return any display depth that is supported on this system."
^self findAnyDisplayDepthIfNone:[
"Ugh .... now this is a biggie - a system that does not support
any of the Squeak display depths at all."
Smalltalk
+ logSqueakError:'Fatal error: This system has no support for any display depth at all.'
+ inContext: thisContext .
- logError:'Fatal error: This system has no support for any display depth at all.'
- inContext: thisContext
- to: 'SqueakDebug.log'.
Smalltalk quitPrimitive. "There is no way to continue from here"
].!
Matthew Fulmer uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mtf.164.mcz
==================== Summary ====================
Name: Graphics-mtf.164
Author: mtf
Time: 28 December 2010, 11:51:46.6 pm
UUID: f7f4e7f9-bd12-e84d-9a0a-106a460ea3f7
Ancestors: Graphics-ar.163
Imports from Cobalt:
- added Color pantonePurpleU
- use a configurable error dump file
=============== Diff against Graphics-ar.163 ===============
Item was changed:
Object subclass: #Color
instanceVariableNames: 'rgb cachedDepth cachedBitPattern'
+ classVariableNames: 'Black Blue BlueShift Brown CachedColormaps ColorChart ColorNames ComponentMask ComponentMax Cyan DarkGray Gray GrayToIndexMap Green GreenShift HalfComponentMask HighLightBitmaps IndexedColors LightBlue LightBrown LightCyan LightGray LightGreen LightMagenta LightOrange LightRed LightYellow Magenta MaskingMap Orange PaleBlue PaleBuff PaleGreen PaleMagenta PaleOrange PalePeach PaleRed PaleTan PaleYellow PantonePurpleU PureBlue PureCyan PureGreen PureMagenta PureRed PureYellow RandomStream Red RedShift TranslucentPatterns Transparent VeryDarkGray VeryLightGray VeryPaleRed VeryVeryDarkGray VeryVeryLightGray White Yellow'
- classVariableNames: 'Black Blue BlueShift Brown CachedColormaps ColorChart ColorNames ComponentMask ComponentMax Cyan DarkGray Gray GrayToIndexMap Green GreenShift HalfComponentMask HighLightBitmaps IndexedColors LightBlue LightBrown LightCyan LightGray LightGreen LightMagenta LightOrange LightRed LightYellow Magenta MaskingMap Orange PaleBlue PaleBuff PaleGreen PaleMagenta PaleOrange PalePeach PaleRed PaleTan PaleYellow PureBlue PureCyan PureGreen PureMagenta PureRed PureYellow RandomStream Red RedShift TranslucentPatterns Transparent VeryDarkGray VeryLightGray VeryPaleRed VeryVeryDarkGray VeryVeryLightGray White Yellow'
poolDictionaries: ''
category: 'Graphics-Primitives'!
!Color commentStamp: '<historical>' prior: 0!
This class represents abstract color, regardless of the depth of bitmap it will be shown in. At the very last moment a Color is converted to a pixelValue that depends on the depth of the actual Bitmap inside the Form it will be used with. The supported depths (in bits) are 1, 2, 4, 8, 16, and 32. The number of actual colors at these depths are: 2, 4, 16, 256, 32768, and 16 million. (See comment in BitBlt.) To change the depth of the Display and set how many colors you can see, execute: (Display newDepth: 8). (See comment in DisplayMedium)
Color is represented as the amount of light in red, green, and blue. White is (1.0, 1.0, 1.0) and black is (0, 0, 0). Pure red is (1.0, 0, 0). These colors are "additive". Think of Color's instance variables as:
r amount of red, a Float between 0.0 and 1.0.
g amount of green, a Float between 0.0 and 1.0.
b amount of blue, a Float between 0.0 and 1.0.
(But, in fact, the three are encoded as values from 0 to 1023 and combined in a single integer, rgb. The user does not need to know this.)
Many colors are named. You find a color by name by sending a message to class Color, for example (Color lightBlue). Also, (Color red: 0.2 green: 0.6 blue: 1.0) or (Color r: 0.2 g: 0.6 b: 1.0) creates a color. (see below)
A color is essentially immutable. Once you set red, green, and blue, you cannot change them. Instead, create a new Color and use it.
Applications such as contour maps and bar graphs will want to display one of a set of shades based on a number. Convert the range of this number to an integer from 1 to N. Then call (Color green lightShades: N) to get an Array of colors from white to green. Use the Array messages at:, atPin:, or atWrap: to pull out the correct color from the array. atPin: gives the first (or last) color if the index is out of range. atWrap: wraps around to the other end if the index is out of range.
Here are some fun things to run in when your screen has color:
Pen new mandala: 30 diameter: Display height-100.
Pen new web "Draw with the mouse, opt-click to end"
Display fillWhite. Pen new hilberts: 5.
Form toothpaste: 30 "Draw with mouse, opt-click to end"
You might also want to try the comment in
Form>class>examples>tinyText...
Messages:
mixed: proportion with: aColor Answer this color mixed with the given color additively. The proportion, a number between 0.0 and 1.0, determines what what fraction of the receiver to use in the mix.
+ add two colors
- subtract two colors
* multiply the values of r, g, b by a number or an Array of factors. ((Color named: #white) * 0.3) gives a darkish gray. (aColor * #(0 0 0.9)) gives a color with slightly less blue.
/ divide a color by a factor or an array of three factors.
errorForDepth: d How close the nearest color at this depth is to this abstract color. Sum of the squares of the RGB differences, square rooted and normalized to 1.0. Multiply by 100 to get percent.
hue Returns the hue of the color. On a wheel from 0 to 360 with pure red at 0 and again at 360.
saturation Returns the saturation of the color. 0.0 to 1.0
brightness Returns the brightness of the color. 0.0 to 1.0
name Look to see if this Color has a name.
display Show a swatch of this color tracking the cursor.
lightShades: thisMany An array of thisMany colors from white to the receiver.
darkShades: thisMany An array of thisMany colors from black to the receiver. Array is of length num.
mix: color2 shades: thisMany An array of thisMany colors from the receiver to color2.
wheel: thisMany An array of thisMany colors around the color wheel starting and ending at the receiver.
pixelValueForDepth: d Returns the bits that appear be in a Bitmap of this depth for this color. Represents the nearest available color at this depth. Normal users do not need to know which pixelValue is used for which color.
Messages to Class Color.
red: r green: g blue: b Return a color with the given r, g, and b components.
r: g: b: Same as above, for fast typing.
hue: h saturation: s brightness: b Create a color with the given hue, saturation, and brightness.
pink
blue
red ... Many colors have messages that return an instance of Color.
canUnderstand: #brown Returns true if #brown is a defined color.
names An OrderedCollection of the names of the colors.
named: #notAllThatGray put: aColor Add a new color to the list and create an access message and a class variable for it.
fromUser Shows the palette of colors available at this display depth. Click anywhere to return the color you clicked on.
hotColdShades: thisMany An array of thisMany colors showing temperature from blue to red to white hot.
stdColorsForDepth: d An Array of colors available at this depth. For 16 bit and 32 bits, returns a ColorGenerator. It responds to at: with a Color for that index, simulating a very big Array.
colorFromPixelValue: value depth: d Returns a Color whose bit pattern (inside a Bitmap) at this depth is the number specified. Normal users do not need to use this.
(See also comments in these classes: Form, Bitmap, BitBlt, Pattern, MaskedForm.)!
Item was changed:
----- Method: Color class>>initializeNames (in category 'class initialization') -----
initializeNames
"Name some colors."
"Color initializeNames"
ColorNames := Set new.
self named: #black put: (Color r: 0 g: 0 b: 0).
self named: #veryVeryDarkGray put: (Color r: 0.125 g: 0.125 b: 0.125).
self named: #veryDarkGray put: (Color r: 0.25 g: 0.25 b: 0.25).
self named: #darkGray put: (Color r: 0.375 g: 0.375 b: 0.375).
self named: #gray put: (Color r: 0.5 g: 0.5 b: 0.5).
self named: #lightGray put: (Color r: 0.625 g: 0.625 b: 0.625).
self named: #veryLightGray put: (Color r: 0.75 g: 0.75 b: 0.75).
self named: #veryVeryLightGray put: (Color r: 0.875 g: 0.875 b: 0.875).
self named: #white put: (Color r: 1.0 g: 1.0 b: 1.0).
self named: #red put: (Color r: 1.0 g: 0 b: 0).
self named: #yellow put: (Color r: 1.0 g: 1.0 b: 0).
self named: #green put: (Color r: 0 g: 1.0 b: 0).
self named: #cyan put: (Color r: 0 g: 1.0 b: 1.0).
self named: #blue put: (Color r: 0 g: 0 b: 1.0).
self named: #magenta put: (Color r: 1.0 g: 0 b: 1.0).
self named: #brown put: (Color r: 0.6 g: 0.2 b: 0).
self named: #orange put: (Color r: 1.0 g: 0.6 b: 0).
self named: #lightRed put: (Color r: 1.0 g: 0.8 b: 0.8).
self named: #lightYellow put: (Color r: 1.0 g: 1.0 b: 0.8).
self named: #lightGreen put: (Color r: 0.8 g: 1.0 b: 0.6).
self named: #lightCyan put: (Color r: 0.4 g: 1.0 b: 1.0).
self named: #lightBlue put: (Color r: 0.8 g: 1.0 b: 1.0).
self named: #lightMagenta put: (Color r: 1.0 g: 0.8 b: 1.0).
self named: #lightBrown put: (Color r: 1.0 g: 0.6 b: 0.2).
self named: #lightOrange put: (Color r: 1.0 g: 0.8 b: 0.4).
self named: #transparent put: (TranslucentColor new alpha: 0.0).
self named: #paleBuff put: (Color r: 254 g: 250 b: 235 range: 255).
self named: #paleBlue put: (Color r: 222 g: 249 b: 254 range: 255).
self named: #paleYellow put: (Color r: 255 g: 255 b: 217 range: 255).
self named: #paleGreen put: (Color r: 223 g: 255 b: 213 range: 255).
self named: #paleRed put: (Color r: 255 g: 230 b: 230 range: 255).
self named: #veryPaleRed put: (Color r: 255 g: 242 b: 242 range: 255).
self named: #paleTan put: (Color r: 235 g: 224 b: 199 range: 255).
self named: #paleMagenta put: (Color r: 255 g: 230 b: 255 range: 255).
self named: #paleOrange put: (Color r: 253 g: 237 b: 215 range: 255).
self named: #palePeach put: (Color r: 255 g: 237 b: 213 range: 255).
+ self named: #pantonePurpleU put: (Color r: 193 g: 81 b: 184 range: 255).
!
Item was added:
+ ----- Method: Color class>>pantonePurpleU (in category 'named colors') -----
+ pantonePurpleU
+ ^PantonePurpleU!
Item was changed:
----- Method: DisplayScreen>>findAnyDisplayDepth (in category 'private') -----
findAnyDisplayDepth
"Return any display depth that is supported on this system."
^self findAnyDisplayDepthIfNone:[
"Ugh .... now this is a biggie - a system that does not support
any of the Squeak display depths at all."
Smalltalk
+ logSqueakError:'Fatal error: This system has no support for any display depth at all.'
+ inContext: thisContext .
- logError:'Fatal error: This system has no support for any display depth at all.'
- inContext: thisContext
- to: 'SqueakDebug.log'.
Smalltalk quitPrimitive. "There is no way to continue from here"
].!
Matthew Fulmer uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mtf.164.mcz
==================== Summary ====================
Name: Graphics-mtf.164
Author: mtf
Time: 28 December 2010, 11:51:46.6 pm
UUID: f7f4e7f9-bd12-e84d-9a0a-106a460ea3f7
Ancestors: Graphics-ar.163
Imports from Cobalt:
- added Color pantonePurpleU
- use a configurable error dump file
=============== Diff against Graphics-ar.163 ===============
Item was changed:
Object subclass: #Color
instanceVariableNames: 'rgb cachedDepth cachedBitPattern'
+ classVariableNames: 'Black Blue BlueShift Brown CachedColormaps ColorChart ColorNames ComponentMask ComponentMax Cyan DarkGray Gray GrayToIndexMap Green GreenShift HalfComponentMask HighLightBitmaps IndexedColors LightBlue LightBrown LightCyan LightGray LightGreen LightMagenta LightOrange LightRed LightYellow Magenta MaskingMap Orange PaleBlue PaleBuff PaleGreen PaleMagenta PaleOrange PalePeach PaleRed PaleTan PaleYellow PantonePurpleU PureBlue PureCyan PureGreen PureMagenta PureRed PureYellow RandomStream Red RedShift TranslucentPatterns Transparent VeryDarkGray VeryLightGray VeryPaleRed VeryVeryDarkGray VeryVeryLightGray White Yellow'
- classVariableNames: 'Black Blue BlueShift Brown CachedColormaps ColorChart ColorNames ComponentMask ComponentMax Cyan DarkGray Gray GrayToIndexMap Green GreenShift HalfComponentMask HighLightBitmaps IndexedColors LightBlue LightBrown LightCyan LightGray LightGreen LightMagenta LightOrange LightRed LightYellow Magenta MaskingMap Orange PaleBlue PaleBuff PaleGreen PaleMagenta PaleOrange PalePeach PaleRed PaleTan PaleYellow PureBlue PureCyan PureGreen PureMagenta PureRed PureYellow RandomStream Red RedShift TranslucentPatterns Transparent VeryDarkGray VeryLightGray VeryPaleRed VeryVeryDarkGray VeryVeryLightGray White Yellow'
poolDictionaries: ''
category: 'Graphics-Primitives'!
!Color commentStamp: '<historical>' prior: 0!
This class represents abstract color, regardless of the depth of bitmap it will be shown in. At the very last moment a Color is converted to a pixelValue that depends on the depth of the actual Bitmap inside the Form it will be used with. The supported depths (in bits) are 1, 2, 4, 8, 16, and 32. The number of actual colors at these depths are: 2, 4, 16, 256, 32768, and 16 million. (See comment in BitBlt.) To change the depth of the Display and set how many colors you can see, execute: (Display newDepth: 8). (See comment in DisplayMedium)
Color is represented as the amount of light in red, green, and blue. White is (1.0, 1.0, 1.0) and black is (0, 0, 0). Pure red is (1.0, 0, 0). These colors are "additive". Think of Color's instance variables as:
r amount of red, a Float between 0.0 and 1.0.
g amount of green, a Float between 0.0 and 1.0.
b amount of blue, a Float between 0.0 and 1.0.
(But, in fact, the three are encoded as values from 0 to 1023 and combined in a single integer, rgb. The user does not need to know this.)
Many colors are named. You find a color by name by sending a message to class Color, for example (Color lightBlue). Also, (Color red: 0.2 green: 0.6 blue: 1.0) or (Color r: 0.2 g: 0.6 b: 1.0) creates a color. (see below)
A color is essentially immutable. Once you set red, green, and blue, you cannot change them. Instead, create a new Color and use it.
Applications such as contour maps and bar graphs will want to display one of a set of shades based on a number. Convert the range of this number to an integer from 1 to N. Then call (Color green lightShades: N) to get an Array of colors from white to green. Use the Array messages at:, atPin:, or atWrap: to pull out the correct color from the array. atPin: gives the first (or last) color if the index is out of range. atWrap: wraps around to the other end if the index is out of range.
Here are some fun things to run in when your screen has color:
Pen new mandala: 30 diameter: Display height-100.
Pen new web "Draw with the mouse, opt-click to end"
Display fillWhite. Pen new hilberts: 5.
Form toothpaste: 30 "Draw with mouse, opt-click to end"
You might also want to try the comment in
Form>class>examples>tinyText...
Messages:
mixed: proportion with: aColor Answer this color mixed with the given color additively. The proportion, a number between 0.0 and 1.0, determines what what fraction of the receiver to use in the mix.
+ add two colors
- subtract two colors
* multiply the values of r, g, b by a number or an Array of factors. ((Color named: #white) * 0.3) gives a darkish gray. (aColor * #(0 0 0.9)) gives a color with slightly less blue.
/ divide a color by a factor or an array of three factors.
errorForDepth: d How close the nearest color at this depth is to this abstract color. Sum of the squares of the RGB differences, square rooted and normalized to 1.0. Multiply by 100 to get percent.
hue Returns the hue of the color. On a wheel from 0 to 360 with pure red at 0 and again at 360.
saturation Returns the saturation of the color. 0.0 to 1.0
brightness Returns the brightness of the color. 0.0 to 1.0
name Look to see if this Color has a name.
display Show a swatch of this color tracking the cursor.
lightShades: thisMany An array of thisMany colors from white to the receiver.
darkShades: thisMany An array of thisMany colors from black to the receiver. Array is of length num.
mix: color2 shades: thisMany An array of thisMany colors from the receiver to color2.
wheel: thisMany An array of thisMany colors around the color wheel starting and ending at the receiver.
pixelValueForDepth: d Returns the bits that appear be in a Bitmap of this depth for this color. Represents the nearest available color at this depth. Normal users do not need to know which pixelValue is used for which color.
Messages to Class Color.
red: r green: g blue: b Return a color with the given r, g, and b components.
r: g: b: Same as above, for fast typing.
hue: h saturation: s brightness: b Create a color with the given hue, saturation, and brightness.
pink
blue
red ... Many colors have messages that return an instance of Color.
canUnderstand: #brown Returns true if #brown is a defined color.
names An OrderedCollection of the names of the colors.
named: #notAllThatGray put: aColor Add a new color to the list and create an access message and a class variable for it.
fromUser Shows the palette of colors available at this display depth. Click anywhere to return the color you clicked on.
hotColdShades: thisMany An array of thisMany colors showing temperature from blue to red to white hot.
stdColorsForDepth: d An Array of colors available at this depth. For 16 bit and 32 bits, returns a ColorGenerator. It responds to at: with a Color for that index, simulating a very big Array.
colorFromPixelValue: value depth: d Returns a Color whose bit pattern (inside a Bitmap) at this depth is the number specified. Normal users do not need to use this.
(See also comments in these classes: Form, Bitmap, BitBlt, Pattern, MaskedForm.)!
Item was changed:
----- Method: Color class>>initializeNames (in category 'class initialization') -----
initializeNames
"Name some colors."
"Color initializeNames"
ColorNames := Set new.
self named: #black put: (Color r: 0 g: 0 b: 0).
self named: #veryVeryDarkGray put: (Color r: 0.125 g: 0.125 b: 0.125).
self named: #veryDarkGray put: (Color r: 0.25 g: 0.25 b: 0.25).
self named: #darkGray put: (Color r: 0.375 g: 0.375 b: 0.375).
self named: #gray put: (Color r: 0.5 g: 0.5 b: 0.5).
self named: #lightGray put: (Color r: 0.625 g: 0.625 b: 0.625).
self named: #veryLightGray put: (Color r: 0.75 g: 0.75 b: 0.75).
self named: #veryVeryLightGray put: (Color r: 0.875 g: 0.875 b: 0.875).
self named: #white put: (Color r: 1.0 g: 1.0 b: 1.0).
self named: #red put: (Color r: 1.0 g: 0 b: 0).
self named: #yellow put: (Color r: 1.0 g: 1.0 b: 0).
self named: #green put: (Color r: 0 g: 1.0 b: 0).
self named: #cyan put: (Color r: 0 g: 1.0 b: 1.0).
self named: #blue put: (Color r: 0 g: 0 b: 1.0).
self named: #magenta put: (Color r: 1.0 g: 0 b: 1.0).
self named: #brown put: (Color r: 0.6 g: 0.2 b: 0).
self named: #orange put: (Color r: 1.0 g: 0.6 b: 0).
self named: #lightRed put: (Color r: 1.0 g: 0.8 b: 0.8).
self named: #lightYellow put: (Color r: 1.0 g: 1.0 b: 0.8).
self named: #lightGreen put: (Color r: 0.8 g: 1.0 b: 0.6).
self named: #lightCyan put: (Color r: 0.4 g: 1.0 b: 1.0).
self named: #lightBlue put: (Color r: 0.8 g: 1.0 b: 1.0).
self named: #lightMagenta put: (Color r: 1.0 g: 0.8 b: 1.0).
self named: #lightBrown put: (Color r: 1.0 g: 0.6 b: 0.2).
self named: #lightOrange put: (Color r: 1.0 g: 0.8 b: 0.4).
self named: #transparent put: (TranslucentColor new alpha: 0.0).
self named: #paleBuff put: (Color r: 254 g: 250 b: 235 range: 255).
self named: #paleBlue put: (Color r: 222 g: 249 b: 254 range: 255).
self named: #paleYellow put: (Color r: 255 g: 255 b: 217 range: 255).
self named: #paleGreen put: (Color r: 223 g: 255 b: 213 range: 255).
self named: #paleRed put: (Color r: 255 g: 230 b: 230 range: 255).
self named: #veryPaleRed put: (Color r: 255 g: 242 b: 242 range: 255).
self named: #paleTan put: (Color r: 235 g: 224 b: 199 range: 255).
self named: #paleMagenta put: (Color r: 255 g: 230 b: 255 range: 255).
self named: #paleOrange put: (Color r: 253 g: 237 b: 215 range: 255).
self named: #palePeach put: (Color r: 255 g: 237 b: 213 range: 255).
+ self named: #pantonePurpleU put: (Color r: 193 g: 81 b: 184 range: 255).
!
Item was added:
+ ----- Method: Color class>>pantonePurpleU (in category 'named colors') -----
+ pantonePurpleU
+ ^PantonePurpleU!
Item was changed:
----- Method: DisplayScreen>>findAnyDisplayDepth (in category 'private') -----
findAnyDisplayDepth
"Return any display depth that is supported on this system."
^self findAnyDisplayDepthIfNone:[
"Ugh .... now this is a biggie - a system that does not support
any of the Squeak display depths at all."
Smalltalk
+ logSqueakError:'Fatal error: This system has no support for any display depth at all.'
+ inContext: thisContext .
- logError:'Fatal error: This system has no support for any display depth at all.'
- inContext: thisContext
- to: 'SqueakDebug.log'.
Smalltalk quitPrimitive. "There is no way to continue from here"
].!
Matthew Fulmer uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mtf.501.mcz
==================== Summary ====================
Name: Morphic-mtf.501
Author: mtf
Time: 28 December 2010, 8:43:55.314 pm
UUID: 58aeefd2-fb62-1a45-aa60-92515490433b
Ancestors: Morphic-mtf.500
import from Croquet
Name: Morphic-ar.9
Author: ar
Time: 13 March 2006, 4:26:31 pm
UUID: 071f4e22-280e-1044-bf61-112022984c8c
Ancestors: Morphic-ar.8
- add a fix for transparent backgrounds in Morphic worlds
=============== Diff against Morphic-mtf.500 ===============
Item was changed:
----- Method: WorldState>>drawWorld:submorphs:invalidAreasOn: (in category 'update cycle') -----
drawWorld: aWorld submorphs: submorphs invalidAreasOn: aCanvas
"Redraw the damaged areas of the given canvas and clear the damage list. Return a collection of the areas that
were redrawn."
| rectList n morphs rects validList |
rectList := damageRecorder invalidRectsFullBounds: aWorld viewBox.
"sort by areas to draw largest portions first"
rectList := rectList asArray sort: [:r1 :r2 | r1 area > r2 area].
damageRecorder reset.
n := submorphs size.
morphs := OrderedCollection new: n * 2.
rects := OrderedCollection new: n * 2.
validList := OrderedCollection new: n * 2.
+
+ "This is added in case we are drawing to a form that is to be used as a texture, and we want the background to be translucent."
+ aWorld color isTranslucent ifTrue:
+ [rectList do: [:r | aCanvas form fill: r fillColor: aWorld color]].
+
rectList do:
[:dirtyRect |
dirtyRect allAreasOutsideList: validList
do:
[:r | | mm rectToFill remnants c rect i |
"Experimental top-down drawing --
Traverses top to bottom, stopping if the entire area is filled.
If only a single rectangle remains, then continue with the reduced rectangle."
rectToFill := r.
i := 1.
[rectToFill isNil or: [i > n]] whileFalse:
[mm := submorphs at: i.
((mm fullBounds intersects: r) and: [mm visible])
ifTrue:
[morphs addLast: mm.
rects addLast: rectToFill.
remnants := mm areasRemainingToFill: rectToFill.
remnants size = 1 ifTrue: [rectToFill := remnants first].
remnants isEmpty ifTrue: [rectToFill := nil]].
i := i + 1].
"Now paint from bottom to top, but using the reduced rectangles."
rectToFill
ifNotNil: [aWorld drawOn: (c := aCanvas copyClipRect: rectToFill)].
[morphs isEmpty] whileFalse:
[(rect := rects removeLast) == rectToFill
ifFalse: [c := aCanvas copyClipRect: (rectToFill := rect)].
c fullDrawMorph: morphs removeLast].
morphs reset.
rects reset.
validList add: r]].
^validList!