The Trunk: Graphics-ar.128.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Graphics-ar.128.mcz

commits-2
Andreas Raab uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-ar.128.mcz

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

Name: Graphics-ar.128
Author: ar
Time: 28 March 2010, 3:38:28.691 pm
UUID: 1dbdb38d-01ac-ca44-b388-8f451290286e
Ancestors: Graphics-laza.127

Generalize #lighter, #darker, #dimmed into #collectColors: and #collectPixels: which now also ensures that the form is unhibernated (this could cause problems during/after image same) and that we only do this for depth 32 as the other form depths are currently not implemented.

=============== Diff against Graphics-laza.127 ===============

Item was changed:
  ----- Method: Form>>lighter (in category 'converting') -----
  lighter
  "Answer a lighter variant of this form"
+ ^self collectColors:[:color| color lighter lighter].!
-
- ^ Form
- extent: self extent
- depth: self depth
- bits: (self bits collect: [:bit |
- (Color colorFromPixelValue: bit depth: self depth)
- lighter lighter
- pixelValueForDepth: self depth])!

Item was added:
+ ----- Method: Form>>collectColors: (in category 'converting') -----
+ collectColors: aBlock
+ "Create a new copy of the receiver with all the colors transformed by aBlock"
+ ^self collectPixels:[:pv|
+ (aBlock value: (Color colorFromPixelValue: pv depth: self depth))
+ pixelValueForDepth: self depth.
+ ].!

Item was changed:
  ----- Method: Form>>dimmed (in category 'converting') -----
  dimmed
  "Answer a dimmed variant of this form."
+ ^self collectColors:[:color| (color alpha: (color alpha min: 0.2)) ]!
-
- ^ Form
- extent: self extent
- depth: self depth
- bits: (self bits collect: [:bit | | color |
- color := Color colorFromPixelValue: bit depth: self depth.
- (color alpha: (color alpha min: 0.2)) pixelValueForDepth: self depth])!

Item was added:
+ ----- Method: Form>>collectPixels: (in category 'converting') -----
+ collectPixels: aBlock
+ "Create a new copy of the receiver with all the pixels transformed by aBlock"
+ self depth = 32 ifFalse:[^self error: 'Not implemented for depth ', self depth].
+ self unhibernate. "ensure unhibernated before touching bits"
+ ^Form
+ extent: self extent
+ depth: self depth
+ bits: (self bits collect: aBlock)!

Item was changed:
  ----- Method: Form>>darker (in category 'converting') -----
  darker
  "Answer a darker variant of this form."
+ ^self collectColors:[:color| color darker darker]!
-
- ^ Form
- extent: self extent
- depth: self depth
- bits: (self bits collect: [:bit |
- (Color colorFromPixelValue: bit depth: self depth)
- darker darker
- pixelValueForDepth: self depth])!