The Trunk: Graphics-nice.444.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-nice.444.mcz

commits-2
Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.444.mcz

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

Name: Graphics-nice.444
Author: nice
Time: 27 December 2020, 11:14:18.76654 pm
UUID: 7ad44724-768e-449e-b201-507678a23c94
Ancestors: Graphics-nice.443

Isolate alpha channel when printing a named color. This allows it to reuse the color name even for translucent color.

Example:
        (Color red alpha: 0.4) printString
Output (new):
         '(Color red alpha: 0.4)'
Output (old):
        '(TranslucentColor r: 1 g: 0.5 b: 0.0 alpha: 0.4)'
       
Note: the implementation preserves parentheses and Color transparent printString.

Thanks to Christoph Thiede (ct) for the original proposal.

=============== Diff against Graphics-nice.443 ===============

Item was changed:
+ ----- Method: TranslucentColor>>isOpaque (in category 'testing') -----
- ----- Method: TranslucentColor>>isOpaque (in category 'queries') -----
  isOpaque
  ^alpha = 255!

Item was changed:
+ ----- Method: TranslucentColor>>isTranslucent (in category 'testing') -----
- ----- Method: TranslucentColor>>isTranslucent (in category 'queries') -----
  isTranslucent
  ^ alpha < 255!

Item was changed:
+ ----- Method: TranslucentColor>>isTranslucentColor (in category 'testing') -----
- ----- Method: TranslucentColor>>isTranslucentColor (in category 'queries') -----
  isTranslucentColor
  "This means: self isTranslucent, but isTransparent not"
  ^ alpha > 0!

Item was changed:
+ ----- Method: TranslucentColor>>isTransparent (in category 'testing') -----
- ----- Method: TranslucentColor>>isTransparent (in category 'queries') -----
  isTransparent
  ^ alpha = 0!

Item was added:
+ ----- Method: TranslucentColor>>printOn: (in category 'printing') -----
+ printOn: aStream
+ | name |
+ self isTransparent ifTrue: [^ aStream nextPutAll: 'Color transparent'].
+ (name := self asNontranslucentColor name) ifNil: [^self storeOn: aStream].
+ aStream
+ nextPutAll: '(Color ';
+ nextPutAll: name;
+ nextPutAll: ' alpha: ';
+ print: self alpha maxDecimalPlaces: 3;
+ nextPut: $)
+ !

Item was changed:
  ----- Method: TranslucentColor>>storeOn: (in category 'printing') -----
  storeOn: aStream
 
+ self isTransparent ifTrue: [^ aStream nextPutAll: 'Color transparent'].
- self isTransparent ifTrue: [^ aStream nextPutAll: '(Color transparent)'].
  super storeOn: aStream.
  aStream
  skip: -1;  "get rid of trailing )"
  nextPutAll: ' alpha: ';
  print: self alpha maxDecimalPlaces: 3;
  nextPutAll: ')'.
  !