|
|
Class: Color
Object
|
+--Color
|
+--ColorValue
- Package:
- stx:libview
- Category:
- Graphics-Support
- Version:
- rev:
1.219
date: 2010/02/09 13:40:38
- user: stefan
- file: Color.st directory: libview
- module: stx stc-classLibrary: libview
- Author:
- Claus Gittinger
Color represents colors in a device independent manner, main info I keep about
mySelf are the red, green and blue components scaled into 0 .. MaxValue.
The device specific color can be aquired by sending a color the 'on:aDevice' message,
which will return a color with the same rgb values as the receiver but specific
for that device.
Colors can be pure or dithered, depending on the capabilities of the device.
For plain colors, the colorId-instvar is a handle (usually lookup-table entry) for that
device. For dithered colors, the colorId is nil and ditherForm specifies the form
used to dither that color. The ditherForm can be either a depth-1 bitmap or a pixmap
with the devices depth. The plain colors needed by the ditherForm are found in its
colormap (as usual for bitmaps).
The default algorithm for color allocation is to ask the display for colors as
new colors are created. When running out of colors, dithered colors will be used,
using existing nearest colors and a dither pattern to aproximate the color.
There could be situations, where no good colors are available for the dither, leading
to ugly looking dither colors.
This can be avoided by preallocating a set of colors over the complete range, which
makes certain that appropriate colors are later available for the dither process.
To do so, add a statement like: 'Color getColors5x5x5' to the startup.rc file.
(beside 5x5x5, there are various other size combinations available).
However, doing so may make things worse when displaying bitmap images, since this
preallocated table may steal colors from the image ...
[Instance variables:]
red <Integer> the red component (0..MaxValue)
green <Integer> the green component (0..MaxValue)
blue <Integer> the blue component (0..MaxValue)
device <Device> the device I am on, or nil
colorId <Object> some device dependent identifier (or nil if dithered)
ditherForm <Form> the Form to dither this color (if non-nil)
writable <Boolean> true if this is for a writable color cell
[Class variables:]
MaxValue <Integer> r/g/b components are scaled relative to this maximum
Lobby <Registry> all colors in use - keeps track of already allocated
colors for reuse and finalization.
(dont use it: this will be moved to the device)
Cells <Registry> keeps track of allocated writable color cells
(dont use it: this will be moved to the device)
FixColors <Array> preallocated colors for dithering on Display
NumRedFix <Integer> number of distinct red values in FixColors
NumGreenFix <Integer> number of distinct green values in FixColors
NumBlueFix <Integer> number of distinct blue values in FixColors
Black <Color> for fast return of black
White <Color> for fast return of white
Grey <Color> for fast return of grey
LightGrey <Color> for fast return of lightGrey
DarkGrey <Color> for fast return of darkGrey
Pseudo0 <Color> a color with 0 as handle (for forms and bitblit)
Pseudo1 <Color> a color with 1 as handle (for forms)
PseudoAll <Color> a color with allPlanes as handle (for bitblit)
Red <Color> red, needed for dithering
Green <Color> green, for dithering
Blue <Color> blue, for dithering
DitherColors <Collection> some preallocated colors for dithering
(kept, so they are available when needed)
RetryAllocation <Boolean> this flag controls how a request for a
color should be handled which failed previously.
I.e. a color is asked for, which was dithered
the last time. Since it could happen, that in
the meantime more colors became free, the request
might succeed this time - however, your screen may
look a bit funny, due to having both dithered and
undithered versions around.
The default is true, which means: do retry
compatibility issues:
ST-80 seems to represent colors internally with scaled smallInteger
components (this can be guessed from uses of
scaledRed:scaledGreen:scaledBlue:). The main instance creation method is
via 'ColorValue red:green:blue:', passing components in 0..1.
In ST/X, component are internally represented as percent.
For more compatibility (when subclassing color), these internals may
change in the near future. For migration, a compatibility subclass
called ColorValue is provided.
After the change, Color will be renamed to ColorValue and Color
be made a subclass of ColorValue (offering the 0..100 interface for
backward compatibility).
DeviceWorkstation
GraphicsContext
DeviceDrawable
Form
Image
Colormap
Font
Cursor
Compatibility-Squeak
-
colorPaletteForDepth: depth extent: chartExtent
-
Squeak mimicri:
Display a palette of colors sorted horizontally by hue and vertically by lightness. Useful for eyeballing the color gamut of the display, or for choosing a color interactively.
-
fromRgbTriplet: aTriple
-
-
h: hue s: saturation v: brightness
-
Squeak mimicri:
Create a color with the given hue, saturation, and brightness.
Hue is given as the angle in degrees of the color on the color circle,
where red is zero degrees.
Saturation and brightness are numbers in [0.0..1.0],
where larger values are more saturated or brighter colors.
For example, (Color h: 0 s: 1 v: 1) is pure red.
-
indexedColors
-
Build an array of colors corresponding to the fixed colormap used
for display depths of 1, 2, 4, or 8 bits.
-
paleBlue
-
-
pixelScreenForDepth: depth
-
Return a 50% stipple containing alternating pixels of all-zeros and all-ones to be used as a mask at the given depth.
-
r: redFraction g: greenFraction b: blueFraction
-
Squeak mimicri:
return a color from red, green and blue fractional values;
the arguments, r, g and b must be in (0..1)
-
r: r g: g b: b alpha: alphaValue
-
return a color from red, green and blue values;
the arguments, r, g, b and alpha must be in 0..1
-
r: r g: g b: b range: componentMax
-
return a color from red, green and blue values;
the arguments, r, g and b are interpreted as values (0..componentMax)
-
showColors: colorList
-
Display the given collection of colors across the top of the Display.
-
wheel: thisMany
-
Return a collection of thisMany colors evenly spaced around the color wheel.
-
wheel: thisMany saturation: s brightness: v
-
Return a collection of thisMany colors evenly spaced around the color wheel,
all of the given saturation and brightness.
Signal constants
-
colorAllocationFailSignal
-
return the signal raised when a color allocation failed.
-
colorErrorSignal
-
return the parent signal of all color error signals.
-
invalidColorNameSignal
-
return the signal raised when an invalid color name is encountered
accessing
-
allocatedColorsOn: aDevice
-
return a collection of colors which have already been allocated
on aDevice.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
allocatedColorsOnDevice: aDevice
-
return a collection of colors which have already been allocated
on aDevice.
color space conversions
-
withHLSFromRed: r green: g blue: b do: aBlock
-
compute hls form rgb, evaluate aBlock with h,l and s as arguments.
r,g,b in 0..100
h in 0..360; l in 0..100; s in 0..100
-
withHLSFromScaledRed: r scaledGreen: g scaledBlue: b do: aBlock
-
compute hls form rgb, evaluate aBlock with h,l and s as arguments
-
withRGBFromHue: h light: l saturation: s do: aBlock
-
compute rgb form hls, evaluate aBlock with r,g and b as arguments
r,g,b in 0..100
h in 0..360; l in 0..100; s in 0..100
constant colors
-
black
-
return the black color
-
blue
-
return the blue color
-
brown
-
-
cyan
-
return the cyan color - ST-80 compatibility
-
cyan: cyan
-
return a cyan color;
the argument cyan is interpreted as percent (0..100)
-
darkGray
-
return the dark grey color (English version ;-)
-
darkGrey
-
return the darkGrey color (US version ;-)
-
gray
-
return a medium grey color (US version ;-)
-
gray: gray
-
return a gray color (US version).
The argument, gray is interpreted as percent (0..100).
-
grayPercent: gray
-
return a gray color (US version).
The argument, gray is interpreted as percent (0..100).
-
green
-
return green
-
grey
-
return the grey color (English version ;-)
-
grey: grey
-
return a grey color (English version).
The argument, grey is interpreted as percent (0..100).
-
greyByte: greyByte
-
return a grey color (English version).
The argument, grey is interpreted as byte-value (0..255).
-
lightBlue
-
return a light blue color
-
lightBrown
-
-
lightGray
-
return the lightGrey color (US version ;-)
-
lightGreen
-
return a light green color
-
lightGrey
-
return the lightGrey color (English version ;-)
-
lightRed
-
return a light red color
-
lightYellow
-
-
magenta
-
return the magenta color - ST-80 compatibility
-
magenta: magenta
-
return a magenta color;
the argument magenta is interpreted as percent (0..100)
-
mediumGray
-
return medium-grey color (US version ;-)
-
mediumGrey
-
return medium-grey color (English version ;-)
-
orange
-
return the orange color - ST-80 compatibility
-
orange: orange
-
return a orange color;
the argument orange is interpreted as percent (0..100)
-
pink
-
return the pink color - ST-80 compatibility
-
red
-
return the red color
-
transparent
-
return the transparent-color
-
veryDarkGray
-
return a very dark-grey color (US version ;-)
-
veryDarkGrey
-
return a very dark-grey color (English version ;-)
-
veryLightGray
-
return a very light-grey color (US version ;-)
-
veryLightGrey
-
return a very light-grey color (English version ;-)
-
veryVeryLightGray
-
return a very very light-grey color (US version ;-)
-
white
-
return the white-color
-
yellow
-
return the yellow color - ST-80 compatibility
-
yellow: yellow
-
return a yellow color;
the argument yellow is interpreted as percent (0..100)
initialization
-
allocateColorsIn: aColorVector on: aDevice
-
preallocates a nR x nG x nB colorMap for later use in dithering.
Doing so has the advantage that the system will never run out of colors,
however, colors may be either inexact or dithered.
-
colorCubeWithRed: nRed green: nGreen blue: nBlue
-
-
flushDeviceColors
-
unassign all colors from their device
-
flushDeviceColorsFor: aDevice
-
-
getColors6x6x4
-
preallocates a 6x6x4 (144) colorMap and later uses those colors only.
Doing so has the advantage that the system will never run out of colors,
however, colors may be either inexact or dithered.
-
getColors6x6x5
-
preallocates a 6x6x5 (180) colorMap and later uses those colors only.
Doing so has the advantage that the system will never run out of colors,
however, colors may be either inexact or dithered.
-
getColors6x6x6
-
preallocates a 6x6x6 (196) colorMap and later uses those colors only.
Doing so has the advantage that the system will never run out of colors,
however, colors may be either inexact or dithered.
-
getColors6x7x4
-
preallocates a 6x7x4 (168) colorMap and later uses those colors only.
Doing so has the advantage that the system will never run out of colors,
however, colors may be either inexact or dithered.
-
getColors7x8x4
-
preallocates a 7x8x4 (224) colorMap and later uses those colors only.
Doing so has the advantage that the system will never run out of colors,
however, colors may be either inexact or dithered.
-
getColorsRed: nRed green: nGreen blue: nBlue
-
preallocates a nR x nG x nB colorMap for later use in dithering.
Doing so has the advantage that the system will never run out of colors,
however, colors may be either inexact or dithered.
-
getColorsRed: nRed green: nGreen blue: nBlue on: aDevice
-
preallocates a nR x nG x nB colorMap for later use in dithering.
Doing so has the advantage that the system will never run out of colors,
however, colors may be either inexact or dithered.
-
getGrayColors: nGray on: aDevice
-
preallocates nGray gray colors for later use in dithering.
Doing so has the advantage that the system will never run out of colors,
however, colors may be either inexact or dithered.
-
getPrimaryColorsOn: aDevice
-
preallocate the primary colors.
Doing so during early startup prevents us from running out
of (at least those required) colors later.
This guarantees, that at least some colors are available
for dithering (although, with only black, white, red, green and blue,
dithered images look very poor).
-
grayColorVector: nGray
-
-
initialize
-
setup tracker of known colors and initialize classvars with
heavily used colors
-
initializeStandardColorNames
-
setup standard colors
-
standardDitherColorsForDepth8
-
return a set of colors useful for dithering (roughly 200 colors);
This includes a color cube and the main grayScale colors.
-
update: something with: aParameter from: changedObject
-
handle image restarts and flush any device resource handles
-
vgaColors
-
instance creation
-
allColor
-
return a special color which, when used for bit-blitting will
behave like a all-1-color (i.e. have a device-pixel value of all-1s)
-
bgrValue: bgr
-
return a color from a 24bit BGR value (intentionally not RGB);
The value is composed of b<<16 + g<<8 + r.
(this byte-order is sometimes encountered with windows systems (progs)
-
blue: blue
-
return a color from blue value;
the argument green is interpreted as percent (0..100)
-
brightness: brightness
-
create a gray color with given brightness (0..1).
ST-80 compatibility.
-
colorId: id
-
return a color for a specific colorid without associating it to a
specific device. Use this only for bitmaps which want 0- or 1-color,
or for bitblits if you want to manipulate a specific colorplane.
-
cyan: c magenta: m yellow: y
-
return a color from cyan, magenta and yellow values.
all values are given in percent (0..100)
-
cyan: c magenta: m yellow: y black: k
-
return a color from cyan, magenta, yellow and black values.
all values are given in percent (0..100).
The value returned here is questionable.
TODO: we loose information about one component here,
and should actually return an instance of CMYK color, which keeps this
information internally for later use (when saving).
-
dither: fraction between: color1 and: color2 on: aDevice
-
create a dithered Color which dithers between color1 and color2.
Fraction must be 0..1, color1 and color2 must be real (i.e. undithered)
colors.
Useful, if you explicitely want a dithered color
(for example, to not use up too many colors, or for special effects)
-
dithered: fraction between: color1 and: color2 on: aDevice
-
create a dithered Color which dithers between color1 and color2.
Fraction must be 0..1, color1 and color2 must be real (i.e. undithered)
colors.
Useful, if you explicitely want a dithered color
(for example, to not use up too many colors, or for special effects)
-
fromUser
-
let user point on a screen pixel.
Return an instance for that pixels color
-
fromUserWithFeedBack: feedbackBlockOrNil
-
let user point on a screen pixel.
Return an instance for that pixels color
-
green: green
-
return a color from green value;
the argument green is interpreted as percent (0..100)
-
hue: h light: l saturation: s
-
return a color from hue, light and saturation values.
Hue is in degrees (0..360); light and sturation are
in percent (0..100)
-
name: colorName
-
Return a named color (either exact or dithered).
Report an error, if aString is not a valid color name.
We hereby only guarantee that the 8 basic colors are supported
on every device (X uses the Xcolor database, so it supports more
names - other devices use a builtIn name table containing only the
common names)
- use with special names (such as 'mediumGoldenRod' is not recommended).
Better use: #name:ifIllegal: and provide a fallBack.
-
name: colorName ifIllegal: errorBlock
-
Return a named color (either exact or dithered).
If aString is not a valid color name,
return the result from evaluating errorBlock.
-
noColor
-
return a special color which, when used for bit-blitting will
behave like a 0-color (i.e. have a device-pixel value of all-0s)
-
red: red
-
return a color from red value;
the argument r is interpreted as percent (0..100)
-
red: r green: g blue: b
-
return a color from red, green and blue values;
the arguments, r, g and b are interpreted as percent (0..100)
-
redByte: r greenByte: g blueByte: b
-
return a color from red, green and blue values;
the arguments, r, g and b are interpreted as byte values (0..255)
-
redByte: r greenByte: g blueByte: b alphaByte: a
-
return a color from red, green, blue and alpha values;
the arguments, r, g, b and a are interpreted as byte values (0..255)
-
redFraction: r greenFraction: g blueFraction: b
-
return a color from red, green and blue values;
the arguments, r, g and b are interpreted as fraction (0..1)
-
redPercent: r greenPercent: g bluePercent: b
-
return a color from red, green and blue values;
the arguments, r, g and b are interpreted as percent (0..100)
-
redPercent: r greenPercent: g bluePercent: b alphaPercent: a
-
return a color from red, green and blue values;
the arguments, r, g and b are interpreted as percent (0..100)
-
redShort: r greenShort: g blueShort: b
-
return a color from red, green and blue short values;
the arguments, r, g and b are interpreted as unsigned short values (0..16rFFFF)
-
rgbValue: rgb
-
return a color from a 24bit RGB value;
The value is composed of r<<16 + g<<8 + b.
-
scaledGray: aGrayValue
-
return a gray color with a scaled gray value (0..MaxValue)
-
scaledRed: r scaledGreen: g scaledBlue: b
-
return a color from red, green and blue values;
the arguments, r, g and b are interpreted as (0..MaxValue)
-
variableColorOn: aDevice
-
return a variable color (i.e. allocate a writable colorcell) on
aDevice. The returned color is not shared and its rgb components
are initially undefined. The components can be set to any value
using Color>>red:green:blue. Care should be taken, since this call
fails on static color or b&w displays (i.e. it depends on the device
being a pseudocolor device using colormaps).
Returns nil, if no more colorCells are available, or the display
uses a fix colormap (i.e. is a directColor or staticColor pr b&w device).
Because of this, you should not write your application to depend on
writable colors to be available (i.e. add fallBack code to redraw
things in another color)
obsolete
-
nameOrDither: colorName
-
return a named color - if the exact color is not available,
return a dithered color. Report an error, if the colorname is
illegal.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
nameOrDither: colorName ifIllegal: errorBlock
-
return a named color - if the exact color is not available,
return a dithered color. If the colorname is illegal, return
the value of evaluating errorBlock.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
nameOrNearest: colorName
-
return a named color - or its nearest match
** This is an obsolete interface - do not use it (it may vanish in future versions) **
private
-
colorNearRed: r green: g blue: b on: aDevice
-
return a device color on aDevice with rgb values
almost matching. If there is one, nil otherwise.
This is tried as a last chance before dithering.
The algorithm needs rework, the color components
should be weighted according some theory :-)
-
existingColorRed: r green: g blue: b on: aDevice
-
return a device color on aDevice with rgb values
if there is one, nil otherwise.
-
existingColorScaledRed: r scaledGreen: g scaledBlue: b on: aDevice
-
return a device color on aDevice with rgb values
if there is one, nil otherwise.
private-dithering
-
complexDitherRed: red green: green blue: blue on: aDevice into: aBlock
-
get a deep dither form for an rgb value.
Use all available colors for error dithering into a form.
-
ditherBits
-
return a dither pattern for x/64; x in 1..63
-
ditherGrayFor: fraction on: aDevice into: aBlock
-
get a dither form or colorId for a brightness value.
Fraction is 0..1.
Returns 2 values (either color or ditherForm) through aBlock.
-
ditherRed: rV green: gV blue: bV on: aDevice into: aBlock
-
get a dither form or colorId for an rgb value.
Returns 2 values (either color or ditherForm) through
aBlock.
This code is just a minimum of what is really needed,
and needs much more work. Currently only some special cases
are handled
-
fixDitherRed: redVal green: greenVal blue: blueVal on: aDevice into: aBlock
-
get a dither form for an rgb value.
Returns 2 values (either color or ditherForm) through aBlock.
This code uses the table of preallocated fix-colors to find
dither colors.
-
monoDitherFor: fraction between: color1 and: color2 on: aDevice into: aBlock
-
get a dither form or colorId for dithering between 2 colors.
Fraction is 0..1.
Returns 2 values (either color or ditherForm) through aBlock.
queries
-
constantNames
-
return names known as instance creation messages
-
scalingValue
-
ST-80 compatibility
special instance creation
-
nearestColorRed: r green: g blue: b on: aDevice in: colors
-
return the nearest color on aDevice with RGB values
same or near r/g/b in a collection of colors.
If there is one, return it; nil otherwise.
Near is defined as having an error less than the argument
error (in percent). The error is computed by the color
vector distance (which may not be the best possible solution).
-
nearestColorScaledRed: r scaledGreen: g scaledBlue: b inCube: aColorCube numRed: nRed numGreen: nGreen numBlue: nBlue
-
return a color with rgb values same or near r/g/b in a given
collection, containing colors from a colorCube.
This is used with preallocated fixColors and is quite fast
(no need to search)
-
nearestColorScaledRed: r scaledGreen: g scaledBlue: b on: aDevice
-
return a device color on aDevice with RGB values
same or near r/g/b, if there is one, nil otherwise.
Near is defined as having an error less than the argument
error (in percent). The error is computed by the color
vector distance (which may not be the best possible solution).
-
nearestColorScaledRed: r scaledGreen: g scaledBlue: b on: aDevice in: colors
-
return the nearest color on aDevice with RGB values
same or near r/g/b in a collection of colors.
If there is one, return it; nil otherwise.
-
quickNearestColorScaledRed: r scaledGreen: g scaledBlue: b on: aDevice
-
return a device color on aDevice with rgb values
same or near r/g/b.
This looks for primary colors only and is thus faster
than the general nearestColor search (slightly uglier though).
Compatibility-ST80
-
asDevicePaintOn: aDevice
-
ST-80 compatibility: an alias for on:.
create a new Color representing the same color as
myself on aDevice; if one already exists, return the one
-
asHiliteColor
-
same as lightened - for ST-80 compatibility
-
asShadowColor
-
same as darkened - for ST-80 compatibility
Compatibility-Squeak
-
alphaMixed: proportion with: aColor
-
Answer this color mixed with the given color. The proportion, a number
between 0.0 and 1.0, determines what what fraction of the receiver to
use in the mix. For example, 0.9 would yield a color close to the
receiver. This method uses RGB interpolation; HSV interpolation can lead
to surprises. Mixes the alphas (for transparency) also.
-
bitPatternForDepth: depth
-
Return a Bitmap, possibly containing a stipple pattern,
that best represents this color at the given depth.
BitBlt calls this method to convert colors into Bitmaps.
The resulting Bitmap may be multiple words to represent a stipple
pattern of several lines.
-
colorForInsets
-
-
darker
-
return a new color, which is darker than the receiver.
Almost the same as darkened for Squeak compatibility.
-
lighter
-
return a new color, which is slightly lighter than the receiver.
Almost the same as lightened for Squeak compatibility.
-
muchDarker
-
return a new color, which is much darker than the receiver.
Added for Squeak compatibility.
-
muchLighter
-
return a new color, which is much lighter than the receiver.
Added for Squeak compatibility.
-
newTileMorphRepresentative
-
-
privateBlue
-
Squeak compatibility:
return the blue components value mapped to 0..MaxValue
-
privateGreen
-
Squeak compatibility:
return the green components value mapped to 0..MaxValue
-
privateRed
-
Squeak compatibility:
return the red components value mapped to 0..MaxValue
-
scaledPixelValue32
-
-
veryMuchLighter
-
return a new color, which is very much lighter than the receiver.
Added for Squeak compatibility.
-
wheel: thisMany
-
An array of thisMany colors around the color wheel starting at self and ending all the way around the hue space just before self. Array is of length thisMany. Very useful for displaying color based on a variable in your program.
accessing
-
alpha
-
return the alpha value (0..1),
where 0 is completely transparent and 1 is completely opaque
-
alphaByte
-
return the alpha byte-value (0..255),
where 0 is completely transparent and 255 is completely opaque
-
blue
-
return the blue component in percent [0..100]
-
blueByte
-
return the blue components value mapped to 0..255
-
colorId
-
return the device-dependent color-id
-
cyan
-
return the cyan component in percent [0..100] in cmy color space
-
device
-
return the device I am associated to
-
deviceBlue
-
return the actual value of the blue component in percent.
-
deviceGreen
-
return the actual value of the green component in percent.
(usually 16bit in X; but could be different on other systems)
-
deviceRed
-
return the actual value of the red component in percent.
-
ditherForm
-
return the form to dither the color
-
graphicsDevice
-
same as #device, for ST-80 compatibility naming.
Return the device I am associated with.
-
green
-
return the green component in percent [0..100]
-
greenByte
-
return the green components value mapped to 0..255
-
hue
-
return the hue (in hue/light/saturation model) in degrees [0..360]
-
light
-
return the light (in hue/light/saturation model) in percent [0..100].
This corresponds to the brightness of the color (if displayed on
a b&w television screen)
-
magenta
-
return the magenta component in percent [0..100] in cmy color space
-
privateAlpha
-
return the internal alpha value (0..255),
where 0 is completely transparent and 255 is completely opaque
-
red
-
return the red component in percent [0..100]
-
red: r green: g blue: b
-
set r/g/b components in percent. This method will change the color lookup
table in pseudocolor devices.
This is only allowed for writable colors (i.e. those allocated with
Color>>variableColorOn: on pseudoColor displays).
Using this may make your code unportable, since it depends on a display
using palettes (i.e. it will not work on greyScale or b&w displays).
-
redByte
-
return the red components value mapped to 0..255;
nil if it has no red component.
-
rgbValue
-
return the rgb byteValues packed into a 24bit integer;
The returned value is composed of r<<16 + g<<8 + b.
-
saturation
-
return the saturation (in hue/light/saturation model) in percent [0..100].
This corresponds to the saturation setting of a color TV
-
scaledBlue
-
ST-80 compatibility:
return the blue components value mapped to 0..MaxValue
-
scaledGray
-
return the grey intensity scaled to 0..MaxValue
-
scaledGreen
-
ST-80 compatibility:
return the green components value mapped to 0..MaxValue
-
scaledRed
-
ST-80 compatibility:
return the red components value mapped to 0..MaxValue
-
scaledRed: r scaledGreen: g scaledBlue: b
-
set r/g/b components in 0..MaxValue.
This method will change the color lookup table in pseudocolor devices.
This is only allowed for writable colors (i.e. those allocated with
Color>>variableColorOn: on pseudoColor displays).
Using this may make your code unportable, since it depends on a display
using palettes (i.e. it will not work on greyScale or b&w displays).
-
writable
-
return true, if this is a writable colorcell
-
yellow
-
return the yellow component in percent [0..100] in cmy color space
binary storage
-
readBinaryContentsFrom: stream manager: manager
-
-
storeBinaryDefinitionBodyOn: stream manager: manager
-
comparing
-
= aColor
-
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.
-
hash
-
return an integer useful as hash key for the receiver.
Redefined since = is redefined
converting
-
fromLiteralArrayEncoding: encoding
-
read my values from an encoding.
The encoding is supposed to be either of the form:
(#Color redPart greenPart bluePart)
or:
(#Color constantColorSymbol)
This is the reverse operation to #literalArrayEncoding.
-
literalArrayEncoding
-
encode myself as an array, from which a copy of the receiver
can be reconstructed with #decodeAsLiteralArray.
The encoding is:
(#Color redPart greenPart bluePart)
copying
-
postCopy
-
redefined to clear out any device handles in the copy
-
postDeepCopy
-
redefined to clear out any device handles in the copy
-
skipInstvarIndexInDeepCopy: index
-
getting a device color
-
exactOn: aDevice
-
create a new Color representing the same color as
myself on aDevice; if one already exists, return the one.
Do not dither or otherwise approximate the color, but return
nil, if the exact color is not available.
Used to aquire primary colors for dithering, during startup.
-
exactOrNearestOn: aDevice
-
get a device color for the receiver, which is either exact
or the nearest, but never dithered.
This can be used for viewBackgrounds, where the exact greyLevel
does not matter, but a dithered color is not wanted.
-
nearestIn: aColorMap
-
return the nearest color in a colorMap
-
nearestOn: aDevice
-
create a new Color representing the same color as myself on aDevice;
if one already exists, return the one. If no exact match is found,
search for the nearest match
-
on: aDevice
-
create a new Color representing the same color as
myself on aDevice; if one already exists, return the one
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
onDevice: aDevice
-
create a new Color representing the same color as
myself on aDevice; if one already exists, return the one
inspecting
-
inspectorClass
-
return the class of an appropriate inspector.
ST/X has a specialized ColorInspectorView for that
-
inspectorExtraAttributes
-
extra (pseudo instvar) entries to be shown in an inspector.
instance creation
-
alpha: alphaValue
-
return a new color with the same color, but different alpha as the receiver.
The alpha arguments range is 0..1 (0=completely transparent; 1=completely opaque)
-
blendWith: aColor
-
create a new color from equally mixing the receiver
and the argument, aColor.
Mixing is done by adding components
(which is different from mixing colors on paper .. which is subtractive).
-
darkened
-
return a new color, which is slightly darker than the receiver
-
lightened
-
return a new color, which is slightly lighter than the receiver
-
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.
-
slightlyDarkened
-
return a new color, which is a bit darker than the receiver
-
slightlyLightened
-
return a new color, which is a bit lighter than the receiver
instance release
-
executor
-
redefined, since for finalization only device and colorIndex
are needed - thus a faster copy is possible here
-
releaseFromDevice
-
I am no longer available on the device
misc
-
magnifiedTo: extent
-
do nothing here, for compatibility with Image/Form
object persistency
-
elementDescriptorFor: aspect
-
support for persistency:
answer the elements to be made persistent with an ObjectCoder
printing & storing
-
hex
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
hexPrintString
-
return a hex-printString as rrggbb
-
htmlPrintString
-
return a hex-printString for html as #rrggbb;
-
printOn: aStream
-
append a string representing of the receiver
to the argument, aStream
-
storeOn: aStream
-
append a string representing an expression to reconstruct the receiver
to the argument, aStream
private
-
restored
-
private: color has been restored (either from snapin or binary store);
flush device stuff or reallocate a cell.
-
setColorId: anId
-
private: set the deviceId
-
setDevice: aDevice colorId: aNumber
-
private:set device and colorId
-
setDevice: aDevice colorId: aNumber writable: wBool
-
private:set device, colorId and writable flag
-
setDitherForm: aForm
-
private: set the ditherForm
-
setScaledRed: r scaledGreen: g scaledBlue: b device: aDevice
-
private: set the components
queries
-
averageColor
-
return the average color - thats myself.
This method has been added for compatibility with the image
protocol.
-
averageColorIn: aRectangle
-
return the average color - thats myself.
This method has been added for compatibility with the image
protocol.
-
brightness
-
ST80 compatibility: return the grey intensity in [0..1]
-
deltaFrom: aColor
-
return the distance of the receiver from some color specified
by r/g/b values
-
deltaFromRed: r green: g blue: b
-
return the distance of the receiver from some color specified
by r/g/b values
-
deltaFromScaledRed: r scaledGreen: g scaledBlue: b
-
return the distance of the receiver from some color specified
by r/g/b values
-
errorFrom: aColor
-
return some value which can be used to compare colors.
The following simply returns the vector distance of the r/g/b vectors.
This may not be a very good idea; probably, we should honor the
fact that the hue difference should have more weight than saturation and/or light
-
grayIntensity
-
return the grey intensity in percent [0..100] (US version ;-)
-
greyIntensity
-
return the grey intensity in percent [0..100] (English version ;-)
-
isColor
-
return true if the receiver is a Color.
-
isColorObject
-
-
isDithered
-
return true, if this is a dithered Color.
Only makes sense if the receiver is a device color.
-
isGray
-
same as isGrayColor - for ST80 compatibility.
-
isGrayColor
-
return true, if this color is a gray one (US version ;-) -
i.e. red = green = blue
-
isGreyColor
-
return true, if this color is a grey one (English version ;-) -
i.e. red = green = blue
-
isOnDevice: aGraphicsDevice
-
return true if i am allocated on aGraphicsDevice
-
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, but not transparent
-
isTransparent
-
return true, if I represent a completely transparent color
DeviceColorHandle
|