|
Class: TranslucentColor
Object
|
+--Color
|
+--TranslucentColor
- Package:
- stx:libview
- Category:
- Graphics-Support
- Version:
- rev:
1.16
date: 2023/05/20 02:11:29
- user: cg
- file: TranslucentColor.st directory: libview
- module: stx stc-classLibrary: libview
TranslucentColor represents colors with an alpha (transparency) channel.
This is experimental and not yet used by the system.
[Instance variables:]
alpha <Integer> the internal alpha value (0..255)
copyrightCOPYRIGHT (c) 1999 by Claus Gittinger / eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
instance creation
-
red: r green: g blue: b alpha: alpha
-
-
scaledRed: r scaledGreen: g scaledBlue: b alpha: alpha
-
TranslucentColor scaledRed:0 scaledGreen:0 scaledBlue:0
TranslucentColor scaledRed:0 scaledGreen:0 scaledBlue:0 alpha:1
TranslucentColor scaledRed:0 scaledGreen:0 scaledBlue:0 alpha:0.5
(TranslucentColor scaledRed:0 scaledGreen:0 scaledBlue:0 alpha:0.5) lightened
accessing
-
alpha
-
return the alpha value (0..1),
where 0 is completely transparent and 1 is completely opaque
-
alpha: alphaFraction
-
return a (possibly) new color with the same color, but different alpha as the receiver.
The alpha argument's range is 0..1 (0=completely transparent; 1=completely opaque)
-
alphaByte
-
return the alpha value as byte 0..255,
where 0 is completely transparent and 255 is completely opaque
-
privateAlpha
-
return the internal alpha value (0..255),
where 0 is completely transparent and 255 is completely opaque
-
scaledAlpha
-
return the alpha value (0..16rFFFF),
where 0 is completely transparent and 16rFFFF is completely opaque
-
setAlpha: alphaFraction
-
set the alpha value (0..1),
where 0 is completely transparent and 1 is completely opaque
-
setAlphaByte: aByteValuedInteger
-
set the alpha value (0..255),
where 0 is completely transparent and 255 is completely opaque
-
setScaledRed: r scaledGreen: g scaledBlue: b
-
r,g,b must be 0..MAXVALUE
-
setScaledRed: r scaledGreen: g scaledBlue: b alpha: alphaFraction
-
alphaFraction must be 0..1;
r,g,b must be 0..MAXVALUE
-
setScaledRed: r scaledGreen: g scaledBlue: b alphaByte: a
-
a must be 0..255;
r,g,b must be 0..MAXVALUE
color operations
-
mixed: amount with: aColor
-
create a new color from mixing amount of the receiver
with the argument, aColor.
Mixing is done by adding components (i.e. additive mixing)
(which is different from mixing colors on paper, which is subtractive).
With an amount of 1, this is the same as blendWith.
comparing
-
= aColor
-
(comment from inherited method)
two colors are considered equal, if the color components are;
independent of the device, the color is on
-
almostSameAs: aColor
-
return true, if aColor looks almost the same as the receiver
(i.e. the components differ by a small, invisible amount).
We assume, that the human eye can distinguish roughly 100 grey levels
(which is optimistic ;-);
therefore, allow a 1 percent difference in each component for the colors
to compare as looking the same.
conversion
-
asOpaqueColor
-
inspecting
-
inspectorValueStringInListFor: anInspector
-
returns a string to be shown in the inspector's list
printing & storing
-
storeOn: aStream
-
append a string representing an expression to reconstruct the receiver
to the argument, aStream
Usage example(s):
(self red:100 green:100 blue:0 alpha:1) storeOn:Transcript
|
queries
-
isOpaque
-
return true, if I represent an opaque color
-
isTranslucent
-
return true, if I represent a translucent color;
that is: not completely opaque
-
isTranslucentColor
-
return true, if I represent a translucent color;
This means: self isTranslucent, but isTransparent not
-
isTransparent
-
return true, if I represent a completely transparent color
|