Color.st
author Claus Gittinger <cg@exept.de>
Tue, 08 Sep 2009 19:19:48 +0200
changeset 5337 dae799444a35
parent 5144 d93391e9ea8d
child 5419 7718ae7f7e6b
permissions -rw-r--r--
name:ifIllegal:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     1
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
     3
              All Rights Reserved
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     5
 This software is furnished under a license and may be used
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     6
 only in accordance with the terms of that license and with the
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     9
 other person.  No title to or ownership of the software is
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    10
 hereby transferred.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    11
"
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
    12
"{ Package: 'stx:libview' }"
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
    13
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    14
Object subclass:#Color
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    15
	instanceVariableNames:'red green blue device colorId ditherForm replacementColor
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    16
		writable'
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    17
	classVariableNames:'MaxValue Cells Black White LightGrey Grey DarkGrey Pseudo0
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    18
		Pseudo1 PseudoAll Red Green Blue RetryAllocation DitherBits
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    19
		ColorErrorSignal ColorAllocationFailSignal InvalidColorNameSignal
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    20
		StandardColorValues Transparent'
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    21
	poolDictionaries:''
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    22
	category:'Graphics-Support'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    23
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    24
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    25
Object subclass:#DeviceColorHandle
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    26
	instanceVariableNames:'device colorId'
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    27
	classVariableNames:''
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    28
	poolDictionaries:''
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    29
	privateIn:Color
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    30
!
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    31
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    32
!Color class methodsFor:'documentation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    33
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    34
copyright
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    35
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    36
 COPYRIGHT (c) 1992 by Claus Gittinger
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
    37
              All Rights Reserved
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    38
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    39
 This software is furnished under a license and may be used
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    40
 only in accordance with the terms of that license and with the
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    41
 inclusion of the above copyright notice.   This software may not
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    42
 be provided or otherwise made available to, or used by, any
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    43
 other person.  No title to or ownership of the software is
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    44
 hereby transferred.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    45
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    46
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    47
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    48
documentation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    49
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    50
    Color represents colors in a device independent manner, main info I keep about
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    51
    mySelf are the red, green and blue components scaled into 0 .. MaxValue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    52
    The device specific color can be aquired by sending a color the 'on:aDevice' message,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    53
    which will return a color with the same rgb values as the receiver but specific
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    54
    for that device.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    55
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    56
    Colors can be pure or dithered, depending on the capabilities of the device. 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    57
    For plain colors, the colorId-instvar is a handle (usually lookup-table entry) for that
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    58
    device. For dithered colors, the colorId is nil and ditherForm specifies the form
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    59
    used to dither that color. The ditherForm can be either a depth-1 bitmap or a pixmap
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    60
    with the devices depth. The plain colors needed by the ditherForm are found in its
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    61
    colormap (as usual for bitmaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    62
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    63
    The default algorithm for color allocation is to ask the display for colors as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    64
    new colors are created. When running out of colors, dithered colors will be used,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    65
    using existing nearest colors and a dither pattern to aproximate the color.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    66
    There could be situations, where no good colors are available for the dither, leading
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    67
    to ugly looking dither colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    68
    This can be avoided by preallocating a set of colors over the complete range, which
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    69
    makes certain that appropriate colors are later available for the dither process.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    70
    To do so, add a statement like: 'Color getColors5x5x5' to the startup.rc file.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    71
    (beside 5x5x5, there are various other size combinations available).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    72
    However, doing so may make things worse when displaying bitmap images, since this
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    73
    preallocated table may steal colors from the image ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    74
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    75
    [Instance variables:]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    76
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    77
      red             <Integer>       the red component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    78
      green           <Integer>       the green component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    79
      blue            <Integer>       the blue component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    80
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    81
      device          <Device>        the device I am on, or nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    82
      colorId         <Object>        some device dependent identifier (or nil if dithered)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    83
      ditherForm      <Form>          the Form to dither this color (if non-nil)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    84
      writable        <Boolean>       true if this is for a writable color cell
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    85
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    86
    [Class variables:]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    87
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    88
      MaxValue        <Integer>       r/g/b components are scaled relative to this maximum
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    89
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    90
      Lobby           <Registry>      all colors in use - keeps track of already allocated
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    91
                                      colors for reuse and finalization.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    92
                                      (dont use it: this will be moved to the device)
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    93
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    94
      Cells           <Registry>      keeps track of allocated writable color cells
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    95
                                      (dont use it: this will be moved to the device)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    96
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    97
      FixColors       <Array>         preallocated colors for dithering on Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    98
      NumRedFix       <Integer>       number of distinct red values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    99
      NumGreenFix     <Integer>       number of distinct green values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   100
      NumBlueFix      <Integer>       number of distinct blue values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   101
    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   102
      Black           <Color>         for fast return of black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   103
      White           <Color>         for fast return of white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   104
      Grey            <Color>         for fast return of grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   105
      LightGrey       <Color>         for fast return of lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   106
      DarkGrey        <Color>         for fast return of darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   107
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   108
      Pseudo0         <Color>         a color with 0 as handle (for forms and bitblit)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   109
      Pseudo1         <Color>         a color with 1 as handle (for forms)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   110
      PseudoAll       <Color>         a color with allPlanes as handle (for bitblit)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   111
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   112
      Red             <Color>         red, needed for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   113
      Green           <Color>         green, for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   114
      Blue            <Color>         blue, for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   115
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   116
      DitherColors    <Collection>    some preallocated colors for dithering
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   117
                                      (kept, so they are available when needed)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   118
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   119
      RetryAllocation <Boolean>       this flag controls how a request for a
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   120
                                      color should be handled which failed previously.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   121
                                      I.e. a color is asked for, which was dithered
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   122
                                      the last time. Since it could happen, that in
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   123
                                      the meantime more colors became free, the request
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   124
                                      might succeed this time - however, your screen may
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   125
                                      look a bit funny, due to having both dithered and
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   126
                                      undithered versions around.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   127
                                      The default is true, which means: do retry
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   128
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   129
    compatibility issues:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   130
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   131
        ST-80 seems to represent colors internally with scaled smallInteger
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   132
        components (this can be guessed from uses of
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   133
        scaledRed:scaledGreen:scaledBlue:). The main instance creation method is
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   134
        via 'ColorValue red:green:blue:', passing components in 0..1.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   135
        In ST/X, component are internally represented as percent.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   136
        For more compatibility (when subclassing color), these internals may
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   137
        change in the near future. For migration, a compatibility subclass
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   138
        called ColorValue is provided. 
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   139
        After the change, Color will be renamed to ColorValue and Color
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   140
        be made a subclass of ColorValue (offering the 0..100 interface for
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   141
        backward compatibility).
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   142
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   143
    [see also:]
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   144
        DeviceWorkstation 
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   145
        GraphicsContext DeviceDrawable Form Image Colormap
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   146
        Font Cursor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   147
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   148
    [author:]
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   149
        Claus Gittinger
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   150
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   151
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   152
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   153
!Color class methodsFor:'initialization'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   154
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   155
allocateColorsIn:aColorVector on:aDevice
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   156
    "{ Pragma: +optSpace }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   157
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   158
    "preallocates a nR x nG x nB colorMap for later use in dithering.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   159
     Doing so has the advantage that the system will never run out of colors,
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   160
     however, colors may be either inexact or dithered."
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   161
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   162
    |clr round
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   163
     devClr|
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   164
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   165
    round := 0.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   166
    1 to:aColorVector size do:[:dstIndex |
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   167
        clr := aColorVector at:dstIndex.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   168
        devClr := clr exactOn:aDevice.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   169
        devClr isNil ifTrue:[
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   170
            round == 0 ifTrue:[
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   171
                'Color [info]: scavenge to reclaim colors' infoPrintCR.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   172
                ObjectMemory scavenge.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   173
                round := 1.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   174
                devClr := clr exactOn:aDevice.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   175
            ].
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   176
        ].
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   177
        devClr isNil ifTrue:[
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   178
            round == 1 ifTrue:[
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   179
                'Color [info]: collect garbage to reclaim colors' infoPrintCR.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   180
                ObjectMemory performLowSpaceCleanup.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   181
                ObjectMemory garbageCollect.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   182
                round := 2.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   183
                devClr := clr exactOn:aDevice.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   184
           ].
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   185
        ].
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   186
        devClr isNil ifTrue:[
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   187
            ColorAllocationFailSignal raiseErrorString:'failed to allocate fix color'.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   188
            ^ self
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   189
        ].
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   190
        aColorVector at:dstIndex put:devClr.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   191
    ].
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   192
!
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   193
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   194
colorCubeWithRed:nRed green:nGreen blue:nBlue
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   195
    "{ Pragma: +optSpace }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   196
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   197
    |nR "{Class: SmallInteger }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   198
     nG "{Class: SmallInteger }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   199
     nB "{Class: SmallInteger }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   200
     dR dG dB red green blue dstIndex clr round
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   201
     colorCube|
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   202
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   203
    nR := nRed.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   204
    nG := nGreen.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   205
    nB := nBlue.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   206
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   207
    dR := 100.0 / (nR - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   208
    dG := 100.0 / (nG - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   209
    dB := 100.0 / (nB - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   210
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   211
    colorCube := Array new:(nR * nG * nB).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   212
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   213
    round := 0.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   214
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   215
    dstIndex := 1.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   216
    1 to:nR do:[:sR |
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   217
        red := dR * (sR - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   218
        1 to:nG do:[:sG |
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   219
            green := dG * (sG - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   220
            1 to:nB do:[:sB |
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   221
                blue := dB * (sB - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   222
                clr := self red:red green:green blue:blue.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   223
                colorCube at:dstIndex put:clr.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   224
                dstIndex := dstIndex + 1
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   225
            ]
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   226
        ]
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   227
    ].
3904
52925c65a8cc colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3903
diff changeset
   228
    ^ colorCube
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   229
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   230
    "Created: 11.7.1996 / 17:55:32 / cg"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   231
    "Modified: 10.1.1997 / 15:37:13 / cg"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   232
!
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   233
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   234
flushDeviceColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   235
    "unassign all colors from their device"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   236
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   237
    self allInstances do:[:aColor |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   238
        aColor restored
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   239
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   240
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   241
    "Modified: 24.2.1997 / 18:27:06 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   242
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   243
3240
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   244
flushDeviceColorsFor:aDevice
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   245
    self allInstancesDo:[:aColor |
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   246
        aColor device == aDevice ifTrue:[
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   247
            aColor restored
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   248
        ]
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   249
    ]
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   250
!
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   251
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   252
getColors6x6x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   253
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   254
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   255
    "preallocates a 6x6x4 (144) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   256
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   257
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   258
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   259
    self getColorsRed:6 green:6 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   260
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   261
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   262
     Color getColors6x6x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   263
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   264
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   265
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   266
getColors6x6x5
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   267
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   268
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   269
    "preallocates a 6x6x5 (180) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   270
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   271
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   272
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   273
    self getColorsRed:6 green:6 blue:5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   274
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   275
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   276
     Color getColors6x6x5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   277
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   278
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   279
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   280
getColors6x6x6
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   281
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   282
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   283
    "preallocates a 6x6x6 (196) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   284
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   285
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   286
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   287
    self getColorsRed:6 green:6 blue:6
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   288
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   289
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   290
     Color getColors6x6x6
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   291
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   292
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   293
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   294
getColors6x7x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   295
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   296
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   297
    "preallocates a 6x7x4 (168) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   298
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   299
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   300
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   301
    self getColorsRed:6 green:7 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   302
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   303
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   304
     Color getColors6x7x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   305
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   306
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   307
    "Created: 12.6.1996 / 17:41:57 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   308
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   309
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   310
getColors7x8x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   311
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   312
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   313
    "preallocates a 7x8x4 (224) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   314
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   315
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   316
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   317
    self getColorsRed:7 green:8 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   318
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   319
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   320
     Color getColors7x8x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   321
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   322
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   323
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   324
getColorsRed:nRed green:nGreen blue:nBlue
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   325
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   326
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   327
    "preallocates a nR x nG x nB colorMap for later use in dithering.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   328
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   329
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   330
2999
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   331
    self getColorsRed:nRed green:nGreen blue:nBlue on:Screen current
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   332
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   333
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   334
     Color getColorsRed:2 green:2 blue:2
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   335
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   336
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   337
    "Modified: 11.7.1996 / 17:58:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   338
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   339
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   340
getColorsRed:nRed green:nGreen blue:nBlue on:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   341
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   342
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   343
    "preallocates a nR x nG x nB colorMap for later use in dithering.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   344
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   345
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   346
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   347
    |nR "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   348
     nG "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   349
     nB "{Class: SmallInteger }"
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   350
     dR dG dB fixColors|
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   351
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   352
    aDevice visualType == #TrueColor ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   353
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   354
    nR := nRed.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   355
    nG := nGreen.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   356
    nB := nBlue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   357
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   358
    dR := 100.0 / (nR - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   359
    dG := 100.0 / (nG - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   360
    dB := 100.0 / (nB - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   361
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   362
    fixColors := self colorCubeWithRed:nRed green:nGreen blue:nBlue.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   363
    self allocateColorsIn:fixColors on:aDevice.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   364
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   365
    aDevice setFixColors:fixColors numRed:nR numGreen:nG numBlue:nB
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   366
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   367
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   368
     Color getColorsRed:2 green:2 blue:2 on:Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   369
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   370
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   371
    "Created: 11.7.1996 / 17:55:32 / cg"
1165
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   372
    "Modified: 10.1.1997 / 15:37:13 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   373
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   374
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   375
getGrayColors:nGray on:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   376
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   377
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   378
    "preallocates nGray gray colors for later use in dithering.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   379
     Doing so has the advantage that the system will never run out of colors,
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   380
     however, colors may be either inexact or dithered."
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   381
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   382
    |nG "{Class: SmallInteger }"
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   383
     d fixGrayColors|
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   384
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   385
    aDevice visualType == #TrueColor ifTrue:[^ self].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   386
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   387
    nG := nGray.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   388
    d := 100.0 / (nG - 1).
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   389
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   390
    fixGrayColors := self grayColorVector:nGray.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   391
    self allocateColorsIn:fixGrayColors on:aDevice.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   392
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   393
    aDevice setFixGrayColors:fixGrayColors
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   394
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   395
    "
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   396
     Color getGrayColors:16 on:Display
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   397
    "
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   398
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   399
    "Created: 23.6.1997 / 15:29:50 / cg"
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   400
!
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   401
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   402
getPrimaryColorsOn:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   403
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   404
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   405
    "preallocate the primary colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   406
     Doing so during early startup prevents us from running out
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   407
     of (at least those required) colors later.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   408
     This guarantees, that at least some colors are available
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   409
     for dithering (although, with only black, white, red, green and blue,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   410
     dithered images look very poor)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   411
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   412
    |colors white black red green blue clr dDepth
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   413
     lastPix "{ Class: SmallInteger }" |
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   414
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   415
    (aDevice notNil and:[aDevice ditherColors isNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   416
        white := (self red:100 green:100 blue:100) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   417
        white colorId isNil ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   418
            'Color [warning]: cannot allocate white color' errorPrintCR.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   419
        ].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   420
        black := (self red:0 green:0 blue:0) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   421
        black colorId isNil ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   422
            'Color [warning]: cannot allocate black color' errorPrintCR.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   423
        ].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   424
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   425
        aDevice hasColors ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   426
            red := (self red:100 green:0 blue:0) exactOn:aDevice.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   427
            green := (self red:0 green:100 blue:0) exactOn:aDevice.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   428
            blue := (self red:0 green:0 blue:100) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   429
            (red isNil 
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   430
            or:[green isNil 
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   431
            or:[blue isNil 
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   432
            or:[red colorId isNil
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   433
            or:[green colorId isNil
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   434
            or:[blue colorId isNil]]]]]) ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   435
                'Color [warning]: cannot allocate primary color(s)' errorPrintCR.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   436
                dDepth := aDevice depth.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   437
                ((dDepth >= 4) and:[dDepth <= 8]) ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   438
                    "/
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   439
                    "/ see what we have ...
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   440
                    "/
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   441
                    lastPix := (1 bitShift:dDepth) - 1.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   442
                    0 to:lastPix do:[:pixel |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   443
                        colors := OrderedCollection new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   444
                        aDevice getRGBFrom:pixel into:[:r :g :b |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   445
                            colors add:((Color red:r green:g blue:b) exactOn:aDevice).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   446
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   447
                    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   448
                    red := (self red:100 green:0 blue:0) nearestOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   449
                    green := (self red:0 green:100 blue:0) nearestOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   450
                    blue := (self red:0 green:0 blue:100) nearestOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   451
                ] ifFalse:[
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   452
                    aDevice hasColors:false.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   453
                    aDevice hasGrayscales:false.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   454
                    red := green := blue := nil.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   455
                ]
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   456
            ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   457
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   458
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   459
        aDevice == Display ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   460
            "/ keep those around for the main display
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   461
            White := white.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   462
            Black := black.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   463
            Red := red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   464
            Green := green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   465
            Blue := blue
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   466
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   467
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   468
        aDevice visualType ~~ #TrueColor ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   469
            aDevice hasColors ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   470
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   471
                "preallocate some colors for dithering 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   472
                 - otherwise, they may not be available when we need them ...
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   473
                 these are: black, white, grey50,
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   474
                            red, green, blue, yellow, cyan and magenta.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   475
                "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   476
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   477
                colors := OrderedCollection new.
1619
4a7dbd25c588 handle the case where not even r/g/b primaries can be allocated
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   478
                clr := (self gray:50) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   479
                (clr notNil and:[clr colorId notNil]) ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   480
                    colors add:clr
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   481
                ].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   482
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   483
                colors add:white; add:black; add:red; add:green; add:blue.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   484
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   485
                colors add:((self red:100 green:100 blue:0) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   486
                colors add:((self red:100 green:0 blue:100) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   487
                colors add:((self red:0 green:100 blue:100) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   488
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   489
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   490
            aDevice hasGrayscales ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   491
                aDevice hasColors ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   492
                    colors := OrderedCollection new.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   493
                    colors add:((self gray:50) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   494
                    colors add:white; add:black.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   495
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   496
                ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   497
                colors add:((self gray:25) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   498
                colors add:((self gray:33) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   499
                colors add:((self gray:67) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   500
                colors add:((self gray:75) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   501
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   502
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   503
            colors notNil ifTrue:[  
1619
4a7dbd25c588 handle the case where not even r/g/b primaries can be allocated
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   504
                colors := colors select:[:clr | clr notNil and:[clr colorId notNil]].
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   505
                aDevice setDitherColors:(colors asArray).
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   506
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   507
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   508
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   509
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   510
    "Created: 11.7.1996 / 18:09:28 / cg"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   511
    "Modified: 21.10.1997 / 02:42:28 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   512
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   513
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   514
grayColorVector:nGray
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   515
    |nG "{Class: SmallInteger }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   516
     d gray dstIndex clr round
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   517
     grayColors|
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   518
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   519
    nG := nGray.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   520
    d := 100.0 / (nG - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   521
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   522
    grayColors := Array new:nG.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   523
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   524
    round := 0.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   525
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   526
    dstIndex := 1.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   527
    1 to:nG do:[:sG |
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   528
        gray := d * (sG - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   529
        clr := self red:gray green:gray blue:gray.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   530
        grayColors at:dstIndex put:clr.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   531
        dstIndex := dstIndex + 1
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   532
    ].
3904
52925c65a8cc colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3903
diff changeset
   533
    ^ grayColors
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   534
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   535
    "
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   536
     Color getGrayColors:16 on:Display
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   537
    "
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   538
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   539
    "Created: 23.6.1997 / 15:29:50 / cg"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   540
!
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   541
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   542
initialize
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   543
    "setup tracker of known colors and initialize classvars with
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   544
     heavily used colors"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   545
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   546
    ColorErrorSignal isNil ifTrue:[
3816
dbd03479da4e Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 3757
diff changeset
   547
        ColorErrorSignal := Error newSignalMayProceed:true.
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   548
        ColorErrorSignal nameClass:self message:#colorErrorSignal.
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   549
        ColorErrorSignal notifierString:'color error'.
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   550
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   551
        ColorAllocationFailSignal := ColorErrorSignal newSignalMayProceed:true.
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   552
        ColorAllocationFailSignal nameClass:self message:#colorAllocationFailSignal.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   553
        ColorAllocationFailSignal notifierString:'color allocation failed'.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   554
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   555
        InvalidColorNameSignal := ColorErrorSignal newSignalMayProceed:true.
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   556
        InvalidColorNameSignal nameClass:self message:#invalidColorNameSignal.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   557
        InvalidColorNameSignal notifierString:'invalid color name'.
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   558
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   559
        MaxValue := 16rFFFF.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   560
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   561
        "want to be informed when returning from snapshot"
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   562
        ObjectMemory addDependent:self.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   563
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   564
        RetryAllocation := true.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   565
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   566
        DitherBits := self ditherBits.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   567
        self initializeStandardColorNames.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   568
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   569
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   570
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   571
     Color initialize
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   572
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   573
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   574
    "Modified: / 30.9.1998 / 21:56:50 / cg"
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   575
!
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   576
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   577
initializeStandardColorNames
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   578
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   579
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   580
    "setup standard colors"
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   581
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   582
    StandardColorValues := Dictionary new.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   583
    #(
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   584
                'red'     (16rFFFF 16r0000 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   585
                'green'   (16r0000 16rFFFF 16r0000)
4170
c78076310ce8 blue color was initialized wrong
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
   586
                'blue'    (16r0000 16r0000 16rFFFF)
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   587
                'yellow'  (16rFFFF 16rFFFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   588
                'magenta' (16rFFFF 16r0000 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   589
                'cyan'    (16r0000 16rFFFF 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   590
                'white'   (16rFFFF 16rFFFF 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   591
                'black'   (16r0000 16r0000 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   592
                'olive'   (16r7FFF 16r7FFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   593
                'teal'    (16r0000 16r7FFF 16r7FFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   594
                'silver'  (16r6666 16r6666 16r6666)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   595
                'lime'    (16r3333 16rFFFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   596
                'fuchsia' (16r9999 16r07ae 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   597
                'aqua'    (16r199a 16rFFFF 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   598
    ) pairWiseDo:[:name :value |
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   599
        StandardColorValues at:name put:value
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   600
    ].
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   601
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   602
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   603
     Color initializeStandardColorNames
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   604
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   605
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   606
    "Modified: 6.3.1997 / 02:28:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   607
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   608
3930
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   609
standardDitherColorsForDepth8
3931
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   610
    "return a set of colors useful for dithering (roughly 200 colors);
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   611
     This includes a color cube and the main grayScale colors."
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   612
3930
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   613
    |ditherColors|
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   614
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   615
    ditherColors := self colorCubeWithRed:6 green:8 blue:4.
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   616
    ditherColors := ditherColors ,
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   617
                    (Array 
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   618
                        with:(Color gray:20)
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   619
                        with:(Color gray:25)
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   620
                        with:(Color gray:40)
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   621
                        with:(Color gray:50)
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   622
                        with:(Color gray:60)
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   623
                        with:(Color gray:75)
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   624
                        with:(Color gray:80)
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   625
                        with:(Color rgbValue:16rBFBFBF)).
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   626
    ^ ditherColors
3931
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   627
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   628
    "
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   629
     self standardDitherColorsForDepth8
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   630
    "
3930
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   631
!
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   632
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   633
update:something with:aParameter from:changedObject
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   634
    "handle image restarts and flush any device resource handles"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   635
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   636
    (something == #returnFromSnapshot) ifTrue:[
3727
3cbc55b7db41 slightly changed
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   637
        Display notNil ifTrue:[
2999
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   638
            Display visualType == #TrueColor ifTrue:[
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   639
                Display releaseFixColors
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   640
            ] ifFalse:[
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   641
                Display fixColors notNil ifTrue:[
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   642
                    ColorAllocationFailSignal handle:[:ex |
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   643
                        ex return
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   644
                    ] do:[
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   645
                        |nR nG nB|
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   646
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   647
                        nR := Display numFixRed.
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   648
                        nG := Display numFixGreen.
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   649
                        nB := Display numFixBlue.
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   650
                        Display releaseFixColors.
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   651
                        self getColorsRed:nR
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   652
                                    green:nG
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   653
                                     blue:nB
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   654
                                       on:Display
3727
3cbc55b7db41 slightly changed
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   655
                    ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   656
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   657
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   658
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   659
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   660
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   661
    "Created: 15.6.1996 / 15:14:03 / cg"
1370
37dfdffdd4b6 getPrimaryColors now invoked from device
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   662
    "Modified: 24.2.1997 / 22:08:05 / cg"
4535
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   663
!
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   664
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   665
vgaColors
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   666
    "{ Pragma: +optSpace }"
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   667
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   668
    |colors|
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   669
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   670
    colors := Array new:16.
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   671
    colors at:1 put:(Color rgbValue:16rFFFFFF).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   672
    colors at:2 put:(Color rgbValue:16rC0C0C0).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   673
    colors at:3 put:(Color rgbValue:16r808080).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   674
    colors at:4 put:(Color rgbValue:16r000000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   675
    colors at:5 put:(Color rgbValue:16rFF0000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   676
    colors at:6 put:(Color rgbValue:16r800000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   677
    colors at:7 put:(Color rgbValue:16r008000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   678
    colors at:8 put:(Color rgbValue:16r00FF00).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   679
    colors at:9 put:(Color rgbValue:16r0000FF).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   680
    colors at:10 put:(Color rgbValue:16r000080).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   681
    colors at:11 put:(Color rgbValue:16rFF00FF).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   682
    colors at:12 put:(Color rgbValue:16r800080).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   683
    colors at:13 put:(Color rgbValue:16rFFFF00).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   684
    colors at:14 put:(Color rgbValue:16r808000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   685
    colors at:15 put:(Color rgbValue:16r00FFFF).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   686
    colors at:16 put:(Color rgbValue:16r008080).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   687
    ^ colors
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   688
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   689
    "Created: / 07-07-2006 / 13:36:15 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   690
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   691
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   692
!Color class methodsFor:'instance creation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   693
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   694
allColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   695
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   696
     behave like a all-1-color (i.e. have a device-pixel value of all-1s)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   697
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   698
    PseudoAll isNil ifTrue:[
2288
4241c24b7e2a no manfred, pseudoAll is always all - also on windows.
Claus Gittinger <cg@exept.de>
parents: 2198
diff changeset
   699
        PseudoAll := self basicNew setColorId:-1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   700
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   701
    ^ PseudoAll
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   702
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   703
    "Modified: 17.1.1997 / 00:05:36 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   704
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   705
2455
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   706
bgrValue:bgr
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   707
    "return a color from a 24bit BGR value (intentionally not RGB);
2455
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   708
     The value is composed of b<<16 + g<<8 + r.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   709
     (this byte-order is sometimes encountered with windows systems (progs)"
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   710
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   711
    |r g b|
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   712
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   713
    b := (bgr bitShift:-16) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   714
    g := (bgr bitShift:-8) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   715
    r := (bgr) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   716
    ^ self redByte:r greenByte:g blueByte:b
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   717
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   718
!
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   719
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   720
blue: blue
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   721
    "return a color from blue value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   722
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   723
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   724
    ^ here 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   725
        scaledRed:0 scaledGreen:0 scaledBlue:(blue * MaxValue // 100)
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   726
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   727
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   728
     (Color blue:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   729
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   730
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   731
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   732
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   733
brightness:brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   734
    "create a gray color with given brightness (0..1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   735
     ST-80 compatibility."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   736
3264
ab71c2bd250f fixed #brightness:
Claus Gittinger <cg@exept.de>
parents: 3240
diff changeset
   737
    ^ self scaledGray:(brightness * MaxValue) rounded
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   738
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   739
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   740
colorId:id
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   741
    "return a color for a specific colorid without associating it to a
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   742
     specific device. Use this only for bitmaps which want 0- or 1-color,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   743
     or for bitblits if you want to manipulate a specific colorplane."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   744
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   745
    id == 0 ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   746
        ^ self noColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   747
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   748
    id == 1 ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   749
        Pseudo1 isNil ifTrue:[
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   750
            Pseudo1 := self basicNew setColorId:1
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   751
        ].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   752
        ^ Pseudo1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   753
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   754
    id == -1 ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   755
        ^ self allColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   756
    ].
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   757
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   758
    ^ self basicNew setColorId:id
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   759
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   760
    "Modified: 24.2.1997 / 18:16:30 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   761
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   762
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   763
cyan:c magenta:m yellow:y
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   764
    "return a color from cyan, magenta and yellow values.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   765
     all values are given in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   766
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   767
    ^ self
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   768
        redPercent:(100 - c)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   769
        greenPercent:(100 - m)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   770
        bluePercent:(100 - y)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   771
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   772
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   773
     Color cyan:100 magenta:0 yellow:0      - cyan    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   774
     Color cyan:100 magenta:100 yellow:0    - blue    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   775
     Color cyan:100 magenta:0 yellow:100    - green    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   776
     Color cyan:100 magenta:100 yellow:100  - black  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   777
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   778
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   779
    "Modified: 11.6.1996 / 18:29:15 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   780
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   781
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   782
cyan:c magenta:m yellow:y black:k
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   783
    "return a color from cyan, magenta, yellow and black values.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   784
     all values are given in percent (0..100).
2889
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   785
     The value returned here is questionable.
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   786
     TODO: we loose information about one component here,
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   787
     and should actually return an instance of CMYK color, which keeps this
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   788
     information internally for later use (when saving)."
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   789
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   790
    |scale r g b|
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   791
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   792
    "/ mhmh - how should we scale black into the components ?
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   793
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   794
    r := (100 - c).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   795
    g := (100 - m).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   796
    b := (100 - y).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   797
    k ~~ 0 ifTrue:[
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   798
        "/ more black - darker
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   799
        scale := (100-k) max:0.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   800
        scale := scale / 100.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   801
        r := r * scale.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   802
        g := g * scale.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   803
        b := b * scale.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   804
    ].
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   805
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   806
    ^ self redPercent:r greenPercent:g bluePercent:b
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   807
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   808
    "
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   809
     Color cyan:100 magenta:0 yellow:0 black:0      - cyan    
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   810
     Color cyan:100 magenta:0 yellow:0 black:50     - cyan darkened   
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   811
     Color cyan:100 magenta:50 yellow:50 black:0    - cyan darkened   
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   812
     Color cyan:0 magenta:0 yellow:0 black:100      - black  
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   813
    "
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   814
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   815
    "Modified: 11.6.1996 / 18:29:15 / cg"
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   816
!
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   817
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   818
dither:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   819
    "create a dithered Color which dithers between color1 and color2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   820
     Fraction must be 0..1, color1 and color2 must be real (i.e. undithered)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   821
     colors.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   822
     Useful, if you explicitely want a dithered color 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   823
     (for example, to not use up too many colors, or for special effects)"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   824
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   825
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   826
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   827
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   828
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   829
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   830
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   831
    (c1 isNil or:[c2 isNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   832
        'Color [warning]: monoDither failed - no real colors given' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   833
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   834
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   835
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   836
    self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   837
        monoDitherFor:fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   838
        between:c1 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   839
        and:c2
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   840
        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   841
        into:[:c :f | newColor := c. form := f].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   842
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   843
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   844
    form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   845
        "/ cannot happen
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   846
        'Color [warning]: monoDither failed' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   847
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   848
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   849
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   850
    newColor := self basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   851
                        setScaledRed:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   852
                        scaledGreen:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   853
                        scaledBlue:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   854
                        device:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   855
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   856
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   857
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   858
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   859
    "
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   860
     (Color dither:0.25 between:Color red and:Color yellow on:Display) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   861
     (Color dither:0.5 between:Color red and:Color yellow on:Display) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   862
     (Color dither:0.75 between:Color red and:Color yellow on:Display) inspect
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   863
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   864
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   865
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   866
    "Modified: 3.5.1997 / 11:10:51 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   867
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   868
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   869
dithered:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   870
    "create a dithered Color which dithers between color1 and color2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   871
     Fraction must be 0..1, color1 and color2 must be real (i.e. undithered)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   872
     colors.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   873
     Useful, if you explicitely want a dithered color 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   874
     (for example, to not use up too many colors, or for special effects)"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   875
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   876
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   877
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   878
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   879
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   880
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   881
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   882
    (c1 isNil or:[c2 isNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   883
        'Color [warning]: monoDither failed - no real colors given' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   884
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   885
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   886
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   887
    self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   888
        monoDitherFor:fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   889
        between:c1 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   890
        and:c2
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   891
        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   892
        into:[:c :f | newColor := c. form := f].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   893
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   894
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   895
    form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   896
        "/ cannot happen
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   897
        'Color [warning]: monoDither failed' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   898
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   899
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   900
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   901
    newColor := self basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   902
                        setScaledRed:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   903
                        scaledGreen:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   904
                        scaledBlue:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   905
                        device:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   906
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   907
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   908
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   909
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   910
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   911
     |c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   912
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   913
     c := Color dithered:0.5 between:Color red and:Color yellow on:Display.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   914
     c inspect.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   915
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   916
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   917
     |v c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   918
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   919
     v := StandardSystemView new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   920
     v extent:100@100.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   921
     v openAndWait.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   922
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   923
     c := Color dithered:0.5 between:Color red and:Color yellow on:Display.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   924
     v paint:c.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   925
     v fillRectangle:(10@10 corner:90@90).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   926
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   927
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   928
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   929
    "Modified: 3.5.1997 / 11:13:12 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   930
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   931
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   932
fromUser
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   933
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   934
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   935
    "let user point on a screen pixel.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   936
     Return an instance for that pixels color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   937
4896
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   938
    ^ self fromUserWithFeedBack:nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   939
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   940
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   941
     Color fromUser
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   942
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   943
1976
fcf9afd72f0f Do not use obsolete method Color>>at:
Stefan Vogel <sv@exept.de>
parents: 1971
diff changeset
   944
    "Modified: / 31.8.1995 / 01:34:22 / claus"
fcf9afd72f0f Do not use obsolete method Color>>at:
Stefan Vogel <sv@exept.de>
parents: 1971
diff changeset
   945
    "Modified: / 9.1.1998 / 20:48:58 / stefan"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   946
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   947
4896
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   948
fromUserWithFeedBack:feedbackBlockOrNil
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   949
    "{ Pragma: +optSpace }"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   950
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   951
    "let user point on a screen pixel.
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   952
     Return an instance for that pixels color"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   953
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   954
    |p screen|
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   955
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   956
    screen := Screen current.
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   957
    p := screen 
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   958
            pointFromUserShowing:(Cursor crossHair)
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   959
            positionFeedback:[:p | 
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   960
                                feedbackBlockOrNil notNil ifTrue:[
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   961
                                    feedbackBlockOrNil value:(screen colorAt:p)    
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   962
                                ]
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   963
                            ].
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   964
    ^ screen colorAt:p
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   965
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   966
    "
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   967
     Color fromUserWithFeedBack:nil
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   968
    "
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   969
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   970
    "Modified: / 31.8.1995 / 01:34:22 / claus"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   971
    "Modified: / 9.1.1998 / 20:48:58 / stefan"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   972
!
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   973
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   974
green:green
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   975
    "return a color from green value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   976
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   977
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   978
    ^ here 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   979
        scaledRed:0 scaledGreen:(green * MaxValue // 100) scaledBlue:0
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   980
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   981
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   982
     (Color green:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   983
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   984
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   985
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   986
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   987
hue:h light:l saturation:s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   988
    "return a color from hue, light and saturation values.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   989
     Hue is in degrees (0..360); light and sturation are
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   990
     in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   991
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   992
    self withRGBFromHue:h light:l saturation:s do:[:r :g :b |
5131
95d91d6d649c care for invalid hue/light/saturation
Claus Gittinger <cg@exept.de>
parents: 5127
diff changeset
   993
        ^ self 
95d91d6d649c care for invalid hue/light/saturation
Claus Gittinger <cg@exept.de>
parents: 5127
diff changeset
   994
            redPercent:(r clampBetween:0 and:100) 
95d91d6d649c care for invalid hue/light/saturation
Claus Gittinger <cg@exept.de>
parents: 5127
diff changeset
   995
            greenPercent:(g clampBetween:0 and:100) 
95d91d6d649c care for invalid hue/light/saturation
Claus Gittinger <cg@exept.de>
parents: 5127
diff changeset
   996
            bluePercent:(b clampBetween:0 and:100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   997
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   998
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   999
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1000
     Color hue:0 light:50 saturation:100     - red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1001
     Color hue:60 light:50 saturation:100    - yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1002
     Color hue:120 light:50 saturation:100   - green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1003
     Color hue:120 light:75 saturation:100   - bright green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1004
     Color hue:120 light:25 saturation:100   - dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1005
     Color hue:120 light:50 saturation:50    - greyish dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1006
     Color hue:120 light:50 saturation:0     - b&w television dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1007
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1008
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1009
    "Modified: 23.4.1996 / 13:22:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1010
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1011
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1012
name:colorName
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1013
    "Return a named color (either exact or dithered).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1014
     Report an error, if aString is not a valid color name.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1015
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1016
     We hereby only guarantee that the 8 basic colors are supported
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1017
     on every device (X uses the Xcolor database, so it supports more
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1018
     names - other devices use a builtIn name table containing only the
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1019
     common names) 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1020
     - use with special names (such as 'mediumGoldenRod' is not recommended). 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1021
     Better use: #name:ifIllegal: and provide a fallBack."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1022
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1023
    ^ self 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1024
        name:colorName 
5337
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1025
        ifIllegal:[
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1026
            InvalidColorNameSignal 
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1027
                raiseRequestWith:colorName errorString:' : ' , colorName
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1028
        ]
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1029
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1030
    "
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1031
     Color name:'brown'      
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1032
     Color name:'snow'      
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1033
     Color name:'foo'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1034
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1035
1534
73dd2c4b86c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1502
diff changeset
  1036
    "Modified: 4.4.1997 / 15:32:33 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1037
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1038
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1039
name:colorName ifIllegal:errorBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1040
    "Return a named color (either exact or dithered).
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1041
     If aString is not a valid color name, 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1042
     return the result from evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1043
3399
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1044
    |triple r g b currScreen|
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1045
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1046
    triple := StandardColorValues at:colorName asString ifAbsent:nil.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1047
    triple notNil ifTrue:[
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1048
        r := triple at:1.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1049
        g := triple at:2.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1050
        b := triple at:3.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1051
    ] ifFalse:[
3399
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1052
        "/ ask display (if there is one) ...
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1053
3727
3cbc55b7db41 slightly changed
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
  1054
        (Screen notNil 
3cbc55b7db41 slightly changed
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
  1055
        and:[ (currScreen := Screen current) notNil])
3cbc55b7db41 slightly changed
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
  1056
        ifTrue:[
3399
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1057
            currScreen
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1058
                getScaledRGBFromName:colorName 
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1059
                into:[:rr :gg :bb |
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1060
                    r := rr.
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1061
                    g := gg.
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1062
                    b := bb
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1063
                ].
3727
3cbc55b7db41 slightly changed
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
  1064
        ]
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1065
    ].
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1066
    r notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1067
        ^ here scaledRed:r scaledGreen:g scaledBlue:b
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1068
    ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1069
    ^ errorBlock value
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1070
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1071
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1072
     Color name:'brown' ifIllegal:[Color black]
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1073
     Color name:'red' ifIllegal:[Color black]      
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1074
     Color name:'fuchsia' ifIllegal:[Color black]      
5337
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1075
     Color name:'foo' ifIllegal:[Color black]      
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  1076
     Color name:'foo' ifIllegal:[nil]               
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1077
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1078
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1079
    "Modified: 6.3.1997 / 02:32:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1080
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1081
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1082
noColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1083
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1084
     behave like a 0-color (i.e. have a device-pixel value of all-0s)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1085
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1086
     Pseudo0 isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1087
         Pseudo0 := self basicNew setColorId:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1088
     ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1089
     ^ Pseudo0
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1090
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1091
    "Modified: 17.1.1997 / 00:06:49 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1092
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1093
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1094
red:red
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1095
    "return a color from red value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1096
     the argument r is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1097
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1098
    ^ here 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1099
        scaledRed:(red * MaxValue // 100) scaledGreen:0 scaledBlue:0
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1100
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1101
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1102
     (Color red:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1103
    "
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1104
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1105
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1106
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1107
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1108
     the arguments, r, g and b are interpreted as percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1109
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1110
    ^ here scaledRed:(r * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1111
           scaledGreen:(g * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1112
           scaledBlue:(b * MaxValue // 100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1113
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1114
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1115
redByte:r greenByte:g blueByte:b
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1116
    "return a color from red, green and blue values;
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1117
     the arguments, r, g and b are interpreted as byte values (0..255)"
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1118
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1119
    ^ here scaledRed:(r * MaxValue // 255)
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1120
           scaledGreen:(g * MaxValue // 255)
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1121
           scaledBlue:(b * MaxValue // 255)
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1122
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1123
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1124
     (Color redByte:255 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1125
     (Color redByte:255 greenByte:255 blueByte:255) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1126
     (Color redByte:0 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1127
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1128
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1129
    "Modified: 16.1.1997 / 23:32:43 / cg"
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1130
!
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1131
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1132
redByte:r greenByte:g blueByte:b alphaByte:a
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1133
    "return a color from red, green, blue and alpha values;
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1134
     the arguments, r, g, b and a are interpreted as byte values (0..255)"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1135
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1136
    ^ (here scaledRed:(r * MaxValue // 255)
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1137
           scaledGreen:(g * MaxValue // 255)
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1138
           scaledBlue:(b * MaxValue // 255))
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1139
           alpha:(a / 255)
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1140
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1141
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1142
     (Color redByte:255 greenByte:0 blueByte:0 alphaByte:127) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1143
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1144
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1145
    "Created: / 06-06-2007 / 11:15:47 / cg"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1146
!
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1147
5144
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1148
redFraction:r greenFraction:g blueFraction:b
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1149
    "return a color from red, green and blue values;
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1150
     the arguments, r, g and b are interpreted as fraction (0..1)"
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1151
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1152
    ^ here scaledRed:(r * MaxValue) rounded
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1153
           scaledGreen:(g * MaxValue) rounded
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1154
           scaledBlue:(b * MaxValue) rounded
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1155
!
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1156
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1157
redPercent:r greenPercent:g bluePercent:b
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1158
    "return a color from red, green and blue values;
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1159
     the arguments, r, g and b are interpreted as percent (0..100)"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1160
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1161
    ^ here scaledRed:(r * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1162
           scaledGreen:(g * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1163
           scaledBlue:(b * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1164
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1165
5127
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1166
redPercent:r greenPercent:g bluePercent:b alphaPercent:a
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1167
    "return a color from red, green and blue values;
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1168
     the arguments, r, g and b are interpreted as percent (0..100)"
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1169
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1170
    ^ (here scaledRed:(r * MaxValue // 100)
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1171
           scaledGreen:(g * MaxValue // 100)
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1172
           scaledBlue:(b * MaxValue // 100))
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1173
           alpha:(a * 255 // 100)
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1174
!
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1175
3956
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1176
redShort:r greenShort:g blueShort:b
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1177
    "return a color from red, green and blue short values;
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1178
     the arguments, r, g and b are interpreted as unsigned short values (0..16rFFFF)"
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1179
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1180
    ^ here scaledRed:(r * MaxValue // 16rFFFF)
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1181
           scaledGreen:(g * MaxValue // 16rFFFF)
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1182
           scaledBlue:(b * MaxValue // 16rFFFF)
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1183
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1184
    "
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1185
     (Color redShort:16rFFFF greenShort:0 blueShort:0) inspect
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1186
    "
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1187
!
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1188
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1189
rgbValue:rgb
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1190
    "return a color from a 24bit RGB value;
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1191
     The value is composed of r<<16 + g<<8 + b."
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1192
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1193
    |r g b|
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1194
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1195
    r := (rgb bitShift:-16) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1196
    g := (rgb bitShift:-8) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1197
    b := (rgb) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1198
    ^ self redByte:r greenByte:g blueByte:b
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1199
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1200
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1201
     (Color rgbValue:16rFF0000) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1202
     (Color rgbValue:16r00FF00) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1203
     (Color rgbValue:16r0000FF) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1204
     (Color rgbValue:16rFF00FF) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1205
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1206
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1207
    "Modified: 13.8.1997 / 20:24:37 / cg"
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1208
!
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1209
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1210
scaledGray:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1211
    "return a gray color with a scaled gray value (0..MaxValue)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1212
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1213
    ^ self scaledRed:aGrayValue scaledGreen:aGrayValue scaledBlue:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1214
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1215
    "Modified: 11.6.1996 / 16:31:42 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1216
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1217
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1218
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1219
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1220
     the arguments, r, g and b are interpreted as (0..MaxValue)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1221
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1222
    |newColor|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1223
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1224
"/    "look if already known"
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1225
"/
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1226
"/    aDevice deviceColors do:[:aColor |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1227
"/        (r == aColor scaledRed) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1228
"/            (g == aColor scaledGreen) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1229
"/                (b == aColor scaledBlue) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1230
"/                    ^ aColor
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1231
"/                ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1232
"/            ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1233
"/        ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1234
"/    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1235
    newColor := self basicNew setScaledRed:r scaledGreen:g scaledBlue:b device:nil.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1236
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1237
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1238
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1239
     (Color red:100 green:0 blue:0) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1240
     (Color red:100 green:50 blue:50) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1241
     (Color red:50 green:0 blue:0) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1242
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1243
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1244
    "Modified: 2.5.1996 / 13:40:51 / stefan"
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1245
    "Modified: 24.2.1997 / 18:18:47 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1246
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1247
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1248
variableColorOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1249
    "return a variable color (i.e. allocate a writable colorcell) on
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1250
     aDevice. The returned color is not shared and its rgb components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1251
     are initially undefined. The components can be set to any value
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1252
     using Color>>red:green:blue. Care should be taken, since this call
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1253
     fails on static color or b&w displays (i.e. it depends on the device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1254
     being a pseudocolor device using colormaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1255
     Returns nil, if no more colorCells are available, or the display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1256
     uses a fix colormap (i.e. is a directColor or staticColor pr b&w device).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1257
     Because of this, you should not write your application to depend on
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1258
     writable colors to be available (i.e. add fallBack code to redraw
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1259
     things in another color)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1260
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1261
    |c lutIndex|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1262
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1263
    lutIndex := aDevice colorCell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1264
    lutIndex isNil ifTrue:[^ nil].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1265
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1266
    c := self new.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  1267
    c setDevice:aDevice colorId:lutIndex writable:true.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1268
    Cells isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1269
        Cells := Registry new.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1270
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1271
    Cells register:c.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1272
    ^ c
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1273
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1274
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1275
     |l cell|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1276
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1277
     l := Label new.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1278
     l label:('hello' asText allBold).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1279
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1280
     cell := Color variableColorOn:(Screen current).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1281
     l foregroundColor:cell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1282
     [
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1283
        1 to:40 do:[:i|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1284
            i odd ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1285
                cell red:100 green:0 blue:0
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1286
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1287
                cell red:0 green:0 blue:0
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1288
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1289
            Display flush.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1290
            (Delay forSeconds:0.4) wait
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1291
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1292
        l destroy.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1293
     ] fork.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1294
     l open
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1295
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1296
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1297
    "Modified: 13.5.1996 / 12:41:53 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1298
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1299
3892
fb62c937c134 category
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  1300
!Color class methodsFor:'Compatibility-Squeak'!
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1301
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1302
colorPaletteForDepth: depth extent: chartExtent
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1303
        "Squeak mimicri:
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1304
         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."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1305
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1306
        "Note: It is slow to build this palette, so it should be cached for quick access."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1307
        "(Color colorPaletteForDepth: 16 extent: 190@60) display"
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1308
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1309
        | basicHue x y c startHue palette transHt vSteps transCaption grayWidth hSteps |
3324
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
  1310
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
  1311
"/        Smalltalk isSmalltalkX ifTrue:[
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1312
            palette := Image extent:chartExtent depth:24.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1313
            palette photometric:#rgb.
4186
2ac5f5cb7944 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4176
diff changeset
  1314
            palette bits:(ByteArray new:chartExtent x * chartExtent y * 3).   
3324
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
  1315
"/        ] ifFalse:[
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
  1316
"/            palette := Form extent: chartExtent depth: depth.
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
  1317
"/        ].
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1318
        transCaption := "(DisplayText text: 'no color' asText textStyle: (TextConstants at: #ComicPlain)) form storeString"
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1319
                (Form extent: 34@9 depth: 1
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1320
                        fromArray: #(0 0 256 0 256 0 3808663859 2147483648 2491688266 2147483648 2491688266 0 2491688266 0 2466486578 0 0 0)
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1321
                        offset: 0@0).
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1322
        transHt := transCaption height.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1323
        palette fillWhite: (0@0 extent: palette width@transHt).
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1324
        palette fillBlack: (0@transHt extent: palette width@1).
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1325
"/        transCaption displayOn: palette at: palette boundingBox topCenter - ((transCaption width // 2)@0).
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1326
        grayWidth := 10.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1327
        startHue := 338.0.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1328
        vSteps := palette height - transHt // 2.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1329
        hSteps := palette width - grayWidth.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1330
        x := 0.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1331
        startHue to: startHue + 360.0 by: 360.0/hSteps do: [:h |
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1332
                basicHue := Color h: h asFloat s: 1.0 v: 1.0.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1333
                y := transHt+1.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1334
                0 to: vSteps do: [:n |
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1335
                        c := basicHue mixed: (n asFloat / vSteps asFloat) with: Color white.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1336
                        palette fill: (x@y extent: 1@1) fillColor: c.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1337
                        y := y + 1].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1338
                1 to: vSteps do: [:n |
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1339
                        c := Color black mixed: (n asFloat / vSteps asFloat) with: basicHue.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1340
                        y < palette height ifTrue:[
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1341
                            palette fill: (x@y extent: 1@1) fillColor: c.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1342
                        ].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1343
                        y := y + 1].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1344
                x := x + 1].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1345
        y := transHt + 1.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1346
        1 to: vSteps * 2 do: [:n |
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1347
                c := Color black mixed: (n asFloat / (vSteps*2) asFloat) with: Color white.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1348
                palette fill: (x@y corner:(((x@y) +(10@1))min:palette extent)) fillColor: c.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1349
                y := y + 1].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1350
        ^ palette
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1351
!
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1352
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1353
fromRgbTriplet:aTriple
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1354
    ^ self r:(aTriple at:1)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1355
           g:(aTriple at:2)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1356
           b:(aTriple at:3)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1357
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1358
!
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1359
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1360
h:hue s:saturation v:brightness
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1361
    "Squeak mimicri:
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1362
     Create a color with the given hue, saturation, and brightness. 
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1363
     Hue is given as the angle in degrees of the color on the color circle,
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1364
     where red is zero degrees. 
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1365
     Saturation and brightness are numbers in [0.0..1.0],
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1366
     where larger values are more saturated or brighter colors. 
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1367
     For example, (Color h: 0 s: 1 v: 1) is pure red."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1368
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1369
    "Note: By convention, brightness is abbreviated 'v' to to avoid confusion with blue."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1370
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1371
    ^ self hue:hue light:(brightness*50) saturation:(saturation*100)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1372
!
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1373
4986
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1374
indexedColors
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1375
    "Build an array of colors corresponding to the fixed colormap used
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1376
     for display depths of 1, 2, 4, or 8 bits."
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1377
    "Color indexedColors"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1378
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1379
    | a index grayVal |
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1380
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1381
    a := Array new: 256.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1382
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1383
    "1-bit colors (monochrome)"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1384
    a at: 1 put: (Color r: 1.0 g: 1.0 b: 1.0).  "white or transparent"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1385
    a at: 2 put: (Color r: 0.0 g: 0.0 b: 0.0).  "black"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1386
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1387
    "additional colors for 2-bit color"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1388
    a at: 3 put: (Color r: 1.0 g: 1.0 b: 1.0).  "opaque white"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1389
    a at: 4 put: (Color r: 0.5 g: 0.5 b: 0.5).  "1/2 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1390
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1391
    "additional colors for 4-bit color"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1392
    a at:  5 put: (Color r: 1.0 g: 0.0 b: 0.0). "red"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1393
    a at:  6 put: (Color r: 0.0 g: 1.0 b: 0.0). "green"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1394
    a at:  7 put: (Color r: 0.0 g: 0.0 b: 1.0). "blue"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1395
    a at:  8 put: (Color r: 0.0 g: 1.0 b: 1.0). "cyan"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1396
    a at:  9 put: (Color r: 1.0 g: 1.0 b: 0.0). "yellow"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1397
    a at: 10 put: (Color r: 1.0 g: 0.0 b: 1.0). "magenta"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1398
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1399
    a at: 11 put: (Color r: 0.125 g: 0.125 b: 0.125).       "1/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1400
    a at: 12 put: (Color r: 0.25 g: 0.25 b: 0.25).      "2/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1401
    a at: 13 put: (Color r: 0.375 g: 0.375 b: 0.375).       "3/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1402
    a at: 14 put: (Color r: 0.625 g: 0.625 b: 0.625).       "5/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1403
    a at: 15 put: (Color r: 0.75 g: 0.75 b: 0.75).      "6/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1404
    a at: 16 put: (Color r: 0.875 g: 0.875 b: 0.875).       "7/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1405
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1406
    "additional colors for 8-bit color"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1407
    "24 more shades of gray (1/32 increments but not repeating 1/8 increments)"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1408
    index := 17.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1409
    1 to: 31 do: [:v |
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1410
        (v \\ 4) = 0 ifFalse: [
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1411
            grayVal := v / 32.0.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1412
            a at: index put: (Color r: grayVal g: grayVal b: grayVal).
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1413
            index := index + 1]].
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1414
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1415
    "The remainder of color table defines a color cube with six steps
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1416
     for each primary color. Note that the corners of this cube repeat
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1417
     previous colors, but this simplifies the mapping between RGB colors
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1418
     and color map indices. This color cube spans indices 40 through 255
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1419
     (indices 41-256 in this 1-based array)."
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1420
    0 to: 5 do: [:r |
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1421
        0 to: 5 do: [:g |
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1422
            0 to: 5 do: [:b |
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1423
                index := 41 + ((36 * r) + (6 * b) + g).
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1424
                index > 256 ifTrue: [
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1425
                    self error: 'index out of range in color table compuation'].
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1426
                a at: index put: (Color r: r g: g b: b range: 5)]]].
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1427
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1428
    ^ a.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1429
!
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1430
3893
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1431
paleBlue
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1432
    ^ self r:0.75 g:0.75 b:1
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1433
!
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1434
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1435
pixelScreenForDepth: depth
3898
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1436
    "Return a 50% stipple containing alternating pixels of all-zeros and all-ones to be used as a mask at the given depth."
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1437
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1438
    | mask bits |
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1439
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1440
    (Smalltalk dialectName = 'SmalltalkX') ifTrue:[
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1441
        depth == 1 ifTrue:[
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1442
            ^ Form mediumGreyFormOn:Screen current
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1443
        ].
3898
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1444
        self shouldImplement.
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1445
    ].
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1446
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1447
    mask := (1 bitShift: depth) - 1.
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1448
    bits := 2 * depth.
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1449
    [bits >= 32] whileFalse: [
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1450
        mask := mask bitOr: (mask bitShift: bits).  "double the length of mask"
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1451
        bits := bits + bits
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1452
    ].
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1453
    ^ Bitmap with: mask with: mask bitInvert32
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1454
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1455
    "
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1456
     self pixelScreenForDepth: depth
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1457
    "
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1458
!
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1459
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1460
r:redFraction g:greenFraction b:blueFraction
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1461
    "Squeak mimicri:
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1462
     return a color from red, green and blue fractional values;
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1463
     the arguments, r, g and b must be in (0..1)"
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1464
2937
4536e6de438a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  1465
    ^ here scaledRed:(redFraction * MaxValue) rounded
4536e6de438a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  1466
           scaledGreen:(greenFraction * MaxValue) rounded
4536e6de438a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  1467
           scaledBlue:(blueFraction * MaxValue) rounded
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1468
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1469
    "Modified: / 06-06-2007 / 11:19:53 / cg"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1470
!
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1471
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1472
r:r g:g b:b alpha:alphaValue
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1473
    "return a color from red, green and blue values;
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1474
     the arguments, r, g, b and alpha must be in 0..1"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1475
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1476
    ^ (self r:r g:g b:b) alpha:alphaValue
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1477
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1478
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1479
     (Color r:1 g:0 b:0 alpha:0) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1480
     (Color r:0 g:1 b:0 alpha:0.5) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1481
     (Color r:0 g:0 b:1 alpha:1) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1482
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1483
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1484
    "Created: / 06-06-2007 / 10:48:21 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1485
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1486
4202
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1487
r:r g:g b:b range:componentMax
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1488
    "return a color from red, green and blue values;
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1489
     the arguments, r, g and b are interpreted as values (0..componentMax)"
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1490
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1491
    ^ here scaledRed:(r * MaxValue // componentMax)
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1492
           scaledGreen:(g * MaxValue // componentMax)
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1493
           scaledBlue:(b * MaxValue // componentMax)
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1494
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1495
    "
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1496
     (Color r:1023 g:0 b:0 range:1023) inspect
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1497
     (Color r:1023 g:1023 b:1023 range:1023) inspect
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1498
     (Color r:0 g:0 b:0 range:1023) inspect
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1499
    "
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1500
!
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1501
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1502
showColors: colorList
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1503
        "Display the given collection of colors across the top of the Display."
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1504
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1505
        | w r |
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1506
        w _ Display width // colorList size.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1507
        r _ 0@0 extent: w@((w min: 30) max: 10).
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1508
        colorList do: [:c |
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1509
                Display fill: r fillColor: c.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1510
                r _ r translateBy: w@0].
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1511
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1512
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1513
wheel: thisMany
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1514
    "Return a collection of thisMany colors evenly spaced around the color wheel."
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1515
    "Color showColors: (Color wheel: 12)"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1516
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1517
    ^ Color wheel: thisMany saturation: 0.9 brightness: 0.7
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1518
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1519
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1520
wheel: thisMany saturation: s brightness: v
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1521
    "Return a collection of thisMany colors evenly spaced around the color wheel, 
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1522
     all of the given saturation and brightness."
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1523
    "Color showColors: (Color wheel: 12 saturation: 0.4 brightness: 1.0)"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1524
    "Color showColors: (Color wheel: 12 saturation: 0.8 brightness: 0.5)"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1525
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1526
    ^ (Color h: 0.0 s: s v: v) wheel: thisMany
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1527
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1528
    "Modified: / 06-06-2007 / 11:20:59 / cg"
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1529
! !
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1530
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1531
!Color class methodsFor:'Signal constants'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1532
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1533
colorAllocationFailSignal
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1534
    "return the signal raised when a color allocation failed."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1535
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1536
    ^ ColorAllocationFailSignal
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1537
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1538
    "Created: 12.6.1996 / 17:44:49 / cg"
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1539
!
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1540
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1541
colorErrorSignal
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1542
    "return the parent signal of all color error signals."
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1543
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1544
    ^ ColorErrorSignal
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1545
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1546
    "Created: / 30.9.1998 / 21:56:04 / cg"
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1547
!
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1548
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1549
invalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1550
    "return the signal raised when an invalid color name is encountered"
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1551
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1552
    ^ InvalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1553
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1554
    "Created: 24.1.1997 / 13:36:25 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1555
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1556
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1557
!Color class methodsFor:'accessing'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1558
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1559
allocatedColorsOn:aDevice
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1560
    "return a collection of colors which have already been allocated
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1561
     on aDevice."
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1562
4176
40b359dfc293 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4170
diff changeset
  1563
    <resource: #obsolete>
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1564
    self obsoleteMethodWarning:'use #allocatedColorsOnDevice:'.
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1565
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1566
    ^ self allocatedColorsOnDevice:aDevice
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1567
!
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1568
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1569
allocatedColorsOnDevice:aDevice
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1570
    "return a collection of colors which have already been allocated
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1571
     on aDevice."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1572
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1573
    |colors|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1574
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1575
    colors := OrderedCollection new.
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1576
    aDevice deviceColors do:[:clr |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1577
        clr colorId notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1578
            colors add:clr
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1579
        ] ifFalse:[
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1580
            'Color [oops]: nil colorId in color' infoPrintCR.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1581
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1582
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1583
    ^ colors asArray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1584
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1585
    "
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1586
     Color allocatedColorsOnDevice:Display
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1587
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1588
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1589
    "Modified: 24.2.1997 / 18:16:14 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1590
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1591
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1592
!Color class methodsFor:'color space conversions'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1593
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1594
withHLSFromRed:r green:g blue:b do:aBlock
3543
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1595
    "compute hls form rgb, evaluate aBlock with h,l and s as arguments.
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1596
     r,g,b in 0..100
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1597
     h in 0..360; l in 0..100; s in 0..100"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1598
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1599
    |max min r1 g1 b1 delta h l s|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1600
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1601
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1602
    r1 := r / 100.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1603
    g1 := g / 100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1604
    b1 := b / 100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1605
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1606
    max := (r1 max:g1) max:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1607
    min := (r1 min:g1) min:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1608
    l := (max + min) / 2.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1609
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1610
    max = min ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1611
        "achromatic, r=g=b"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1612
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1613
        s := 0.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1614
        h := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1615
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1616
        l < 0.5 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1617
            s := (max - min) / (max + min)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1618
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1619
            s := (max - min) / (2 - max - min)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1620
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1621
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1622
        "calc hue"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1623
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1624
        delta := max - min.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1625
        r1 = max ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1626
            h := (g1 - b1) / delta
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1627
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1628
            g1 = max ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1629
                h := 2 + ((b1 - r1) / delta)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1630
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1631
                h := 4 + ((r1 - g1) / delta)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1632
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1633
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1634
        h := h * 60.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1635
        h < 0 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1636
            h := h + 360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1637
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1638
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1639
    aBlock value:h value:(l * 100) value:(s * 100)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1640
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1641
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1642
withHLSFromScaledRed:r scaledGreen:g scaledBlue:b do:aBlock
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1643
    "compute hls form rgb, evaluate aBlock with h,l and s as arguments"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1644
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1645
    ^ self withHLSFromRed:(r * 100.0 / MaxValue)
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1646
                    green:(g * 100.0 / MaxValue) 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1647
                     blue:(b * 100.0 / MaxValue)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1648
                       do:aBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1649
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1650
    "Created: 11.6.1996 / 17:23:47 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1651
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1652
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1653
withRGBFromHue:h light:l saturation:s do:aBlock
3543
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1654
    "compute rgb form hls, evaluate aBlock with r,g and b as arguments
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1655
     r,g,b in 0..100
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1656
     h in 0..360; l in 0..100; s in 0..100"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1657
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1658
    |valueFunc s1 l1 r g b m1 m2|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1659
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1660
    valueFunc := [:n1 :n2 :hIn |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1661
        |hue|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1662
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1663
        hue := hIn.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1664
        hue > 360 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1665
            hue := hue - 360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1666
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1667
            hue < 0 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1668
                hue := hue + 360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1669
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1670
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1671
        hue < 60 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1672
            n1 + ((n2 - n1) * hue / 60)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1673
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1674
            hue < 180 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1675
                n2
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1676
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1677
                hue < 240 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1678
                    n1 + ((n2 - n1) * (240 - hue) / 60)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1679
                ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1680
                    n1
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1681
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1682
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1683
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1684
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1685
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1686
    "compute hls; h in 0..360; l 0..100; s 0..100"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1687
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1688
    s1 := s / 100.0.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1689
    l1 := l / 100.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1690
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1691
    l1 <= 0.5 ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1692
        m2 := l1 * (1 + s1)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1693
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1694
        m2 := l1 + s1 - (l1 * s1)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1695
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1696
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1697
    m1 := 2 * l1 - m2.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1698
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1699
    s1 = 0 ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1700
        "achromatic, ignore hue"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1701
        r := g := b := l1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1702
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1703
        r := valueFunc value:m1 value:m2 value:h + 120.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1704
        g := valueFunc value:m1 value:m2 value:h.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1705
        b := valueFunc value:m1 value:m2 value:h - 120.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1706
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1707
    aBlock value:r*100 value:g*100 value:b*100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1708
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1709
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1710
!Color class methodsFor:'constant colors'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1711
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1712
black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1713
    "return the black color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1714
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1715
    Black isNil ifTrue:[
3039
1c5a5ddfbefb do not depend on Screen class being present in Color black/white.
Claus Gittinger <cg@exept.de>
parents: 3030
diff changeset
  1716
        Black := self red:0 green:0 blue:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1717
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1718
    ^ Black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1719
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1720
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1721
     Color black inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1722
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1723
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1724
    "Modified: 11.6.1996 / 15:55:31 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1725
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1726
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1727
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1728
    "return the blue color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1729
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1730
    Blue isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1731
        Blue := self redPercent:0 greenPercent:0 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1732
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1733
    ^ Blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1734
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1735
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1736
     Color blue inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1737
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1738
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1739
    "Modified: 23.4.1996 / 13:15:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1740
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1741
2962
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1742
brown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1743
    ^ self redPercent:60 greenPercent:20 bluePercent:0
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1744
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1745
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1746
     Color brown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1747
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1748
!
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1749
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1750
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1751
    "return the cyan color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1752
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1753
    ^ self cyan:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1754
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1755
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1756
     Color cyan inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1757
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1758
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1759
    "Modified: 23.4.1996 / 13:16:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1760
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1761
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1762
cyan: cyan
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1763
    "return a cyan color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1764
     the argument cyan is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1765
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1766
     ^ self cyan:100 magenta:100-cyan yellow:100-cyan
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1767
                                     
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1768
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1769
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1770
darkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1771
    "return the dark grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1772
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1773
    DarkGrey isNil ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1774
        DarkGrey := self grayPercent:33
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1775
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1776
    ^ DarkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1777
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1778
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1779
     Color darkGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1780
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1781
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1782
    "Modified: 24.2.1997 / 21:33:11 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1783
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1784
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1785
darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1786
    "return the darkGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1787
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1788
    ^ self darkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1789
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1790
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1791
     Color darkGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1792
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1793
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1794
    "Modified: 28.5.1996 / 20:47:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1795
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1796
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1797
gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1798
    "return a medium grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1799
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1800
    Grey isNil ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1801
        Grey := self grayPercent:50
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1802
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1803
    ^ Grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1804
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1805
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1806
     Color gray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1807
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1808
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1809
    "Modified: 24.2.1997 / 21:33:19 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1810
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1811
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1812
gray:gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1813
    "return a gray color (US version). 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1814
     The argument, gray is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1815
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1816
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1817
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1818
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1819
     Color gray:25
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1820
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1821
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1822
    "Modified: 28.5.1996 / 20:49:51 / cg"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1823
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1824
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1825
grayPercent:gray
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1826
    "return a gray color (US version). 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1827
     The argument, gray is interpreted as percent (0..100)."
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1828
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1829
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1830
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1831
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1832
     Color gray:25
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1833
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1834
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1835
    "Modified: 28.5.1996 / 20:49:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1836
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1837
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1838
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1839
    "return green"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1840
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1841
    Green isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1842
        Green := self redPercent:0 greenPercent:100 bluePercent:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1843
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1844
    ^ Green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1845
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1846
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1847
     Color green inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1848
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1849
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1850
    "Modified: 23.4.1996 / 13:23:08 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1851
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1852
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1853
grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1854
    "return the grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1855
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1856
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1857
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1858
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1859
     Color grey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1860
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1861
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1862
    "Modified: 28.5.1996 / 20:48:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1863
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1864
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1865
grey:grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1866
    "return a grey color (English version). 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1867
     The argument, grey is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1868
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1869
    ^ self grayPercent:grey
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1870
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1871
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1872
     Color grey:25
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1873
     Color grey:12.5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1874
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1875
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1876
    "Modified: 24.2.1997 / 21:33:28 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1877
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1878
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1879
lightBlue
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1880
    "return a light blue color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1881
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1882
    ^ self redPercent:50 greenPercent:50 bluePercent:100
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1883
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1884
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1885
     Color lightBlue inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1886
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1887
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1888
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1889
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1890
2962
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1891
lightBrown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1892
    ^ self brown lighter
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1893
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1894
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1895
     Color lightBrown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1896
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1897
!
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1898
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1899
lightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1900
    "return the lightGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1901
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1902
    LightGrey isNil ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1903
        LightGrey := self grayPercent:67
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1904
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1905
    ^ LightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1906
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1907
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1908
     Color lightGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1909
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1910
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1911
    "Modified: 24.2.1997 / 21:33:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1912
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1913
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1914
lightGreen
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1915
    "return a light green color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1916
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1917
    ^ self redPercent:50 greenPercent:100 bluePercent:50
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1918
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1919
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1920
     Color lightGreen inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1921
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1922
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1923
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1924
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1925
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1926
lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1927
    "return the lightGrey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1928
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1929
    ^ self lightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1930
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1931
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1932
     Color lightGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1933
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1934
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1935
    "Modified: 28.5.1996 / 20:51:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1936
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1937
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1938
lightRed
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1939
    "return a light red color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1940
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1941
    ^ self redPercent:100 greenPercent:50 bluePercent:50
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1942
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1943
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1944
     Color lightRed inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1945
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1946
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1947
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1948
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1949
2949
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1950
lightYellow
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1951
    ^ self yellow lighter
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1952
!
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1953
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1954
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1955
    "return the magenta color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1956
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1957
    ^ self magenta:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1958
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1959
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1960
     Color magenta inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1961
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1962
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1963
    "Modified: 23.4.1996 / 13:23:41 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1964
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1965
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1966
magenta: magenta
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1967
    "return a magenta color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1968
     the argument magenta is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1969
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1970
     ^ self cyan:100-magenta magenta:100 yellow:100-magenta
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1971
                                     
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1972
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1973
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1974
mediumGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1975
    "return medium-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1976
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1977
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1978
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1979
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1980
     Color mediumGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1981
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1982
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1983
    "Created: 23.4.1996 / 13:24:17 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1984
    "Modified: 28.5.1996 / 20:51:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1985
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1986
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1987
mediumGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1988
    "return medium-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1989
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1990
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1991
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1992
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1993
     Color mediumGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1994
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1995
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1996
    "Modified: 28.5.1996 / 20:51:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1997
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1998
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1999
orange
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2000
    "return the orange color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2001
2077
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2002
     ^ self orange:100
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2003
!
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2004
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2005
orange: orange
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2006
    "return a orange color;
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2007
     the argument orange is interpreted as percent (0..100)"
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2008
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2009
     ^ self redPercent:orange greenPercent:orange/2 bluePercent:0
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2010
                                     
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2011
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2012
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2013
pink 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2014
    "return the pink color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2015
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2016
     ^ self redPercent:100 greenPercent:0 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2017
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2018
    "Modified: 23.4.1996 / 13:29:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2019
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2020
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2021
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2022
    "return the red color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2024
    Red isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2025
        Red := self redPercent:100 greenPercent:0 bluePercent:0.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2026
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2027
    ^ Red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2028
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2029
    "Modified: 23.4.1996 / 13:29:44 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2030
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2031
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2032
transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2033
    "return the transparent-color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2034
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2035
    Transparent isNil ifTrue:[
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  2036
        Transparent := TranslucentColor scaledRed:0 scaledGreen:0 scaledBlue:0.
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2037
        Transparent setAlphaByte:0.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2038
    ].
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2039
    ^ Transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2040
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2041
    "
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2042
     self transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2043
    "
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2044
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2045
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2046
veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2047
    "return a very dark-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2048
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  2049
    ^ self grayPercent:13
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2050
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2051
    "Created: 23.4.1996 / 13:33:14 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  2052
    "Modified: 24.2.1997 / 21:33:52 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2053
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2054
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2055
veryDarkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2056
    "return a very dark-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2057
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2058
    ^ self veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2059
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2060
    "Modified: 28.5.1996 / 20:52:49 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2061
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2062
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2063
veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2064
    "return a very light-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2065
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  2066
    ^ self grayPercent:87
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2067
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2068
    "Created: 23.4.1996 / 13:33:46 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  2069
    "Modified: 24.2.1997 / 21:33:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2070
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2071
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2072
veryLightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2073
    "return a very light-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2074
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2075
    ^ self veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2076
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2077
    "Modified: 28.5.1996 / 20:52:03 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2078
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2079
3030
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2080
veryVeryLightGray
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2081
    "return a very very light-grey color (US version ;-)"
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2082
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2083
    ^ self grayPercent:93
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2084
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2085
!
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2086
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2087
white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2088
    "return the white-color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2089
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2090
    White isNil ifTrue:[
3039
1c5a5ddfbefb do not depend on Screen class being present in Color black/white.
Claus Gittinger <cg@exept.de>
parents: 3030
diff changeset
  2091
        White := self redPercent:100 greenPercent:100 bluePercent:100.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2092
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2093
    ^ White
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2094
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2095
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2096
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2097
    "return the yellow color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2098
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2099
    ^ self yellow:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2101
    "Modified: 23.4.1996 / 13:33:56 / cg"
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2102
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2103
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2104
yellow: yellow
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2105
    "return a yellow color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2106
     the argument yellow is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2107
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2108
     ^ self cyan:100-yellow magenta:100-yellow yellow:100
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2109
                                     
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2110
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2111
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2112
!Color class methodsFor:'obsolete'!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2113
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2114
nameOrDither:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2115
    "return a named color - if the exact color is not available,
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2116
     return a dithered color. Report an error, if the colorname is 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2117
     illegal."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2118
3427
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2119
    <resource:#obsolete>
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2120
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2121
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2122
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2123
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2124
    "Modified: 16.1.1997 / 23:01:03 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2125
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2126
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2127
nameOrDither:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2128
    "return a named color - if the exact color is not available,
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2129
     return a dithered color. If the colorname is illegal, return
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2130
     the value of evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2131
3427
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2132
    <resource:#obsolete>
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2133
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2134
    self obsoleteMethodWarning:'use #name:ifIllegal:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2135
    ^ self name:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2136
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2137
    "Modified: 16.1.1997 / 23:01:32 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2138
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2139
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2140
nameOrNearest:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2141
    "return a named color - or its nearest match"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2142
3427
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2143
    <resource:#obsolete>
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2144
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2145
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2146
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2147
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2148
    "Modified: 16.1.1997 / 23:02:18 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2149
! !
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2150
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  2151
!Color class methodsFor:'private'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2152
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2153
colorNearRed:r green:g blue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2154
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2155
     almost matching. If there is one, nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2156
     This is tried as a last chance before dithering.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2157
     The algorithm needs rework, the color components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2158
     should be weighted according some theory :-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2159
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2160
    |bestColor minDelta diff rr rg rb dRed|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2161
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2162
"/    rr := (r * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2163
"/    rg := (g * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2164
"/    rb := (b * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2165
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2166
    rr := r rounded.                "round to 1%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2167
    rg := (g * 2.0) rounded / 2.0.  "round to 0.5%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2168
    rb := (b / 2) rounded * 2.      "round to 2%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2169
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2170
    minDelta := 100*100*100.
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2171
    aDevice deviceColors do:[:aColor |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2172
        dRed := rr - aColor red.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2173
        dRed < 10 ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2174
            diff := dRed asInteger squared
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2175
                    + (rg - aColor green) asInteger squared
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2176
                    + (rb - aColor blue) asInteger squared.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2177
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2178
            diff < minDelta ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2179
                diff = 0 ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2180
                    "got it"
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2181
                    ^ aColor
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2182
                ].
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2183
                bestColor := aColor.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2184
                minDelta := diff
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2185
            ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2186
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2187
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2188
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2189
    "allow an error of 10% per component"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2190
    minDelta < (100+100+100) ifTrue:[ ^ bestColor ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2191
    ^ nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2192
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2193
    "Modified: 24.2.1997 / 18:17:24 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2194
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2195
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2196
existingColorRed:r green:g blue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2197
    "return a device color on aDevice with rgb values
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2198
     if there is one, nil otherwise."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2199
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2200
    ^ self existingColorScaledRed:(r * MaxValue // 100)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2201
                        scaledGreen:(g * MaxValue // 100)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2202
                        scaledBlue:(b * MaxValue // 100)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2203
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2204
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2205
existingColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2206
    "return a device color on aDevice with rgb values
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2207
     if there is one, nil otherwise."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2208
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2209
    aDevice deviceColors do:[:aColor |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2210
        (r == aColor scaledRed) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2211
            (g == aColor scaledGreen) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2212
                (b == aColor scaledBlue) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2213
                    ^ aColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2214
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2215
            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2216
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2217
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2218
    ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2219
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2220
    "Modified: 24.2.1997 / 18:17:35 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2221
! !
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2222
3878
28052cae1ad3 method category rename
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
  2223
!Color class methodsFor:'private-dithering'!
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2224
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2225
complexDitherRed:red green:green blue:blue on:aDevice into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2226
    "get a deep dither form for an rgb value.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2227
     Use all available colors for error dithering into a form."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2228
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2229
    |errR errG errB f wantR wantG wantB clr 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2230
     dir   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2231
     start "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2232
     end   "{ Class: SmallInteger }" 
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2233
     map
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2234
     w     "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2235
     h     "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2236
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2237
"/    w := h := 32.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2238
"/    w := h := 4.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2239
    w := h := 2.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2240
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2241
    errR := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2242
    errG := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2243
    errB := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2244
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2245
    "get a form and clear it"
4785
ffb3b0caceb8 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4772
diff changeset
  2246
    f := Form width:w height:h depth:(aDevice depth) onDevice:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2247
    map := IdentityDictionary new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2248
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2249
    0 to:(w-1) do:[:x |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2250
        x even ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2251
            dir := 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2252
            start := 0.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2253
            end := (h-1).
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2254
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2255
            dir := -1.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2256
            start := (h-1).
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2257
            end := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2258
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2259
        start to:end by:dir do:[:y |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2260
            wantR := red + errR. 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2261
            wantR > MaxValue ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2262
                wantR := MaxValue
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2263
            ] ifFalse:[ wantR < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2264
                wantR := 0
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2265
            ]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2266
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2267
            wantG := green + errG.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2268
            wantG > MaxValue ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2269
                wantG := MaxValue
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2270
            ] ifFalse:[ wantG < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2271
                wantG := 0
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2272
            ]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2273
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2274
            wantB := blue + errB.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2275
            wantB > MaxValue ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2276
                wantB := MaxValue
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2277
            ] ifFalse:[ wantB < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2278
                wantB := 0
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2279
            ]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2280
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2281
            "find the nearest color"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2282
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2283
            clr := Color quickNearestColorScaledRed:wantR scaledGreen:wantG scaledBlue:wantB on:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2284
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2285
            clr := Color nearestColorScaledRed:wantR green:wantG blue:wantB on:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2286
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2287
            clr isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2288
                clr := Color scaledRed:wantR scaledGreen:wantG scaledBlue:wantB.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2289
                clr brightness > 0.5 ifTrue:[
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  2290
                    clr := Color white
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2291
                ] ifFalse:[
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  2292
                    clr := Color black
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  2293
                ].
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  2294
                clr := clr onDevice:aDevice
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2295
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2296
                ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2297
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2298
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2299
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2300
            f paint:clr.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2301
            f displayPointX:x y:y.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2302
            map at:clr colorId + 1 put:clr.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2303
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2304
            "compute the new error"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2305
            errR := wantR - clr scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2306
            errG := wantG - clr scaledGreen.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2307
            errB := wantB - clr scaledBlue.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2308
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2309
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2310
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2311
    f colorMap:map.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2312
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2313
'hard dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2314
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2315
    ^ aBlock value:nil value:f
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2316
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2317
    "Created: 3.5.1997 / 11:02:47 / cg"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2318
    "Modified: 19.10.1997 / 23:28:59 / cg"
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2319
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2320
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2321
ditherBits
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2322
    "return a dither pattern for x/64; x in 1..63"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2323
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2324
    ^ #(
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2325
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2326
        "/ 1in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2327
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2328
          #[2r10000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2329
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2330
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2331
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2332
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2333
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2334
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2335
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2336
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2337
        "/ 2in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2338
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2339
          #[2r10000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2340
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2341
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2342
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2343
            2r00001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2344
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2345
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2346
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2347
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2348
        "/ 3in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2349
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2350
          #[2r10000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2351
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2352
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2353
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2354
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2355
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2356
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2357
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2358
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2359
        "/ 4in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2361
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2362
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2363
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2364
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2365
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2366
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2367
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2368
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2369
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2370
        "/ 5in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2371
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2372
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2373
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2374
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2375
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2376
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2377
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2378
            2r00000010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2379
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2380
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2381
        "/ 6in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2382
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2383
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2384
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2385
            2r00100000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2386
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2387
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2388
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2389
            2r00000010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2390
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2391
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2392
        "/ 7in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2393
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2394
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2395
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2396
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2397
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2398
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2399
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2400
            2r00000010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2401
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2402
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2403
        "/ 8in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2404
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2405
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2406
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2407
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2408
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2409
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2410
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2411
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2412
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2413
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2414
        "/ 9in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2415
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2416
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2417
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2418
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2419
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2420
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2421
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2422
            2r10100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2423
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2424
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2425
        "/ 10in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2426
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2427
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2428
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2429
            2r00101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2430
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2431
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2432
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2433
            2r10100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2434
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2435
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2436
        "/ 11in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2437
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2438
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2439
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2440
            2r00101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2441
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2442
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2443
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2444
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2445
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2446
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2447
        "/ 12in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2448
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2449
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2450
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2451
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2452
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2453
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2454
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2455
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2456
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2457
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2458
        "/ 13in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2459
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2460
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2461
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2462
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2463
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2464
            2r10101000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2465
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2466
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2467
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2468
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2469
        "/ 14in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2470
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2471
          #[2r10001010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2472
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2473
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2474
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2475
            2r10101000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2476
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2477
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2478
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2479
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2480
        "/ 15in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2481
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2482
          #[2r10001010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2483
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2484
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2485
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2486
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2487
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2488
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2489
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2490
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2491
        "/ 16in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2492
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2493
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2494
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2495
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2496
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2497
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2498
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2499
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2500
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2501
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2502
        "/ 17in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2503
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2504
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2505
            2r01000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2506
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2507
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2508
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2509
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2510
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2511
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2512
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2513
        "/ 18in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2514
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2515
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2516
            2r01000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2517
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2518
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2519
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2520
            2r00000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2521
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2522
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2523
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2524
        "/ 19in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2525
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2526
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2527
            2r01000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2528
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2529
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2530
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2531
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2532
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2533
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2534
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2535
        "/ 20in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2536
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2537
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2538
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2539
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2540
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2541
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2542
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2543
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2544
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2545
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2546
        "/ 21in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2547
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2548
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2549
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2550
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2551
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2552
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2553
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2554
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2555
            2r00000001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2556
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2557
        "/ 22in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2558
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2559
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2560
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2561
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2562
            2r00010000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2563
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2564
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2565
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2566
            2r00000001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2567
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2568
        "/ 23in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2569
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2570
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2571
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2572
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2573
            2r00010001
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2574
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2575
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2576
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2577
            2r00000001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2578
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2579
        "/ 24in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2580
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2581
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2582
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2583
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2584
            2r00010001
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2585
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2586
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2587
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2588
            2r00010001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2589
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2590
        "/ 25in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2591
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2592
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2593
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2594
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2595
            2r00010001
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2596
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2597
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2598
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2599
            2r01010001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2600
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2601
        "/ 26in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2602
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2603
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2604
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2605
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2606
            2r00010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2607
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2608
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2609
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2610
            2r01010001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2611
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2612
        "/ 27in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2613
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2614
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2615
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2616
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2617
            2r00010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2618
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2619
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2620
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2621
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2622
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2623
        "/ 28in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2624
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2625
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2626
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2627
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2628
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2629
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2630
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2631
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2632
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2633
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2634
        "/ 29in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2635
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2636
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2637
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2638
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2639
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2640
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2641
            2r01010100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2642
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2643
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2644
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2645
        "/ 30in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2646
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2647
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2648
            2r01000101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2649
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2650
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2651
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2652
            2r01010100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2653
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2654
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2655
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2656
        "/ 31in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2657
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2658
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2659
            2r01000101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2660
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2661
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2662
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2663
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2664
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2665
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2666
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2667
        "/ 32in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2668
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2669
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2670
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2671
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2672
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2673
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2674
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2675
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2676
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2677
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2678
        "/ 33in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2679
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2680
          #[2r11101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2681
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2682
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2683
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2684
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2685
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2686
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2687
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2688
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2689
        "/ 34in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2690
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2691
          #[2r11101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2692
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2693
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2694
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2695
            2r10101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2696
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2697
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2698
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2699
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2700
        "/ 35in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2701
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2702
          #[2r11101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2703
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2704
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2705
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2706
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2707
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2708
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2709
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2710
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2711
        "/ 36in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2712
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2713
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2714
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2715
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2716
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2717
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2718
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2719
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2720
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2721
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2722
        "/ 37in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2723
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2724
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2725
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2726
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2727
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2728
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2729
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2730
            2r10101011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2731
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2732
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2733
        "/ 38in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2734
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2735
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2736
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2737
            2r10111010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2738
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2739
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2740
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2741
            2r10101011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2742
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2743
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2744
        "/ 39in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2745
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2746
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2747
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2748
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2749
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2750
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2751
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2752
            2r10101011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2753
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2754
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2755
        "/ 40in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2756
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2757
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2758
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2759
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2760
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2761
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2762
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2763
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2764
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2765
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2766
        "/ 41in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2767
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2768
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2769
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2770
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2771
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2772
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2773
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2774
            2r11111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2775
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2776
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2777
        "/ 42in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2778
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2779
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2780
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2781
            2r10111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2782
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2783
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2784
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2785
            2r11111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2786
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2787
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2788
        "/ 43in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2789
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2790
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2791
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2792
            2r10111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2793
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2794
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2795
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2796
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2797
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2798
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2799
        "/ 44in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2800
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2801
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2802
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2803
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2804
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2805
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2806
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2807
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2808
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2809
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2810
        "/ 45in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2811
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2812
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2813
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2814
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2815
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2816
            2r11111110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2817
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2818
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2819
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2820
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2821
        "/ 46in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2822
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2823
          #[2r11101111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2824
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2825
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2826
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2827
            2r11111110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2828
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2829
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2830
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2831
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2832
        "/ 47in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2833
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2834
          #[2r11101111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2835
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2836
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2837
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2838
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2839
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2840
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2841
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2842
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2843
        "/ 48in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2844
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2845
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2846
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2847
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2848
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2849
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2850
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2851
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2852
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2853
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2854
        "/ 49in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2855
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2856
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2857
            2r01110101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2858
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2859
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2860
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2861
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2862
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2863
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2864
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2865
        "/ 50in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2866
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2867
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2868
            2r01110101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2869
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2870
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2871
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2872
            2r01010111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2873
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2874
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2875
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2876
        "/ 51in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2877
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2878
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2879
            2r01110101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2880
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2881
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2882
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2883
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2884
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2885
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2886
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2887
        "/ 52in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2888
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2889
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2890
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2891
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2892
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2893
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2894
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2895
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2896
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2897
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2898
        "/ 53in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2899
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2900
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2901
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2902
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2903
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2904
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2905
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2906
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2907
            2r11010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2908
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2909
        "/ 54in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2910
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2911
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2912
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2913
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2914
            2r01011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2915
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2916
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2917
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2918
            2r11010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2919
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2920
        "/ 55in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2921
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2922
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2923
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2924
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2925
            2r11011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2926
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2927
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2928
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2929
            2r11010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2930
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2931
        "/ 56in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2932
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2933
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2934
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2935
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2936
            2r11011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2937
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2938
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2939
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2940
            2r11011101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2941
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2942
        "/ 57in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2943
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2944
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2945
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2946
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2947
            2r11011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2948
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2949
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2950
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2951
            2r11111101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2952
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2953
        "/ 58in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2954
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2955
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2956
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2957
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2958
            2r11011111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2959
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2960
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2961
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2962
            2r11111101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2963
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2964
        "/ 59in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2965
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2966
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2967
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2968
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2969
            2r11011111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2970
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2971
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2972
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2973
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2974
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2975
        "/ 60in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2976
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2977
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2978
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2979
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2980
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2981
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2982
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2983
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2984
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2985
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2986
        "/ 61in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2987
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2988
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2989
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2990
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2991
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2992
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2993
            2r01111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2994
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2995
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2996
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2997
        "/ 62in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2998
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2999
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3000
            2r11110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3001
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3002
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3003
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3004
            2r01111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3005
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3006
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3007
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3008
        "/ 63in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3009
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3010
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3011
            2r11110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3012
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3013
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3014
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3015
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3016
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3017
            2r11111111]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3018
     )
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3019
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3020
    "Modified: 23.4.1996 / 13:31:50 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3021
    "Created: 11.6.1996 / 15:34:29 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3022
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3023
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3024
ditherGrayFor:fraction on:aDevice into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3025
    "get a dither form or colorId for a brightness value.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3026
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3027
     Returns 2 values (either color or ditherForm) through aBlock."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3028
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3029
    |d nGray grayBelow scaledGrey scaledGray1 scaledGray2 clr1 clr2 newFraction step|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3030
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3031
    d := aDevice depth.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3032
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3033
    "/ special code for b&w displays
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3034
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3035
    d == 1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3036
        aDevice blackpixel == 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3037
            clr1 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3038
            clr2 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3039
            newFraction := fraction.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3040
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3041
            clr1 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3042
            clr2 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3043
            newFraction := 1 - fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3044
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3045
    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3046
        "/ special code for 2-plane displays (NeXT)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3047
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3048
        d == 2 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3049
            fraction <= 0.01 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3050
                clr1 := Black exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3051
            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3052
                (fraction between:0.32 and:0.34) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3053
                    clr1 := (Color gray:33) exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3054
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3055
                    (fraction between:0.66 and:0.68) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3056
                        clr1 := (Color gray:67) exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3057
                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3058
                        fraction >= 0.99 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3059
                            clr1 := White exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3060
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3061
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3062
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3063
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3064
            clr1 notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3065
                ^ aBlock value:clr1 value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3066
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3067
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3068
            (fraction between:0 and:0.33) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3069
                clr1 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3070
                clr2 := Color gray:33.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3071
            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3072
                (fraction between:0.34 and:0.66) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3073
                    clr1 := Color gray:33.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3074
                    clr2 := Color gray:67.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3075
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3076
                    clr1 := Color gray:67.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3077
                    clr2 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3078
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3079
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3080
            scaledGray1 := clr1 scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3081
            scaledGray2 := clr2 scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3082
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3083
            scaledGrey := (MaxValue * fraction) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3084
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3085
            newFraction := (scaledGrey - scaledGray1) asFloat / (scaledGray2 - scaledGray1).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3086
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3087
            nGray := (1 bitShift:d) - 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3088
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3089
            "/ scale greyValue into grey levels
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3090
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3091
            grayBelow := (fraction * nGray) truncated.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3092
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3093
            grayBelow < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3094
                ^ Color black exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3095
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3096
            grayBelow >= nGray ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3097
                ^ Color white exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3098
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3099
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3100
            scaledGrey := (MaxValue * fraction) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3101
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3102
            step := MaxValue // nGray.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3103
            scaledGray1 := grayBelow * step.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3104
            scaledGray2 := scaledGray1 + step.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3105
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3106
            clr1 := Color scaledGray:scaledGray1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3107
            clr2 := Color scaledGray:scaledGray2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3108
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3109
            "/ scale remainder in between low..high
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3110
            newFraction := (scaledGrey - scaledGray1) asFloat / (scaledGray2 - scaledGray1).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3111
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3112
            "/ dither between those two colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3113
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3114
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3115
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3116
    clr1 := clr1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3117
    clr2 := clr2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3118
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3119
    (clr1 isNil or:[clr2 isNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3120
        "/ fall back to b&w dither
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3121
        aDevice blackpixel == 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3122
            clr1 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3123
            clr2 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3124
            newFraction := fraction.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3125
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3126
            clr1 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3127
            clr2 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3128
            newFraction := 1 - fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3129
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3130
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3131
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3132
    ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3133
        monoDitherFor:newFraction 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3134
        between:clr1 and:clr2
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3135
        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3136
        into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3137
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3138
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3139
     Color basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3140
        ditherGrayFor:0.5 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3141
        on:Display 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3142
        into:[:clr :form | clr notNil ifTrue:[clr inspect].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3143
                           form notNil ifTrue:[(form magnifiedBy:16) inspect].]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3144
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3145
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3146
     Color basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3147
        ditherGrayFor:0.25 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3148
        on:Display 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3149
        into:[:clr :form | clr notNil ifTrue:[clr inspect].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3150
                           form notNil ifTrue:[(form magnifiedBy:16) inspect].]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3151
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3152
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3153
    "Created: 3.5.1997 / 10:59:57 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3154
    "Modified: 3.5.1997 / 11:05:09 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3155
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3156
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3157
ditherRed:rV green:gV blue:bV on:aDevice into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3158
    "get a dither form or colorId for an rgb value.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3159
     Returns 2 values (either color or ditherForm) through
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3160
     aBlock.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3161
     This code is just a minimum of what is really needed,
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3162
     and needs much more work. Currently only some special cases
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3163
     are handled"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3164
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3165
    |rh rl rs 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3166
     lowL hiL lowValL hiValL lowS hiS lowValS hiValS lowH hiH lowValH hiValH d|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3167
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3168
    "get hls (since we dither anyway, round them a bit"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3169
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3170
    Color withHLSFromScaledRed:rV scaledGreen:gV scaledBlue:bV do:[:h :l :s |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3171
        h notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3172
            rh := (h * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3173
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3174
        rl := (l * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3175
        rs := (s * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3176
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3177
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3178
    rh isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3179
        "achromatic,  dither between achromatic colors"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3180
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3181
        lowL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3182
        hiL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3183
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3184
        "find the 2 bounding colors"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3185
        aDevice deviceColors do:[:aColor |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3186
            aColor colorId notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3187
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3188
                Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:h :l :s |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3189
                    | cl |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3190
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3191
                    h isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3192
                        cl := (l * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3193
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3194
                        cl > rl ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3195
                            hiL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3196
                                hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3197
                                hiValL := cl.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3198
                            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3199
                                cl < hiValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3200
                                    hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3201
                                    hiValL := cl.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3202
                                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3203
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3204
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3205
                            lowL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3206
                                lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3207
                                lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3208
                            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3209
                                cl > lowValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3210
                                    lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3211
                                    lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3212
                                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3213
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3214
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3215
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3216
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3217
            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3218
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3219
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3220
        (lowL notNil and:[hiL notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3221
            ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3222
                monoDitherFor:1.0 / (hiValL - lowValL) * (rl - lowValL)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3223
                between:lowL and:hiL 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3224
                on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3225
                into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3226
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3227
        "cannot happen, should always find at least black and white"
2071
20a74671b3e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2062
diff changeset
  3228
        'Color [info]: oops - color to dither is not bound by b&w' infoPrintCR.
20a74671b3e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2062
diff changeset
  3229
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3230
        ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3231
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3232
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3233
    "chromatic case"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3234
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3235
    aDevice hasColors ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3236
        "no chance, return nil values"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3237
        ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3238
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3239
    (Red isNil or:[Green isNil or:[Blue isNil]]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3240
        "if we where not able to get primary colors: no chance"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3241
        ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3242
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3243
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3244
    "try to find two bounding colors with same hue and saturation;
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3245
     dither on light between those"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3246
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3247
    lowL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3248
    hiL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3249
    lowS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3250
    hiS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3251
    lowH := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3252
    hiH := nil.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3253
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3254
    aDevice deviceColors do:[:aColor |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3255
        aColor colorId notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3256
            Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:h :l :s |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3257
                | cl ch cs|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3258
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3259
                h notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3260
                   ch := (h * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3261
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3262
                   ch := nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3263
                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3264
                cl := (l * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3265
                cs := (s * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3266
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3267
                ((ch = rh) and:[cs = rs]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3268
                    "found a color with same saturation and same hue, keep for light"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3269
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3270
                    cl > rl ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3271
                        hiL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3272
                            hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3273
                            hiValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3274
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3275
                            cl < hiValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3276
                                hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3277
                                hiValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3278
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3279
                        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3280
                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3281
                        lowL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3282
                            lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3283
                            lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3284
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3285
                            cl > lowValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3286
                                lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3287
                                lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3288
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3289
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3290
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3291
                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3292
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3293
                (((ch = rh) or:[ch == nil]) and:[cl = rl]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3294
                    "found a color with same light and same hue, keep for saturation"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3295
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3296
                    cs > rs ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3297
                        hiS isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3298
                            hiS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3299
                            hiValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3300
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3301
                            cs < hiValS ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3302
                                hiS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3303
                                hiValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3304
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3305
                        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3306
                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3307
                        lowS isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3308
                            lowS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3309
                            lowValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3310
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3311
                            cs > lowValS ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3312
                                lowS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3313
                                lowValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3314
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3315
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3316
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3317
                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3318
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3319
                rh notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3320
                    cl = rl ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3321
                        cs = rs ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3322
                            ch notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3323
                                d := (ch - rh) abs.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3324
                                d > 300 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3325
                                    rh > 180 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3326
                                        ch := ch + 360
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3327
                                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3328
                                        ch := ch - 360
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3329
                                    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3330
                                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3331
                                ch > rh ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3332
                                    hiH isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3333
                                        hiH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3334
                                        hiValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3335
                                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3336
                                        ch < hiValH ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3337
                                            hiH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3338
                                            hiValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3339
                                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3340
                                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3341
                                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3342
                                    lowH isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3343
                                        lowH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3344
                                        lowValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3345
                                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3346
                                        ch > lowValH ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3347
                                            lowH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3348
                                            lowValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3349
                                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3350
                                    ] 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3351
                                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3352
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3353
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3354
                    ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3355
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3356
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3357
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3358
    ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3359
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3360
    "found bounds for light ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3361
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3362
    lowL notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3363
        rl = lowValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3364
            ^ aBlock value:lowL value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3365
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3366
        hiL notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3367
            ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3368
                monoDitherFor:1.0 / (hiValL - lowValL) / (rl - lowValL)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3369
                between:lowL and:hiL 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3370
                on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3371
                into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3372
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3373
        "found bound for light - dither with white"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3374
        ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3375
            monoDitherFor:1.0 / (100 - lowValL) / (rl - lowValL)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3376
            between:lowL and:White 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3377
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3378
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3379
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3380
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3381
    "found bound for light - dither with black"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3382
    hiL notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3383
        ^ self  
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3384
            monoDitherFor:1.0 / (hiValL) / (rl)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3385
            between:Black and:hiL 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3386
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3387
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3388
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3389
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3390
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3391
    "found bounds for saturation?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3392
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3393
    (lowS notNil and:[hiS notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3394
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3395
        'saturation dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3396
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3397
        ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3398
            monoDitherFor:1.0 / (hiValS - lowValS) / (rs - lowValS)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3399
            between:lowS and:hiS
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3400
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3401
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3402
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3403
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3404
    "found bounds for hue ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3405
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3406
    (lowH notNil and:[hiH notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3407
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3408
        'hue dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3409
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3410
        hiValH < lowValH ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3411
            hiValH := hiValH + 360
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3412
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3413
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3414
        d := hiValH - lowValH.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3415
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3416
        ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3417
            monoDitherFor:1.0 / (d / (rh - lowValH))
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3418
            between:lowH and:hiH 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3419
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3420
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3421
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3422
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3423
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3424
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3425
    "Modified: 3.5.1997 / 10:58:54 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3426
    "Created: 3.5.1997 / 11:02:03 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3427
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3428
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3429
fixDitherRed:redVal green:greenVal blue:blueVal on:aDevice into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3430
    "get a dither form for an rgb value.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3431
     Returns 2 values (either color or ditherForm) through aBlock.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3432
     This code uses the table of preallocated fix-colors to find
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3433
     dither colors."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3434
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3435
    | 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3436
     nR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3437
     nG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3438
     nB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3439
     hR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3440
     hG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3441
     hB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3442
     eR eG eB
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3443
     rI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3444
     gI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3445
     bI  "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3446
     idx "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3447
     f clr
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3448
     r    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3449
     g    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3450
     b    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3451
     x1   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3452
     x2   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3453
     step "{ Class: SmallInteger }" 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3454
     lastIdx mx 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3455
     dS   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3456
     cube|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3457
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3458
    (cube := aDevice fixColors) notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3459
        dS := 4.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3460
4785
ffb3b0caceb8 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4772
diff changeset
  3461
        f := Form width:dS height:dS depth:(aDevice depth) onDevice:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3462
        f initGC.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3463
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3464
        mx := MaxValue asFloat.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3465
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3466
        nR := aDevice numFixRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3467
        nG := aDevice numFixGreen.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3468
        nB := aDevice numFixBlue.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3469
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3470
        hR := nR // 2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3471
        hG := nG // 2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3472
        hB := nB // 2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3473
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3474
        eR := eG := eB := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3475
        r := redVal.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3476
        g := greenVal.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3477
        b := blueVal.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3478
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3479
        step := -1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3480
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3481
        0 to:dS-1 do:[:y |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3482
            step == -1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3483
                x1 := 0. x2 := dS-1. step := 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3484
            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3485
                x1 := dS-1. x2 := 0. step := -1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3486
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3487
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3488
            x1 to:x2 by:step do:[:x |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3489
                "/ the nearest along the grid
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3490
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3491
                r := redVal + eR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3492
                r > MaxValue ifTrue:[r := MaxValue]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3493
                             ifFalse:[r < 0 ifTrue:[r := 0]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3494
                g := greenVal + eG.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3495
                g > MaxValue ifTrue:[g := MaxValue]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3496
                             ifFalse:[g < 0 ifTrue:[g := 0]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3497
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3498
                b := blueVal + eB.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3499
                b > MaxValue ifTrue:[b := MaxValue]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3500
                             ifFalse:[b < 0 ifTrue:[b := 0]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3501
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3502
                rI := (r * (nR-1) + hR / mx) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3503
                gI := (g * (nG-1) + hG / mx) rounded .
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3504
                bI := (b * (nB-1) + hB / mx) rounded .
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3505
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3506
                idx := (((rI * nG) + gI) * nB + bI) + 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3507
                clr := (cube at:idx) exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3508
                lastIdx isNil ifTrue:[lastIdx := idx]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3509
                ifFalse:[lastIdx ~~ idx ifTrue:[lastIdx := -1]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3510
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3511
                f foreground:clr.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3512
                f displayPointX:x y:y.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3513
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3514
                eR := r  - clr scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3515
                eG := g  - clr scaledGreen.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3516
                eB := b  - clr scaledBlue.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3517
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3518
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3519
        f releaseGC.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3520
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3521
        lastIdx ~~ -1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3522
            ^ aBlock value:clr value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3523
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3524
        ^ aBlock value:nil value:f
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3525
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3526
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3527
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3528
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3529
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3530
    "Modified: 11.7.1996 / 18:30:28 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3531
    "Created: 3.5.1997 / 11:03:18 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3532
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3533
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3534
monoDitherFor:fraction between:color1 and:color2 on:aDevice into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3535
    "get a dither form or colorId for dithering between 2 colors.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3536
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3537
     Returns 2 values (either color or ditherForm) through aBlock."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3538
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3539
    |form c1 c2 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3540
     index "{ Class:SmallInteger }"|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3541
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3542
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3543
    "/ having forms with: [1 .. 63] of 64 pixels (see Form),
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3544
    "/ we get dithers for: 1/64, 2/64, ... 63/64
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3545
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3546
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3547
    index := (fraction * 64) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3548
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3549
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3550
    index < 1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3551
        ^ aBlock value:c1 value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3552
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3553
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3554
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3555
    index >= 64 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3556
        ^ aBlock value:c2 value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3557
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3558
4772
be4524221fa7 Use Form class>>#width:height:fromArray:onDevice: instead of obsolete
Stefan Vogel <sv@exept.de>
parents: 4749
diff changeset
  3559
    form := Form width:8 height:8 fromArray:(DitherBits at:index) onDevice:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3560
    form colorMap:(Array with:c1 with:c2).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3561
    ^ aBlock value:nil value:form
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3562
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3563
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3564
     Color basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3565
        monoDitherFor:(MaxValue // 2)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3566
        between:Color black 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3567
        and:Color white 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3568
        on:Display 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3569
        into:[:clr :dither | clr inspect. dither inspect]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3570
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3571
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3572
    "Created: 3.5.1997 / 10:55:06 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3573
    "Modified: 3.5.1997 / 11:05:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3574
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3575
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3576
!Color class methodsFor:'queries'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3577
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3578
constantNames
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3579
    "return names known as instance creation messages"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3580
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3581
    ^ #(white black 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3582
        grey mediumGrey veryLightGrey lightGrey darkGrey veryDarkGrey
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3583
        red green blue cyan yellow pink orange magenta)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3584
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3585
    "Modified: 2.5.1996 / 11:34:05 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3586
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3587
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3588
scalingValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3589
    "ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3590
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3591
    ^ MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3592
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3593
    "Created: 2.5.1996 / 11:30:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3594
    "Modified: 11.7.1996 / 21:42:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3595
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3596
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3597
!Color class methodsFor:'special instance creation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3598
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3599
nearestColorRed:r green:g blue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3600
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3601
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3602
     If there is one, return it; nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3603
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3604
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3605
     vector distance (which may not be the best possible solution)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3606
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3607
    ^ self
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3608
        nearestColorScaledRed:(r * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3609
                  scaledGreen:(g * MaxValue // 100) 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3610
                   scaledBlue:(b * MaxValue // 100) 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3611
                           on:aDevice 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3612
                           in:colors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3613
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3614
    "Modified: 11.6.1996 / 18:04:55 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3615
    "Created: 14.6.1996 / 20:05:13 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3616
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3617
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3618
nearestColorScaledRed:r scaledGreen:g scaledBlue:b inCube:aColorCube numRed:nRed numGreen:nGreen numBlue:nBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3619
    "return a color with rgb values same or near r/g/b in a given
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3620
     collection, containing colors from a colorCube.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3621
     This is used with preallocated fixColors and is quite fast 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3622
     (no need to search)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3623
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3624
    |sR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3625
     sG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3626
     sB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3627
     idx "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3628
     nR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3629
     nG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3630
     nB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3631
     rI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3632
     gI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3633
     bI  "{ Class: SmallInteger }"|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3634
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3635
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3636
     round to the step given by FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3637
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3638
    nR := nRed.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3639
    nG := nGreen.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3640
    nB := nBlue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3641
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3642
    sR := MaxValue // (nR - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3643
    sG := MaxValue // (nG - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3644
    sB := MaxValue // (nB - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3645
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3646
    rI := (r + (sR // 2)) // sR.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3647
    gI := (g + (sG // 2)) // sG.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3648
    bI := (b + (sB // 2)) // sB.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3649
    idx := (((rI * nG) + gI) * nB + bI) + 1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3650
    ^ aColorCube at:idx
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3651
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3652
    "Modified: 11.7.1996 / 17:52:46 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3653
    "Created: 11.7.1996 / 18:20:13 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3654
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3655
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3656
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3657
    "return a device color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3658
     same or near r/g/b, if there is one, nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3659
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3660
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3661
     vector distance (which may not be the best possible solution)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3662
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3663
    |cube|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3664
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3665
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3666
     if there are preallocated colors, things are much easier ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3667
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3668
    (cube := aDevice fixColors) notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3669
        ^ self 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3670
            nearestColorScaledRed:r 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3671
            scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3672
            scaledBlue:b
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3673
            inCube:cube
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3674
            numRed:(aDevice numFixRed)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3675
            numGreen:(aDevice numFixGreen)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3676
            numBlue:(aDevice numFixBlue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3677
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3678
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3679
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3680
     search in existing colors ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3681
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3682
    ^ self 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3683
        nearestColorScaledRed:r 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3684
        scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3685
        scaledBlue:b 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3686
        on:aDevice 
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3687
        in:aDevice deviceColors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3688
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3689
    "Created: 14.6.1996 / 20:11:18 / cg"
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3690
    "Modified: 24.2.1997 / 18:17:51 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3691
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3692
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3693
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3694
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3695
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3696
     If there is one, return it; nil otherwise."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3697
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3698
    |delta minDelta bestSoFar|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3699
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3700
    minDelta := 9999999.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3701
1619
4a7dbd25c588 handle the case where not even r/g/b primaries can be allocated
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3702
    colors isNil ifTrue:[^ nil].
4a7dbd25c588 handle the case where not even r/g/b primaries can be allocated
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3703
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3704
    colors do:[:aColor |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3705
        |cr cg cb|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3706
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3707
        (aDevice isNil 
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3708
        or:[(aColor graphicsDevice == aDevice)
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3709
            and:[aColor colorId notNil]]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3710
                delta := aColor deltaFromScaledRed:r scaledGreen:g scaledBlue:b.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3711
                delta < minDelta ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3712
                    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3713
                     an exact fit - no need to continue search
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3714
                    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3715
                    delta == 0 ifTrue:[^ aColor].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3716
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3717
                    bestSoFar := aColor.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3718
                    minDelta := delta
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3719
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3720
            ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3721
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3722
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3723
    ^ bestSoFar
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3724
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3725
    "Created: / 11.6.1996 / 18:02:12 / cg"
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3726
    "Modified: / 28.7.1998 / 20:40:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3727
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3728
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3729
quickNearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3730
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3731
     same or near r/g/b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3732
     This looks for primary colors only and is thus faster
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3733
     than the general nearestColor search (slightly uglier though)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3734
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3735
    |cube|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3736
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3737
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3738
     if there are preallocated colors, things are much easier ...
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3739
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3740
    (cube := aDevice fixColors) notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3741
        ^ self 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3742
            nearestColorScaledRed:r 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3743
            scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3744
            scaledBlue:b 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3745
            inCube:cube
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3746
            numRed:(aDevice numFixRed)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3747
            numGreen:(aDevice numFixGreen)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3748
            numBlue:(aDevice numFixBlue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3749
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3750
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3751
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3752
     search in existing colors ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3753
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3754
    ^ self nearestColorScaledRed:r 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3755
                     scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3756
                      scaledBlue:b 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3757
                        on:aDevice 
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3758
                        in:(aDevice availableDitherColors)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3759
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3760
    "Created: 14.6.1996 / 20:13:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3761
    "Modified: 11.7.1996 / 18:20:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3762
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3763
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3878
diff changeset
  3764
!Color methodsFor:'Compatibility-ST80'!
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3765
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3766
asDevicePaintOn:aDevice
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3767
    "ST-80 compatibility: an alias for on:.
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3768
     create a new Color representing the same color as
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3769
     myself on aDevice; if one already exists, return the one"
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3770
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  3771
    ^ self onDevice:aDevice
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3772
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3773
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3774
asHiliteColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3775
    "same as lightened - for ST-80 compatibility"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3776
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3777
    ^ self lightened
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3778
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3779
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3780
asShadowColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3781
    "same as darkened - for ST-80 compatibility"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3782
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3783
    ^ self darkened
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3784
! !
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3785
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3878
diff changeset
  3786
!Color methodsFor:'Compatibility-Squeak'!
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3787
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3788
alphaMixed: proportion with: aColor 
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3789
    "Answer this color mixed with the given color. The proportion, a number 
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3790
     between 0.0 and 1.0, determines what what fraction of the receiver to  
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3791
     use in the mix. For example, 0.9 would yield a color close to the  
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3792
     receiver. This method uses RGB interpolation; HSV interpolation can lead 
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3793
     to surprises.  Mixes the alphas (for transparency) also."
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3794
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3795
    | frac1 frac2 |
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3796
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3797
    frac1 := proportion asFloat min: 1.0 max: 0.0.
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3798
    frac2 := 1.0 - frac1.
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3799
    ^ Color
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3800
        r: ((red * frac1) + (aColor scaledRed * frac2)) / MaxValue 
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3801
        g: ((green * frac1) + (aColor scaledGreen * frac2)) / MaxValue
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3802
        b: ((blue * frac1) + (aColor scaledBlue * frac2)) / MaxValue
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3803
        alpha: (self alpha * frac1) + (aColor alpha * frac2)
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3804
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3805
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3806
     (Color r:1 g:0 b:0 alpha:1) alphaMixed:0.5 with:(Color r:1 g:0 b:0 alpha:1)  
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3807
     (Color r:1 g:0 b:0 alpha:0.5) alphaMixed:0.5 with:(Color r:0 g:1 b:0 alpha:0.5)   
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3808
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3809
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3810
    "Created: / 06-06-2007 / 10:53:25 / cg"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3811
!
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3812
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3813
bitPatternForDepth: depth
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3814
    "Return a Bitmap, possibly containing a stipple pattern, 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3815
     that best represents this color at the given depth. 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3816
     BitBlt calls this method to convert colors into Bitmaps. 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3817
     The resulting Bitmap may be multiple words to represent a stipple 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3818
     pattern of several lines.  "
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3819
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3820
    "See also:      
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3821
        pixelValueAtDepth:      -- value for single pixel
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3822
        pixelWordAtDepth:       -- a 32-bit word filled with the pixel value"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3823
    "Details: The pattern for the most recently requested depth is cached."
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3824
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3825
^ self.
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3826
"/    depth == cachedDepth ifTrue: [^ cachedBitPattern].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3827
"/    cachedDepth _ depth.
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3828
"/
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3829
"/    depth > 2 ifTrue: [^ cachedBitPattern _ Bitmap with: (self pixelWordForDepth: depth)].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3830
"/    depth = 1 ifTrue: [^ cachedBitPattern _ self halfTonePattern1].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3831
"/    depth = 2 ifTrue: [^ cachedBitPattern _ self halfTonePattern2].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3832
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3833
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3834
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3835
colorForInsets
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3836
    ^ self
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3837
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3838
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3839
darker
3030
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3840
    "return a new color, which is darker than the receiver.
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3841
     Almost the same as darkened for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3842
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3843
    ^ self mixed:0.8333 with:Black
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3844
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3845
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3846
     (Color red) darker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3847
     (Color red) muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3848
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3849
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3850
    "Modified: 11.6.1996 / 18:10:37 / cg"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3851
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3852
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3853
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3854
lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3855
    "return a new color, which is slightly lighter than the receiver.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3856
     Almost the same as lightened for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3857
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3858
    ^ self mixed:0.8333 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3859
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3860
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3861
     (Color red) 
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3862
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3863
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3864
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3865
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3866
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3867
    "Modified: 11.6.1996 / 18:10:49 / cg"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3868
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3869
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3870
muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3871
    "return a new color, which is much darker than the receiver.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3872
     Added for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3873
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3874
    ^ self mixed:0.233 with:Black
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3875
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3876
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3877
     (Color red) darker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3878
     (Color red) muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3879
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3880
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3881
    "Modified: 11.6.1996 / 18:10:49 / cg"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3882
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3883
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3884
muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3885
    "return a new color, which is much lighter than the receiver.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3886
     Added for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3887
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3888
    ^ self mixed:0.233 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3889
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3890
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3891
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3892
     (Color red) mixed:0.833 with:Color white
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3893
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3894
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3895
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3896
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3897
    "Modified: 11.6.1996 / 18:10:49 / cg"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3898
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3899
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  3900
newTileMorphRepresentative
3727
3cbc55b7db41 slightly changed
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
  3901
        ^ ColorTileMorph new colorSwatchColor: self
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3902
!
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  3903
4203
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3904
privateBlue
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3905
    "Squeak compatibility:
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3906
     return the blue components value mapped to 0..MaxValue"
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3907
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3908
    ^ self scaledBlue
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3909
!
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3910
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3911
privateGreen
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3912
    "Squeak compatibility:
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3913
     return the green components value mapped to 0..MaxValue"
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3914
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3915
    ^ self scaledGreen
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3916
!
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3917
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3918
privateRed
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3919
    "Squeak compatibility:
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3920
     return the red components value mapped to 0..MaxValue"
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3921
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3922
    ^ self scaledRed
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3923
!
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3924
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3925
scaledPixelValue32
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3926
    ^ (self redByte bitShift:16)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3927
      + (self greenByte bitShift:8)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3928
      + (self blueByte)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3929
      + (self alphaByte bitShift:24)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3930
!
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3931
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3932
veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3933
    "return a new color, which is very much lighter than the receiver.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3934
     Added for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3935
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3936
    ^ self mixed:0.1165 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3937
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3938
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3939
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3940
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3941
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3942
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3944
    "Modified: 11.6.1996 / 18:10:49 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3945
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3946
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3947
wheel:thisMany
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3948
    "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.  "
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3949
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3950
    | sat bri hue step c |
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3951
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3952
    thisMany = 1 ifTrue: [^ Array with: self].
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3953
    sat := self saturation / 100.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3954
    bri := self brightness.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3955
    hue := self hue.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3956
    step := 360.0 / thisMany.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3957
    ^ (1 to: thisMany) collect: [:num |
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3958
            c := Color h: hue s: sat v: bri.  "hue is taken mod 360"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3959
            hue := hue + step.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3960
            c].
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3961
! !
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3962
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3963
!Color methodsFor:'accessing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3964
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3965
alpha
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3966
    "return the alpha value (0..1),
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3967
     where 0 is completely transparent and 1 is completely opaque"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3968
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3969
    ^ 1.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3970
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3971
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3972
alphaByte
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3973
    "return the alpha byte-value (0..255),
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3974
     where 0 is completely transparent and 255 is completely opaque"
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3975
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3976
    ^ 255.
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3977
!
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  3978
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3979
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3980
    "return the blue component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3981
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3982
    (blue isNil and:[colorId notNil]) ifTrue:[
4315
20e950100947 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4244
diff changeset
  3983
        device isNil ifTrue:[^ 0].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3984
        device getRGBFrom:colorId into:[:r :g :b | ^ b].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3985
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3986
    ^ blue * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3987
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3988
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3989
blueByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3990
    "return the blue components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3991
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3992
    blue isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3993
    ^ blue * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3994
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3995
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3996
     Color red blueByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3997
     Color blue blueByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3998
     Color green blueByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3999
     Color black blueByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4000
     Color grey blueByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4001
     Color white blueByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4002
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4003
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4004
    "Created: / 7.6.1996 / 18:30:25 / cg"
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4005
    "Modified: / 26.7.1998 / 12:31:44 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4006
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4007
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4008
colorId
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4009
    "return the device-dependent color-id"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4010
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4011
    colorId notNil ifTrue:[^ colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4012
    replacementColor notNil ifTrue:[^ replacementColor colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4013
    ^ nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4014
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4015
    "Modified: 17.1.1997 / 00:03:18 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4016
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4017
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4018
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4019
    "return the cyan component in percent [0..100] in cmy color space"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4020
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4021
    ^ 100 - self red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4022
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4023
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4024
    "Created: 11.6.1996 / 18:30:00 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4025
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4026
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4027
device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4028
    "return the device I am associated to"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4029
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4030
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4031
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4032
    "Modified: 23.4.1996 / 13:36:42 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4033
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4034
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4035
deviceBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4036
    "return the actual value of the blue component in percent."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4037
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4038
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4039
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4040
    device getRGBFrom:colorId into:[:r :g :b | v := b].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4041
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4042
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4043
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4044
deviceGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4045
    "return the actual value of the green component in percent.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4046
     (usually 16bit in X; but could be different on other systems)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4047
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4048
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4049
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4050
    device getRGBFrom:colorId into:[:r :g :b | v := g].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4051
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4052
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4053
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4054
deviceRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4055
    "return the actual value of the red component in percent."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4056
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4057
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4058
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4059
    device getRGBFrom:colorId into:[:r :g :b | v := r].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4060
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4061
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4062
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4063
     (Color yellow on:Display) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4064
     (Color yellow on:aPrinterPage) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4065
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4066
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4067
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4068
ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4069
    "return the form to dither the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4070
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4071
    ^ ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4072
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4073
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4074
graphicsDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4075
    "same as #device, for ST-80 compatibility naming.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4076
     Return the device I am associated with."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4077
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4078
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4079
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4080
    "Created: 28.5.1996 / 18:39:27 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4081
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4082
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4083
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4084
    "return the green component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4085
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4086
    (green isNil and:[colorId notNil]) ifTrue:[
4315
20e950100947 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4244
diff changeset
  4087
        device isNil ifTrue:[^ 0].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4088
        device getRGBFrom:colorId into:[:r :g :b | ^ g].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4089
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4090
    ^ green * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4091
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4092
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4093
greenByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4094
    "return the green components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4095
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4096
    green isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4097
    ^ green * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4098
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4099
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4100
     Color red greenByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4101
     Color blue greenByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4102
     Color green greenByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4103
     Color black greenByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4104
     Color grey greenByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4105
     Color white greenByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4106
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4107
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4108
    "Modified: / 26.7.1998 / 12:31:33 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4109
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4110
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4111
hue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4112
    "return the hue (in hue/light/saturation model) in degrees [0..360]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4113
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4114
    |r g b h|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4115
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4116
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4117
        device getRGBFrom:colorId into:[:xr :xg :xb |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4118
            r := xr.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4119
            g := xg.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4120
            b := xb.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4121
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4122
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4123
        r := self red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4124
        g := self green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4125
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4126
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4127
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4128
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4129
        h := xh
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4130
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4131
    ^ h
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4132
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4133
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4134
     Color yellow hue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4135
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4136
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4137
    "Modified: 11.6.1996 / 17:14:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4138
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4139
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4140
light 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4141
    "return the light (in hue/light/saturation model) in percent [0..100].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4142
     This corresponds to the brightness of the color (if displayed on
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4143
     a b&w television screen)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4144
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4145
    |r g b l|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4146
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4147
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4148
        device getRGBFrom:colorId into:[:xr :xg :xb |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4149
            r := xr.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4150
            g := xg.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4151
            b := xb.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4152
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4153
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4154
        r := self red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4155
        g := self green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4156
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4157
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4158
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4159
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4160
        l := xl
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4161
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4162
    ^ l
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4163
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4164
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4165
     Color yellow light          
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4166
     Color yellow darkened light   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4167
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4168
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4169
    "Modified: 11.6.1996 / 17:15:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4170
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4171
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4172
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4173
    "return the magenta component in percent [0..100] in cmy color space"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4174
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4175
    ^ 100 - self green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4176
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4177
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4178
    "Created: 11.6.1996 / 18:30:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4179
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4180
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4181
privateAlpha
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4182
    "return the internal alpha value (0..255),
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4183
     where 0 is completely transparent and 255 is completely opaque"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4184
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4185
    ^ 255 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4186
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4187
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4188
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4189
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4190
    "return the red component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4191
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4192
    (red isNil and:[colorId notNil]) ifTrue:[
4315
20e950100947 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4244
diff changeset
  4193
        device isNil ifTrue:[^ 0].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4194
        device getRGBFrom:colorId into:[:r :g :b | ^ r].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4195
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4196
    red isNil ifTrue:[^ 0].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4197
    ^ red * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4198
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4199
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4200
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4201
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4202
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4203
    "set r/g/b components in percent. This method will change the color lookup
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4204
     table in pseudocolor devices.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4205
     This is only allowed for writable colors (i.e. those allocated with 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4206
     Color>>variableColorOn: on pseudoColor displays). 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4207
     Using this may make your code unportable, since it depends on a display 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4208
     using palettes (i.e. it will not work on greyScale or b&w displays)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4209
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4210
    ^ self scaledRed:(r * MaxValue // 100)
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4211
           scaledGreen:(g * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4212
           scaledBlue:(b * MaxValue // 100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4213
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4214
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4215
     |c|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4216
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4217
     c := Color variableColorOn:Display.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4218
     c inspect.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4219
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4220
     c red:100 green:0 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4221
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4222
     c red:0 green:100 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4223
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4224
     c red:0 green:0 blue:100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4225
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4226
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4227
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4228
redByte
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4229
    "return the red components value mapped to 0..255;
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4230
     nil if it has no red component."
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4231
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4232
    red isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4233
    ^ red * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4234
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4235
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4236
     Color red redByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4237
     Color blue redByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4238
     Color green redByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4239
     Color black redByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4240
     Color grey redByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4241
     Color white redByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4242
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4243
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4244
    "Modified: / 26.7.1998 / 12:31:22 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4245
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4246
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4247
rgbValue
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4248
    "return the rgb byteValues packed into a 24bit integer;
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4249
     The returned value is composed of r<<16 + g<<8 + b."
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4250
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4251
    |t "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4252
     v "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4253
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4254
    v := red * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4255
    t := green * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4256
    v := (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4257
    t := blue * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4258
    ^ (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4259
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4260
    "
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4261
     Color red rgbValue hexPrintString  
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4262
     Color blue rgbValue hexPrintString  
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4263
     Color green rgbValue hexPrintString   
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4264
     Color black rgbValue hexPrintString   
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4265
     Color grey rgbValue hexPrintString   
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4266
     Color white rgbValue hexPrintString  
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4267
    "
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4268
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4269
    "Modified: 17.10.1997 / 20:00:25 / cg"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4270
!
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4271
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4272
saturation 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4273
    "return the saturation (in hue/light/saturation model) in percent [0..100].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4274
     This corresponds to the saturation setting of a color TV"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4275
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4276
    |r g b s|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4277
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4278
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4279
        device getRGBFrom:colorId into:[:xr :xg :xb |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4280
            r := xr.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4281
            g := xg.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4282
            b := xb.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4283
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4284
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4285
        r := self red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4286
        g := self green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4287
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4288
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4289
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4290
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4291
        s := xs
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4292
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4293
    ^ s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4294
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4295
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4296
     Color yellow saturation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4297
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4298
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4299
    "Modified: 11.6.1996 / 17:15:47 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4300
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4301
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4302
scaledBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4303
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4304
     return the blue components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4305
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4306
    ^ blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4307
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4308
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4309
     Color blue scaledBlue   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4310
     Color black scaledBlue  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4311
     Color grey scaledBlue   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4312
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4313
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4314
    "Modified: 7.6.1996 / 18:32:30 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4315
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4316
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4317
scaledGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4318
    "return the grey intensity scaled to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4319
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4320
    ^ ((red * 3) + (green * 6) + blue) // 10
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4321
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4322
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4323
     Color blue scaledGray   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4324
     Color black scaledGray  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4325
     Color white scaledGray  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4326
     Color grey scaledGray    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4327
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4328
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4329
    "Modified: 11.6.1996 / 14:43:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4330
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4331
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4332
scaledGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4333
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4334
     return the green components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4335
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4336
    ^ green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4337
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4338
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4339
     Color green scaledRed    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4340
     Color black scaledRed  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4341
     Color grey scaledRed   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4342
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4343
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4344
    "Modified: 7.6.1996 / 18:32:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4345
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4346
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4347
scaledRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4348
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4349
     return the red components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4350
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4351
    ^ red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4352
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4353
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4354
     Color red scaledRed    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4355
     Color black scaledRed  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4356
     Color grey scaledRed   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4357
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4358
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4359
    "Modified: 7.6.1996 / 18:32:43 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4360
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4361
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4362
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4363
    "set r/g/b components in 0..MaxValue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4364
     This method will change the color lookup table in pseudocolor devices.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4365
     This is only allowed for writable colors (i.e. those allocated with 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4366
     Color>>variableColorOn: on pseudoColor displays).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4367
     Using this may make your code unportable, since it depends on a display 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4368
     using palettes (i.e. it will not work on greyScale or b&w displays)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4369
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4370
    (colorId isNil or:[red notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4371
        ^ self error:'operation is not allowed for shared colors'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4372
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4373
    device setColor:colorId scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4374
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4375
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4376
writable
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4377
    "return true, if this is a writable colorcell"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4378
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4379
    ^ writable == true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4380
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4381
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4382
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4383
    "return the yellow component in percent [0..100] in cmy color space"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4384
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4385
    ^ 100 - self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4386
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4387
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4388
    "Created: 11.6.1996 / 18:30:20 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4389
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4390
5131
95d91d6d649c care for invalid hue/light/saturation
Claus Gittinger <cg@exept.de>
parents: 5127
diff changeset
  4391
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4392
!Color methodsFor:'comparing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4393
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4394
= aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4395
    "two colors are considered equal, if the color components are;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4396
     independent of the device, the color is on"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4397
2083
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  4398
    aColor == self ifTrue:[^ true].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4399
    aColor isColor ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4400
        (red == aColor scaledRed) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4401
            (green == aColor scaledGreen) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4402
                (blue == aColor scaledBlue) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4403
                    ^ true
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4404
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4405
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4406
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4407
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4408
    ^ false
2083
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  4409
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  4410
    "Modified: / 2.4.1998 / 10:04:39 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4411
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4412
1390
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4413
almostSameAs:aColor
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4414
    "return true, if aColor looks almost the same as the receiver
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4415
     (i.e. the components differ by a small, invisible amount).
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4416
     We assume, that the human eye can distinguish roughly 100 grey levels
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4417
     (which is optimistic ;-);
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4418
     therefore, allow a 1 percent difference in each component for the colors
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4419
     to compare as looking the same."
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4420
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4421
     (self red - aColor red) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4422
     (self green - aColor green) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4423
     (self blue - aColor blue) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4424
     ^ true
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4425
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4426
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4427
      (Color red:10 green:10 blue:10) almostSameAs:(Color red:11 green:11 blue:11)
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4428
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4429
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4430
    "Modified: 28.2.1997 / 12:00:01 / cg"
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4431
!
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4432
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4433
hash
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4434
    "return an integer useful as hash key for the receiver.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4435
     Redefined since = is redefined"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4436
2318
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  4437
    red isNil ifTrue:[
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  4438
        ^ colorId
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  4439
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4440
    ^ red + green + blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4441
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4442
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4443
!Color methodsFor:'converting'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4444
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4445
fromLiteralArrayEncoding:encoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4446
    "read my values from an encoding.
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4447
     The encoding is supposed to be either of the form: 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4448
        (#Color redPart greenPart bluePart)
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4449
     or:
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4450
        (#Color constantColorSymbol)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4451
     This is the reverse operation to #literalArrayEncoding."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4452
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4453
    |clr|
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4454
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4455
    encoding size == 2 ifTrue:[
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4456
        clr := Color perform:(encoding at:2).
2779
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
  4457
        red := clr scaledRed.
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
  4458
        green := clr scaledGreen.
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
  4459
        blue := clr scaledBlue
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4460
    ] ifFalse:[
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4461
        red := ((encoding at:2) / 100.0 * MaxValue) rounded.
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4462
        green := ((encoding at:3) / 100.0 * MaxValue) rounded.
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4463
        blue := ((encoding at:4) / 100.0 * MaxValue) rounded.
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4464
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4465
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4466
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4467
      Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4468
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4469
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4470
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4471
literalArrayEncoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4472
    "encode myself as an array, from which a copy of the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4473
     can be reconstructed with #decodeAsLiteralArray.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4474
     The encoding is: 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4475
        (#Color redPart greenPart bluePart)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4476
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4477
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4478
    ^ Array
4533
0ac6babcc37f Fix comments.
Stefan Vogel <sv@exept.de>
parents: 4422
diff changeset
  4479
        with:self class name
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4480
        with:(red * 100.0 / MaxValue)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4481
        with:(green * 100.0 / MaxValue)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4482
        with:(blue * 100.0 / MaxValue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4483
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4484
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4485
      Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4486
      (Color red:25 green:30 blue:70) literalArrayEncoding 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4487
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4488
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4489
    "Modified: 22.4.1996 / 13:00:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4490
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4491
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4492
!Color methodsFor:'copying'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4493
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4494
postCopy
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4495
    "redefined to clear out any device handles in the copy"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4496
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4497
    device := colorId := ditherForm := replacementColor := nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4498
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4499
    "Modified: 17.1.1997 / 00:03:42 / cg"
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4500
!
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4501
4403
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4342
diff changeset
  4502
postDeepCopy
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4342
diff changeset
  4503
    "redefined to clear out any device handles in the copy"
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4342
diff changeset
  4504
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4342
diff changeset
  4505
    device := colorId := ditherForm := replacementColor := nil
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4342
diff changeset
  4506
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4342
diff changeset
  4507
    "Modified: 17.1.1997 / 00:03:42 / cg"
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4342
diff changeset
  4508
!
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4342
diff changeset
  4509
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4510
skipInstvarIndexInDeepCopy:index
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4511
    index == 4 ifTrue:[
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4512
        ^ true "/ skip device
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4513
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4514
    index == 5 ifTrue:[
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4515
        ^ true "/ skip colorId
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4516
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4517
    index == 6 ifTrue:[
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4518
        ^ true "/ skip ditherForm
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4519
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4520
    index == 7 ifTrue:[
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4521
        ^ true "/ skip replacementColor
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4522
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4523
    ^ false
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4524
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4525
    "
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4526
     (Color black onDevice:Screen current) deepCopy
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4527
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4528
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4529
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4530
!Color methodsFor:'getting a device color'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4531
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4532
exactOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4533
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4534
     myself on aDevice; if one already exists, return the one.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4535
     Do not dither or otherwise approximate the color, but return
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4536
     nil, if the exact color is not available. 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4537
     Used to aquire primary colors for dithering, during startup."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4538
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4539
    |newColor id r g b|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4540
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4541
    "if Iam already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4542
    (device == aDevice and:[ditherForm isNil]) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4543
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4544
    r := red.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4545
    g := green.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4546
    b := blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4547
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4548
    "first look if not already there"
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4549
    newColor := Color existingColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4550
    (newColor notNil and:[newColor ditherForm isNil]) ifTrue:[^ newColor].
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4551
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4552
    r := (r bitAnd:16rFF00) bitOr:(r bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4553
    g := (g bitAnd:16rFF00) bitOr:(g bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4554
    b := (b bitAnd:16rFF00) bitOr:(b bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4555
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4556
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4557
    id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4558
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4559
        "/ this is a kludge: scavenge to free unused colors
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4560
        "/  and try again ...
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4561
        ObjectMemory scavenge; finalize.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4562
        id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4563
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4564
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4565
        "no such color - fail"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4566
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4567
"/      'COLOR: no color for ' infoPrint. self displayString infoPrintCR.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4568
        ^ nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4569
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4570
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4571
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4572
    device isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4573
        device := aDevice.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4574
        colorId := id.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4575
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4576
        aDevice visualType ~~ #TrueColor ifTrue:[
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4577
            "/ Lobby register:self.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4578
            aDevice registerColor:self.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4579
        ].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4580
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4581
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4582
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4583
    "receiver was already associated to another device - need a new color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4584
    newColor := (self class basicNew) setScaledRed:r scaledGreen:g scaledBlue:b device:aDevice.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4585
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4586
    aDevice visualType ~~ #TrueColor ifTrue:[
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4587
        "/ Lobby register:newColor.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4588
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4589
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4590
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4591
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4592
    "Modified: 24.2.1997 / 18:23:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4593
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4594
1856
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4595
exactOrNearestOn:aDevice
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4596
    "get a device color for the receiver, which is either exact
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4597
     or the nearest, but never dithered.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4598
     This can be used for viewBackgrounds, where the exact greyLevel
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4599
     does not matter, but a dithered color is not wanted."
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4600
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4601
    |deviceColor|
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4602
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4603
    deviceColor := self exactOn:aDevice.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4604
    deviceColor isNil ifTrue:[
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4605
        deviceColor := self nearestOn:aDevice
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4606
    ].
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4607
    ^ deviceColor
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4608
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4609
    "Created: 13.8.1997 / 15:25:48 / cg"
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4610
!
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4611
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4612
nearestIn:aColorMap 
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4613
    "return the nearest color in a colorMap"
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4614
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4615
    ^ self class
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4616
        nearestColorScaledRed:(self scaledRed)
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4617
                  scaledGreen:(self scaledGreen)
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4618
                   scaledBlue:(self scaledBlue)
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4619
                           on:nil 
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4620
                           in:aColorMap
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4621
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4622
    "Created: / 28.7.1998 / 20:42:11 / cg"
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4623
!
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4624
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4625
nearestOn:aDevice 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4626
    "create a new Color representing the same color as myself on aDevice; 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4627
     if one already exists, return the one. If no exact match is found,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4628
     search for the nearest match"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4629
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4630
    |newColor id|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4631
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4632
    "if I'am already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4633
    (device == aDevice) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4634
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4635
    "first look if not already there"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4636
    newColor := Color nearestColorScaledRed:red scaledGreen:green scaledBlue:blue on:aDevice.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4637
    newColor notNil ifTrue:[^ newColor].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4638
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4639
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4640
    id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4641
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4642
        "this is a kludge: 
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4643
            scavenge to possuby free unused colors and try again ...
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4644
            this is a compromise: actually a full GC is required here,
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4645
            but that is too expensive.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4646
        "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4647
" "
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4648
        ObjectMemory scavenge; finalize.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4649
        id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4650
" "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4651
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4652
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4653
        "no color - fail"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4654
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4655
        ^ nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4656
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4657
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4658
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4659
    device isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4660
        device := aDevice.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4661
        colorId := id.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4662
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4663
        aDevice visualType ~~ #TrueColor ifTrue:[
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4664
            "/ Lobby register:self.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4665
            aDevice registerColor:self.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4666
        ].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4667
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4668
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4669
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4670
    "receiver was already associated to another device - need a new color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4671
    newColor := (self class basicNew) setScaledRed:red scaledGreen:green sclaedBlue:blue device:aDevice.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4672
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4673
    aDevice visualType ~~ #TrueColor ifTrue:[
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4674
        "/ Lobby register:newColor.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4675
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4676
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4677
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4678
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4679
    "Modified: 24.2.1997 / 18:23:26 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4680
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4681
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4682
on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4683
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4684
     myself on aDevice; if one already exists, return the one"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4685
3623
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4686
    "/ send out a warning: #on: is typically used to create views
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4687
    "/ operating on a model.
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4688
    "/ Please use #onDevice: to avoid confusion.
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4689
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4690
    <resource:#obsolete>
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4691
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4692
    self obsoleteMethodWarning:'use #onDevice:'.
2836
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4693
    ^ self onDevice:aDevice
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4694
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4695
    "Created: / 16.11.1995 / 20:16:42 / cg"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4696
    "Modified: / 8.9.1998 / 17:32:10 / cg"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4697
!
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4698
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4699
onDevice:aDevice
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4700
    "create a new Color representing the same color as
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4701
     myself on aDevice; if one already exists, return the one"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4702
1855
dc59c0c86b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1770
diff changeset
  4703
    |newColor id form 
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4704
     greyV "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4705
     rV    "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4706
     gV    "{ Class: SmallInteger }" 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4707
     bV    "{ Class: SmallInteger }"
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4708
     deviceVisual deviceFixColors deviceDepth|
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4709
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4710
    "/ the most common cases (already allocated) first 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4711
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4712
    colorId notNil ifTrue:[
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4713
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4714
        "/ is someone validating me before drawing on aDevice ?
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4715
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4716
        aDevice notNil ifTrue:[
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4717
            aDevice == device ifTrue:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4718
                ^ self
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4719
            ]
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4720
        ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4721
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4722
        "/ a special case for pseudo-colors (0 and 1 in bitmaps)
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4723
        "/ those have nil r/g/b values, but a nonNil colorId
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4724
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4725
        red isNil ifTrue:[^ self].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4726
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4727
        "/ want to release color ?
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4728
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4729
        (aDevice isNil and:[device notNil]) ifTrue:[
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4730
            "/ trueColor device-colors are not registered
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4731
            device visualType ~~ #TrueColor ifTrue:[
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4732
                device unregisterColor:newColor.
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4733
                device freeColor:colorId
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4734
            ].
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4735
            device := nil.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4736
            colorId := nil.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4737
            ^ self
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4738
        ].
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4739
    ].
2313
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4740
    aDevice isNil ifTrue:[
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4741
        ^ self
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4742
    ].
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4743
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4744
    device == aDevice ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4745
        ditherForm notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4746
            ^ self
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4747
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4748
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4749
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4750
    "/ on high-resolution true-color systems, dont care for dithering and
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4751
    "/ especially freeing colors
2842
dcb1f8eb648f removed obsolete method
Claus Gittinger <cg@exept.de>
parents: 2836
diff changeset
  4752
    "/ (no need to register)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4753
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4754
    deviceDepth := aDevice depth.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4755
    (deviceVisual := aDevice visualType) == #TrueColor ifTrue:[
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4756
        deviceDepth >= 15 ifTrue:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4757
            id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4758
            id notNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4759
                device isNil ifTrue:[
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4760
                    "/ receiver was not associated - do it now & return mySelf
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4761
                    colorId := id.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4762
                    ditherForm := nil.
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4763
                    device := aDevice.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4764
                    ^ self
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4765
                ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4766
                newColor := (self class basicNew) 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4767
                                    setScaledRed:red 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4768
                                    scaledGreen:green 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4769
                                    scaledBlue:blue 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4770
                                    device:aDevice.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4771
                newColor setColorId:id.
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4772
                ^ newColor
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4773
            ] 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4774
        ] 
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4775
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4776
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4777
    "/ round a bit within 1% in red & green, 2% in blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4778
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4779
    rV := red.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4780
    gV := green.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4781
    bV := blue.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4782
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4783
"/    rV := (red / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4784
"/    gV := (green / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4785
"/    bV := (blue / 50.0) rounded * 50.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4786
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4787
    "/ if I am already assigned to that device ...
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4788
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4789
"/    ((device == aDevice) and:[ditherForm notNil]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4790
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4791
"/        "/ mhmh - if I was dithered the last time (not enough colors then)
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4792
"/        "/ try again - maybe some colors were reclaimed in the meanwhile
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4793
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4794
"/        deviceFixColors := aDevice fixColors.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4795
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4796
"/        (deviceFixColors isNil
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4797
"/         and:[RetryAllocation]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4798
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4799
"/             but there is no chance on b&w displays - so don't try
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4800
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4801
"/            aDevice depth > 2 ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4802
"/                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4803
"/                id notNil ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4804
"/                    colorId := id.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4805
"/                    ditherForm := nil.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4806
"/                    device registerColor:self.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4807
"/                ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4808
"/            ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4809
"/        ].
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4810
"/        ^ self
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4811
"/    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4812
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4813
    newColor := Color existingColorScaledRed:rV scaledGreen:gV scaledBlue:bV on:aDevice.
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4814
    newColor notNil ifTrue:[
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4815
        (newColor scaledRed ~~ red
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4816
        or:[newColor scaledGreen ~~ green
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4817
        or:[newColor scaledBlue ~~ blue]]) ifTrue:[
4749
4dbeec6bdb16 changed #onDevice: - more expressive message on Transcript
Stefan Vogel <sv@exept.de>
parents: 4742
diff changeset
  4818
            Transcript showCR:'Color>>#onDevice: got different color'.
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4819
        ].
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4820
        ^ newColor
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4821
    ].
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4822
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4823
    "/ ask that device for the exact color
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4824
    id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4825
    id notNil ifTrue:[
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4826
        device isNil ifTrue:[
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4827
            "/ receiver was not associated - do it now & return mySelf
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4828
            colorId := id.
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4829
            ditherForm := nil.
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4830
            device := aDevice.
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4831
            newColor := self.
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4832
        ] ifFalse:[
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4833
            newColor := (self class basicNew) 
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4834
                                setScaledRed:red 
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4835
                                scaledGreen:green 
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4836
                                scaledBlue:blue 
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4837
                                device:aDevice.
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4838
            newColor setColorId:id.
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4839
        ].
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4840
        id notNil ifTrue:[
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4841
            deviceVisual ~~ #TrueColor ifTrue:[    
2976
3eec8a0c6747 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2975
diff changeset
  4842
                aDevice registerColor:newColor.
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4843
            ]
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4844
        ].
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4845
        ^ newColor
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4846
    ]. 
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4847
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4848
    "/
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4849
    "/ ok, we are either going to dither that color, or look for
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4850
    "/ the nearest.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4851
    "/ if its 'almost' grey, make it grey and round it a bit (1%)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4852
    "/
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4853
    greyV := (3 * red) + (6 * green) + (1 * blue).
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4854
    greyV := (greyV / 1000.0) rounded * 100.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4855
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4856
    "/ allow an error of 1% in red & green, 2% in blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4857
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4858
    ((rV - greyV) abs <= 655                    "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4859
    and:[(gV - greyV) abs <= 655                "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4860
    and:[(bV - greyV) abs <= 1310]]) ifTrue:[   "/ MaxValue // 100 * 2
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4861
        rV := gV := bV := greyV.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4862
    ] ifFalse:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4863
        rV := red. gV := green. bV := blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4864
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4865
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4866
    aDevice hasColors ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4867
        deviceFixColors := aDevice fixColors.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4868
        deviceFixColors isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4869
            "/ ask that device for the exact color
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4870
            id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4871
            id isNil ifTrue:[
2967
88942aca0c7a dont loop when trying to allocate a color
ca
parents: 2962
diff changeset
  4872
                aDevice isOpen ifFalse:[
88942aca0c7a dont loop when trying to allocate a color
ca
parents: 2962
diff changeset
  4873
                    ^ nil
88942aca0c7a dont loop when trying to allocate a color
ca
parents: 2962
diff changeset
  4874
                ].
88942aca0c7a dont loop when trying to allocate a color
ca
parents: 2962
diff changeset
  4875
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4876
                "/ this is a kludge: scavenge to free unused colors
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4877
                "/ and try again ...
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4878
                ObjectMemory scavenge; finalize.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4879
                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4880
            ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4881
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4882
            id isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4883
                "/ no such color - try color dithers
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4884
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4885
                self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4886
                    ditherRed:rV green:gV blue:bV 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4887
                    on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4888
                    into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4889
                newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4890
            ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4891
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4892
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4893
        "/ none found ? -> do a hard dither using fixColors
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4894
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4895
        (id isNil and:[form isNil]) ifTrue:[
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4896
            deviceFixColors notNil ifTrue:[
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4897
                self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4898
                    fixDitherRed:rV green:gV blue:bV 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4899
                    on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4900
                    into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4901
                newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4902
            ]
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4903
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4904
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4905
        "/ still none found ? -> do a very hard dither using existing colors
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4906
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4907
        (id isNil and:[form isNil]) ifTrue:[
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4908
            self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4909
                complexDitherRed:rV green:gV blue:bV 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4910
                on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4911
                into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4912
            newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4913
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4914
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4915
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4916
    (id isNil and:[form isNil]) ifTrue:[
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4917
        "still no result - try graying"
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4918
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4919
        greyV == 0 ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4920
            id := aDevice blackpixel
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4921
        ] ifFalse:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4922
            greyV == MaxValue ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4923
                id := aDevice whitepixel
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4924
            ] ifFalse:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4925
                aDevice hasGrayscales ifTrue:[
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4926
                    self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4927
                        ditherGrayFor:(greyV / MaxValue)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4928
                        on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4929
                        into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4930
                    newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4931
                ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4932
                form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4933
                    "/ still none - dither b&w
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4934
                    self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4935
                        monoDitherFor:(greyV / MaxValue)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4936
                        between:Black and:White
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4937
                        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4938
                        into:[:c :f | newColor := c. form := f].
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4939
                    newColor notNil ifTrue:[^ newColor].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4940
                    form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4941
                        "/ cannot happen
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4942
                        'Color [warning]: monoDither failed' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4943
                        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4944
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4945
                ]
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4946
            ]
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4947
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4948
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4949
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4950
    device isNil ifTrue:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4951
        "/ receiver was not associated - do it now & return mySelf
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4952
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4953
        device := aDevice.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4954
        id isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4955
            ditherForm := form
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4956
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4957
        colorId := id.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4958
2842
dcb1f8eb648f removed obsolete method
Claus Gittinger <cg@exept.de>
parents: 2836
diff changeset
  4959
        "/ have to register - otherwise it keeps old info around
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4960
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4961
        id notNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4962
            deviceVisual ~~ #TrueColor ifTrue:[    
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4963
                aDevice registerColor:self.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4964
            ]
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4965
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4966
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4967
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4968
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4969
    "/ receiver was already associated to another device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4970
    "/ - need a new color and return it
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4971
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4972
    newColor := (self class basicNew) 
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4973
                        setScaledRed:red 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4974
                        scaledGreen:green 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4975
                        scaledBlue:blue 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4976
                        device:aDevice.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4977
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4978
        newColor setDitherForm:form
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4979
    ] ifFalse:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4980
        newColor setColorId:id.
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4981
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4982
        "/ trueColor device-colors are not registered
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4983
        deviceVisual ~~ #TrueColor ifTrue:[    
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4984
            aDevice registerColor:newColor.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4985
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4986
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4987
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4988
2313
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4989
    "Created: / 16.11.1995 / 20:16:42 / cg"
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4990
    "Modified: / 8.9.1998 / 17:32:10 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4991
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4992
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4993
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4994
!Color methodsFor:'instance creation'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4995
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4996
alpha:alphaValue
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4997
    "return a new color with the same color, but different alpha as the receiver.
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4998
     The alpha arguments range is 0..1 (0=completely transparent; 1=completely opaque)"
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4999
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5000
    alphaValue = 1 ifTrue:[ ^ self].
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5001
    ^ (TranslucentColor 
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5002
           scaledRed:red 
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5003
           scaledGreen:green 
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5004
           scaledBlue:blue) alpha:alphaValue
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5005
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5006
    "
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5007
     (Color red alpha:0.5) alpha
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5008
     Color red alpha 
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5009
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5010
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5011
    "Modified: / 06-06-2007 / 11:17:55 / cg"
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5012
!
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5013
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5014
blendWith:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5015
    "create a new color from equally mixing the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5016
     and the argument, aColor.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5017
     Mixing is done by adding components 
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5018
     (which is different from mixing colors on paper .. which is subtractive)."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5019
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5020
    ^ self mixed:1 with:aColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5021
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5022
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5023
     (Color red) blendWith:(Color yellow)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5024
     (Color red) blendWith:(Color blue)
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5025
     (Color red) blendWith:(Color black)
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5026
     (Color red) blendWith:(Color white)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5027
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5028
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5029
    "Modified: 10.2.1997 / 22:08:14 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5030
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5031
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5032
darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5033
    "return a new color, which is slightly darker than the receiver"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5034
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5035
    ^ self blendWith:Black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5036
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5037
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5038
     (Color red) darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5039
     (Color red) darkened darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5040
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5041
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5042
    "Modified: 11.6.1996 / 18:10:37 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5043
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5044
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5045
lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5046
    "return a new color, which is slightly lighter than the receiver"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5047
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5048
    ^ self blendWith:White
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5049
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5050
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5051
     (Color red) lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5052
     (Color red) lightened lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5053
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5054
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5055
    "Modified: 11.6.1996 / 18:10:49 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5056
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5057
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5058
mixed:amount with:aColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5059
    "create a new color from mixing amount of the receiver
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5060
     with the argument, aColor.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5061
     Mixing is done by adding components (i.e. additive mixing)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5062
     (which is different from mixing colors on paper .. which is subtractive).
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5063
     With an amount of 1, this is the same as blendWith."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5064
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5065
    red isNil ifTrue:[
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5066
        ^ aColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5067
    ].
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5068
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5069
    ^ (self class)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5070
        scaledRed:((red * amount) + aColor scaledRed) // (1 + amount)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5071
        scaledGreen:((green * amount) + aColor scaledGreen) // (1 + amount)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5072
        scaledBlue:((blue * amount) + aColor scaledBlue) // (1 + amount)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5073
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5074
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5075
     (Color red) mixed:1 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5076
     (Color red) mixed:0.9 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5077
     (Color red) mixed:0.8 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5078
     (Color red) mixed:0.5 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5079
     (Color red) mixed:0.25 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5080
     (Color red) mixed:0 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5081
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5082
     (Color red) mixed:1 with:(Color white)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5083
     (Color red) mixed:0.8 with:(Color white)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5084
     (Color red) mixed:0.8 with:(Color black)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5085
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5086
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5087
    "Modified: 10.2.1997 / 22:08:14 / cg"
3724
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5088
!
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5089
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5090
slightlyDarkened
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5091
    "return a new color, which is a bit darker than the receiver"
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5092
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5093
    ^ self blendWith:(self blendWith:Black)
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5094
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5095
    "
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5096
     (Color green) inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5097
     (Color green) darkened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5098
     (Color green) slightlyDarkened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5099
    "
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5100
!
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5101
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5102
slightlyLightened
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5103
    "return a new color, which is a bit lighter than the receiver"
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5104
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5105
    ^ self blendWith:(self blendWith:White)
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5106
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5107
    "
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5108
     (Color red) inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5109
     (Color red) lightened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5110
     (Color red) slightlyLightened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5111
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5112
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5113
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5114
!Color methodsFor:'instance release'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5115
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5116
executor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5117
    "redefined, since for finalization only device and colorIndex
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5118
     are needed - thus a faster copy is possible here"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5119
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5120
    ^ DeviceColorHandle basicNew setDevice:device colorId:colorId
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5121
!
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5122
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5123
releaseFromDevice
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5124
    "I am no longer available on the device"
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5125
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  5126
    colorId := device := ditherForm := replacementColor := nil.
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5127
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5128
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5129
3122
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5130
!Color methodsFor:'misc'!
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5131
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5132
magnifiedTo: extent
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5133
    "do nothing here, for compatibility with Image/Form"
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5134
! !
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5135
4851
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5136
!Color methodsFor:'object persistency'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5137
4207
9e70f7998f66 elementDescriptorFor: instead of encodingVectorFor:
penk
parents: 4203
diff changeset
  5138
elementDescriptorFor:aspect
4851
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5139
    "support for persistency:
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5140
     answer the elements to be made persistent with an ObjectCoder"
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5141
3935
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5142
    red isNil ifTrue:[
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5143
        ^ Array with:(#colorId->colorId)
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5144
    ].
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5145
    ^ Array with:(#red->self red) with:(#green->self green) with:(#blue->self blue)
4851
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5146
! !
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5147
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5148
!Color methodsFor:'printing & storing'!
3935
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5149
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5150
hex
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5151
    <resource: #obsolete>
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5152
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5153
    self obsoleteMethodWarning:'use #hexPrintString'.
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5154
    ^ self hexPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5155
!
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5156
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5157
hexPrintString
4908
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5158
    "return a hex-printString as rrggbb"
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5159
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5160
    |s|
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5161
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5162
    s := WriteStream on:(String new:6).
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5163
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5164
    self redByte   printOn:s base:16 size:2 fill:$0.
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5165
    self greenByte printOn:s base:16 size:2 fill:$0.
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5166
    self blueByte  printOn:s base:16 size:2 fill:$0.
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5167
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5168
    ^ s contents.
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5169
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5170
    "
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5171
     Color red hexPrintString
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5172
     Color green hexPrintString
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5173
     Color blue hexPrintString
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5174
     Color yellow hexPrintString 
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5175
    "
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5176
!
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5177
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5178
htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5179
    "return a hex-printString for html as #rrggbb;"
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5180
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5181
    ^ '#',(self hexPrintString)
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5182
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5183
    "
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5184
     Color red htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5185
     Color green htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5186
     Color blue htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5187
     Color yellow htmlPrintString 
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5188
    "
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5189
!
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5190
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5191
printOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5192
    "append a string representing of the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5193
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5194
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5195
    self storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5196
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5197
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5198
storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5199
    "append a string representing an expression to reconstruct the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5200
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5201
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5202
    |clsName|
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5203
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5204
    clsName := self class name.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5205
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5206
    red isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5207
        colorId notNil ifTrue:[
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5208
            aStream nextPutAll:'(' , clsName , ' colorId:'.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5209
            colorId storeOn:aStream.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5210
            aStream nextPut:$).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5211
            ^ self
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5212
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5213
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5214
    (red == green and:[red == blue]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5215
        red == 0 ifTrue:[
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5216
            aStream nextPutAll:'(' , clsName , ' black)'.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5217
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5218
            red == MaxValue ifTrue:[
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5219
                aStream nextPutAll:'(' , clsName , ' white)'.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5220
            ] ifFalse:[
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5221
                aStream nextPutAll:'(' , clsName , ' grey:'.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5222
                (self red) storeOn:aStream.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5223
                aStream nextPut:$).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5224
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5225
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  5226
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5227
    ].
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5228
    aStream nextPutAll:'(' , clsName , ' red:'.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5229
    (self red) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5230
    aStream nextPutAll:' green:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5231
    (self green) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5232
    aStream nextPutAll:' blue:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5233
    (self blue) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5234
    aStream nextPut:$).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5235
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5236
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5237
!Color methodsFor:'private'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5238
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5239
restored
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5240
    "private: color has been restored (either from snapin or binary store);
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5241
     flush device stuff or reallocate a cell."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5242
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5243
    ditherForm := replacementColor := nil.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5244
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5245
    red notNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5246
        device := nil.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5247
        colorId := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5248
    ] ifFalse:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5249
        "a variable color has been restored"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5250
        (colorId notNil and:[writable == true and:[device notNil]]) ifTrue:[
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5251
            colorId := device colorCell.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5252
            device setColor:colorId scaledRed:red scaledGreen:green scaledBlue:blue
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5253
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5254
    ]
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5255
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5256
    "Modified: 17.1.1997 / 00:04:14 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5257
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5258
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5259
setColorId:anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5260
    "private: set the deviceId"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5261
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5262
    colorId := anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5263
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5264
    "Created: 17.1.1997 / 00:05:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5265
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5266
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5267
setDevice:aDevice colorId:aNumber
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5268
    "private:set device and colorId"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5269
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5270
    device := aDevice.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5271
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5272
    writable := false.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5273
!
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5274
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5275
setDevice:aDevice colorId:aNumber writable:wBool
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5276
    "private:set device, colorId and writable flag"
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5277
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5278
    device := aDevice.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5279
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5280
    writable := wBool.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5281
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5282
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5283
setDitherForm:aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5284
    "private: set the ditherForm"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5285
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5286
    ditherForm := aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5287
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5288
    "Created: 17.1.1997 / 00:04:57 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5289
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5290
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5291
setScaledRed:r scaledGreen:g scaledBlue:b device:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5292
    "private: set the components"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5293
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5294
    red notNil ifTrue:[
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5295
        "oops cannot change (you want to make red be green - or what)"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5296
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5297
        self error:'Colors cannot change their components'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5298
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5299
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5300
    red := r.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5301
    green := g.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5302
    blue := b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5303
    device := aDevice
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5304
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5305
    "Modified: 16.1.1997 / 22:39:26 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5306
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5307
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5308
!Color methodsFor:'queries'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5309
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5310
averageColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5311
    "return the average color - thats myself.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5312
     This method has been added for compatibility with the image
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5313
     protocol."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5314
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5315
    ^ self 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5316
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5317
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5318
averageColorIn:aRectangle
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5319
    "return the average color - thats myself.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5320
     This method has been added for compatibility with the image
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5321
     protocol."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5322
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5323
    ^ self 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5324
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5325
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5326
brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5327
    "ST80 compatibility: return the grey intensity in [0..1]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5328
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5329
    ^ ((3 * red) + (6 * green) + (blue)) / 10.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5330
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5331
    "Modified: 7.6.1996 / 19:42:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5332
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5333
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5334
deltaFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5335
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5336
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5337
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5338
    ^ aColor deltaFromRed:self red green:self green blue:self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5339
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5340
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5341
     Color red deltaFrom:(Color blue)  
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5342
     Color red deltaFrom:(Color yellow)  
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5343
     Color red deltaFrom:(Color red:50)  
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5344
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5345
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5346
    "Created: 14.6.1996 / 20:07:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5347
    "Modified: 14.6.1996 / 20:49:32 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5348
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5349
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5350
deltaFromRed:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5351
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5352
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5353
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5354
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5355
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5356
    "
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5357
    ^ ((self red - r) abs
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5358
      + (self green - g) abs
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5359
      + (self blue - b) abs) rounded.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5360
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5361
    "Created: 14.6.1996 / 20:03:58 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5362
    "Modified: 14.6.1996 / 20:20:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5363
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5364
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5365
deltaFromScaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5366
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5367
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5368
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5369
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5370
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5371
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5372
    ^ (red - r) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5373
      + (green - g) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5374
      + (blue - b) abs.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5375
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5376
    "Created: 11.6.1996 / 18:01:12 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5377
    "Modified: 14.6.1996 / 20:36:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5378
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5379
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5380
errorFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5381
    "return some value which can be used to compare colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5382
     The following simply returns the vector distance of the r/g/b vectors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5383
     This may not be a very good idea; probably, we should honor the
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5384
     fact that the hue difference should have more weight than saturation and/or light"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5385
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5386
    ^ (red - aColor scaledRed) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5387
       + (green - aColor scaledGreen) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5388
       + (blue - aColor scaledBlue) squared.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5389
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5390
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5391
grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5392
    "return the grey intensity in percent [0..100] (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5393
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5394
    ^ ((3 * red) + (6 * green) + (1 * blue)) * 10.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5395
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5396
    "Created: 2.5.1996 / 11:38:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5397
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5398
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5399
greyIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5400
    "return the grey intensity in percent [0..100] (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5401
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5402
    ^ self grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5403
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5404
    "Modified: 28.5.1996 / 20:45:41 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5405
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5406
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5407
isColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5408
    "return true if the receiver is a Color."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5409
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5410
    ^ true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5411
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5412
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  5413
isColorObject
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  5414
    ^ true
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  5415
!
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  5416
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5417
isDithered
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5418
    "return true, if this is a dithered Color.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5419
     Only makes sense if the receiver is a device color."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5420
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5421
    ^ ditherForm notNil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5422
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5423
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5424
isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5425
    "same as isGrayColor - for ST80 compatibility."
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5426
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5427
    ^ self isGrayColor
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5428
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5429
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5430
     (Color grey:50) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5431
     (Color red) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5432
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5433
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5434
    "Created: 10.2.1997 / 22:10:25 / cg"
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5435
!
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5436
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5437
isGrayColor
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5438
    "return true, if this color is a gray one (US version ;-) -
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5439
     i.e. red = green = blue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5440
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5441
    red ~~ green ifTrue:[^ false].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5442
    ^ red == blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5443
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5444
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5445
     (Color grey:50) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5446
     (Color red) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5447
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5448
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5449
    "Created: 2.5.1996 / 11:38:48 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5450
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5451
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5452
isGreyColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5453
    "return true, if this color is a grey one (English version ;-) -
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5454
     i.e. red = green = blue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5455
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5456
    ^ self isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5457
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5458
    "(Color grey:50) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5459
    "(Color red) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5460
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5461
    "Modified: 28.5.1996 / 20:44:36 / cg"
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5462
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5463
3598
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5464
isOnDevice:aGraphicsDevice
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5465
    "return true if i am allocated on aGraphicsDevice"
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5466
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5467
    ^ device == aGraphicsDevice 
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5468
      and:[colorId notNil or:[replacementColor notNil and:[replacementColor colorId notNil]]]
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5469
!
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5470
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5471
isOpaque
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5472
    "return true, if I represent an opaque color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5473
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5474
    ^ true
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5475
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5476
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5477
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5478
isTranslucent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5479
    "return true, if I represent a translucent color;
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5480
     that is: not completely opaque"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5481
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5482
    ^ false
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5483
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5484
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5485
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5486
isTranslucentColor
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5487
    "return true, if I represent a translucent color, but not transparent"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5488
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5489
    ^ false
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5490
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5491
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5492
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5493
isTransparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5494
    "return true, if I represent a completely transparent color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5495
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5496
    ^ false
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5497
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5498
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5499
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5500
!Color::DeviceColorHandle class methodsFor:'documentation'!
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5501
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5502
documentation
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5503
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5504
    This is an abstract class for device handles which are responsible
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5505
    for finalization i.e. to destroy underlying system resources, when the GC
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5506
    frees an object which has created some system object.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5507
    These are used with colors.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5508
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5509
    [see also:]
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5510
        Color
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5511
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5512
    [author:]
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5513
        Claus Gittinger
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5514
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5515
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5516
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5517
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5518
!Color::DeviceColorHandle methodsFor:'accessing'!
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5519
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5520
setDevice:aDevice colorId:anId
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5521
    "set the handles contents"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5522
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5523
    device := aDevice.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5524
    colorId := anId.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5525
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5526
    "Modified: 23.4.1996 / 22:10:26 / cg"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5527
    "Created: 25.3.1997 / 14:29:10 / stefan"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5528
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5529
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5530
!Color::DeviceColorHandle methodsFor:'finalization'!
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5531
3611
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3598
diff changeset
  5532
finalize
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5533
    "the color for which I am a handle was collected 
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5534
     - release system resources"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5535
2096
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5536
    |id|
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5537
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5538
    (id := colorId) notNil ifTrue:[
3611
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3598
diff changeset
  5539
        colorId := nil.
2096
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5540
        device freeColor:id.
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5541
    ].
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5542
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5543
    "Created: 25.3.1997 / 14:29:10 / stefan"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5544
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5545
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  5546
!Color class methodsFor:'documentation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5547
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5548
version
5337
dae799444a35 name:ifIllegal:
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  5549
    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.217 2009-09-08 17:19:48 cg Exp $'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5550
! !
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
  5551
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5552
Color initialize!