Color.st
author tz
Sat, 07 Mar 1998 17:28:47 +0100
changeset 2077 442b9763111c
parent 2071 20a74671b3e0
child 2083 117f2e5ca733
permissions -rw-r--r--
#orange should return an orange color and not a brown color
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
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    12
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    13
Object subclass:#Color
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    14
	instanceVariableNames:'red green blue device colorId ditherForm replacementColor
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    15
		writable'
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    16
	classVariableNames:'MaxValue Cells Black White LightGrey Grey DarkGrey Pseudo0
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    17
		Pseudo1 PseudoAll Red Green Blue RetryAllocation DitherBits
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    18
		ColorAllocationFailSignal InvalidColorNameSignal
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    19
		StandardColorValues'
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    20
	poolDictionaries:''
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    21
	category:'Graphics-Support'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    22
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    23
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    24
Object subclass:#DeviceColorHandle
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    25
	instanceVariableNames:'device colorId'
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    26
	classVariableNames:''
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    27
	poolDictionaries:''
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    28
	privateIn:Color
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    29
!
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    30
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    31
!Color class methodsFor:'documentation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    32
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    33
copyright
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    34
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    35
 COPYRIGHT (c) 1992 by Claus Gittinger
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
    36
              All Rights Reserved
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    37
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    38
 This software is furnished under a license and may be used
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    39
 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
    40
 inclusion of the above copyright notice.   This software may not
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    41
 be provided or otherwise made available to, or used by, any
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    42
 other person.  No title to or ownership of the software is
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    43
 hereby transferred.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    44
"
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
documentation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    48
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    49
    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
    50
    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
    51
    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
    52
    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
    53
    for that device.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    54
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    55
    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
    56
    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
    57
    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
    58
    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
    59
    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
    60
    colormap (as usual for bitmaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    61
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    62
    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
    63
    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
    64
    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
    65
    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
    66
    to ugly looking dither colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    67
    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
    68
    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
    69
    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
    70
    (beside 5x5x5, there are various other size combinations available).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    71
    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
    72
    preallocated table may steal colors from the image ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    73
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    74
    [Instance variables:]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    75
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    76
      red             <Integer>       the red component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    77
      green           <Integer>       the green component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    78
      blue            <Integer>       the blue component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    79
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    80
      device          <Device>        the device I am on, or nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    81
      colorId         <Object>        some device dependent identifier (or nil if dithered)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    82
      ditherForm      <Form>          the Form to dither this color (if non-nil)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    83
      writable        <Boolean>       true if this is for a writable color cell
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    84
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    85
    [Class variables:]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    86
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    87
      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
    88
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    89
      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
    90
                                      colors for reuse and finalization.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    91
                                      (dont use it: this will be moved to the device)
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    92
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    93
      Cells           <Registry>      keeps track of allocated writable color cells
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    94
                                      (dont use it: this will be moved to the device)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    95
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    96
      FixColors       <Array>         preallocated colors for dithering on Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    97
      NumRedFix       <Integer>       number of distinct red values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    98
      NumGreenFix     <Integer>       number of distinct green values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    99
      NumBlueFix      <Integer>       number of distinct blue values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   100
    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   101
      Black           <Color>         for fast return of black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   102
      White           <Color>         for fast return of white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   103
      Grey            <Color>         for fast return of grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   104
      LightGrey       <Color>         for fast return of lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   105
      DarkGrey        <Color>         for fast return of darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   106
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   107
      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
   108
      Pseudo1         <Color>         a color with 1 as handle (for forms)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   109
      PseudoAll       <Color>         a color with allPlanes as handle (for bitblit)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   110
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   111
      Red             <Color>         red, needed for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   112
      Green           <Color>         green, for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   113
      Blue            <Color>         blue, for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   114
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   115
      DitherColors    <Collection>    some preallocated colors for dithering
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   116
                                      (kept, so they are available when needed)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   117
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   118
      RetryAllocation <Boolean>       this flag controls how a request for a
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   119
                                      color should be handled which failed previously.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   120
                                      I.e. a color is asked for, which was dithered
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   121
                                      the last time. Since it could happen, that in
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   122
                                      the meantime more colors became free, the request
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   123
                                      might succeed this time - however, your screen may
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   124
                                      look a bit funny, due to having both dithered and
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   125
                                      undithered versions around.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   126
                                      The default is true, which means: do retry
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   127
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   128
    compatibility issues:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   129
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   130
        ST-80 seems to represent colors internally with scaled smallInteger
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   131
        components (this can be guessed from uses of
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   132
        scaledRed:scaledGreen:scaledBlue:). The main instance creation method is
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   133
        via 'ColorValue red:green:blue:', passing components in 0..1.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   134
        In ST/X, component are internally represented as percent.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   135
        For more compatibility (when subclassing color), these internals may
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   136
        change in the near future. For migration, a compatibility subclass
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   137
        called ColorValue is provided. 
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   138
        After the change, Color will be renamed to ColorValue and Color
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   139
        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
   140
        backward compatibility).
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   141
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   142
    [see also:]
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   143
        DeviceWorkstation 
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   144
        GraphicsContext DeviceDrawable Form Image Colormap
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   145
        Font Cursor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   146
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   147
    [author:]
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   148
        Claus Gittinger
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   149
"
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
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   152
!Color class methodsFor:'initialization'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   153
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   154
flushDeviceColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   155
    "unassign all colors from their device"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   156
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   157
    self allInstances do:[:aColor |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   158
        aColor restored
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   159
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   160
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   161
    "Modified: 24.2.1997 / 18:27:06 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   162
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   163
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   164
getColors6x6x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   165
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   166
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   167
    "preallocates a 6x6x4 (144) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   168
     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
   169
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   170
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   171
    self getColorsRed:6 green:6 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   172
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   173
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   174
     Color getColors6x6x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   175
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   176
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   177
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   178
getColors6x6x5
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   179
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   180
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   181
    "preallocates a 6x6x5 (180) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   182
     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
   183
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   184
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   185
    self getColorsRed:6 green:6 blue:5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   186
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   187
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   188
     Color getColors6x6x5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   189
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   190
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   191
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   192
getColors6x6x6
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   193
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   194
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   195
    "preallocates a 6x6x6 (196) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   196
     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
   197
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   198
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   199
    self getColorsRed:6 green:6 blue:6
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   200
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   201
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   202
     Color getColors6x6x6
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   203
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   204
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   205
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   206
getColors6x7x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   207
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   208
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   209
    "preallocates a 6x7x4 (168) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   210
     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
   211
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   212
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   213
    self getColorsRed:6 green:7 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   214
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   215
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   216
     Color getColors6x7x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   217
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   218
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   219
    "Created: 12.6.1996 / 17:41:57 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   220
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   221
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   222
getColors7x8x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   223
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   224
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   225
    "preallocates a 7x8x4 (224) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   226
     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
   227
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   228
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   229
    self getColorsRed:7 green:8 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   230
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   231
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   232
     Color getColors7x8x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   233
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   234
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   235
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   236
getColorsRed:nRed green:nGreen blue:nBlue
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   237
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   238
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   239
    "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
   240
     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
   241
     however, colors may be either inexact or dithered."
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
    self getColorsRed:nRed green:nGreen blue:nBlue on:Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   244
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   245
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   246
     Color getColorsRed:2 green:2 blue:2
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   247
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   248
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   249
    "Modified: 11.7.1996 / 17:58:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   250
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   251
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   252
getColorsRed:nRed green:nGreen blue:nBlue on:aDevice
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 nR x nG x nB colorMap for later use in dithering.
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
    |nR "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   260
     nG "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   261
     nB "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   262
     dR dG dB red green blue dstIndex clr round
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   263
     fixColors|
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
    aDevice visualType == #TrueColor ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   266
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   267
    nR := nRed.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   268
    nG := nGreen.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   269
    nB := nBlue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   270
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   271
    dR := 100.0 / (nR - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   272
    dG := 100.0 / (nG - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   273
    dB := 100.0 / (nB - 1).
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
    fixColors := Array new:(nR * nG * nB).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   276
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   277
    round := 0.
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
    dstIndex := 1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   280
    1 to:nR do:[:sR |
1165
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   281
        red := dR * (sR - 1).
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   282
        1 to:nG do:[:sG |
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   283
            green := dG * (sG - 1).
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   284
            1 to:nB do:[:sB |
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   285
                blue := dB * (sB - 1).
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   286
                clr := (self red:red green:green blue:blue) exactOn:aDevice.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   287
                clr isNil ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   288
                    round == 0 ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   289
                        'Color [info]: scavenge to reclaim colors' infoPrintCR.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   290
                        ObjectMemory scavenge.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   291
                        round := 1.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   292
                        clr := (self red:red green:green blue:blue) exactOn:aDevice.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   293
                    ].
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   294
                ].
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   295
                clr isNil ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   296
                    round == 1 ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   297
                        'Color [info]: collect garbage to reclaim colors' infoPrintCR.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   298
                        ObjectMemory performLowSpaceCleanup.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   299
                        ObjectMemory garbageCollect.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   300
                        round := 2.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   301
                        clr := (self red:red green:green blue:blue) exactOn:aDevice.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   302
                   ].
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   303
                ].
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   304
                clr isNil ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   305
                    ColorAllocationFailSignal raiseErrorString:'failed to allocate fix color'.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   306
                    ^ self
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   307
                ].
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   308
                fixColors at:dstIndex put:clr.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   309
                dstIndex := dstIndex + 1
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   310
            ]
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   311
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   312
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   313
    aDevice setFixColors:fixColors
1165
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   314
                  numRed:nR numGreen:nG numBlue:nB
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   315
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
     Color getColorsRed:2 green:2 blue:2 on:Display
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
    "Created: 11.7.1996 / 17:55:32 / cg"
1165
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   321
    "Modified: 10.1.1997 / 15:37:13 / cg"
1023
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
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   324
getGrayColors:nGray on:aDevice
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
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   327
    "preallocates nGray gray colors for later use in dithering.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   328
     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
   329
     however, colors may be either inexact or dithered."
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   330
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   331
    |nG "{Class: SmallInteger }"
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   332
     d gray dstIndex clr round
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   333
     fixGrayColors|
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   334
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   335
    aDevice visualType == #TrueColor ifTrue:[^ self].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   336
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   337
    nG := nGray.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   338
    d := 100.0 / (nG - 1).
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   339
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   340
    fixGrayColors := Array new:nG.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   341
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   342
    round := 0.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   343
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   344
    dstIndex := 1.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   345
    1 to:nG do:[:sG |
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   346
        gray := d * (sG - 1).
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   347
        clr := (self red:gray green:gray blue:gray) exactOn:aDevice.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   348
        clr isNil ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   349
            round == 0 ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   350
                'Color [info]: scavenge to reclaim colors' infoPrintCR.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   351
                ObjectMemory scavenge.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   352
                round := 1.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   353
                clr := (self red:gray green:gray blue:gray) exactOn:aDevice.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   354
            ].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   355
        ].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   356
        clr isNil ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   357
            round == 1 ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   358
                'Color [info]: collect garbage to reclaim colors' infoPrintCR.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   359
                ObjectMemory performLowSpaceCleanup.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   360
                ObjectMemory garbageCollect.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   361
                round := 2.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   362
                clr := (self red:gray green:gray blue:gray) exactOn:aDevice.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   363
           ].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   364
        ].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   365
        clr isNil ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   366
            ColorAllocationFailSignal raiseErrorString:'failed to allocate fix gray color'.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   367
            ^ self
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   368
        ].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   369
        fixGrayColors at:dstIndex put:clr.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   370
        dstIndex := dstIndex + 1
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   371
    ].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   372
    aDevice setFixGrayColors:fixGrayColors
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   373
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   374
    "
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   375
     Color getGrayColors:16 on:Display
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   376
    "
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   377
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   378
    "Created: 23.6.1997 / 15:29:50 / cg"
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   379
!
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   380
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   381
getPrimaryColorsOn:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   382
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   383
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   384
    "preallocate the primary colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   385
     Doing so during early startup prevents us from running out
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   386
     of (at least those required) colors later.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   387
     This guarantees, that at least some colors are available
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   388
     for dithering (although, with only black, white, red, green and blue,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   389
     dithered images look very poor)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   390
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   391
    |colors white black red green blue clr dDepth
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   392
     lastPix "{ Class: SmallInteger }" |
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   393
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   394
    (aDevice notNil and:[aDevice ditherColors isNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   395
        white := (self red:100 green:100 blue:100) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   396
        white colorId isNil ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   397
            'Color [warning]: cannot allocate white color' errorPrintCR.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   398
        ].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   399
        black := (self red:0 green:0 blue:0) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   400
        black colorId isNil ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   401
            'Color [warning]: cannot allocate black color' errorPrintCR.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   402
        ].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   403
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   404
        aDevice hasColors ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   405
            red := (self red:100 green:0 blue:0) exactOn:aDevice.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   406
            green := (self red:0 green:100 blue:0) exactOn:aDevice.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   407
            blue := (self red:0 green:0 blue:100) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   408
            (red isNil 
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   409
            or:[green isNil 
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   410
            or:[blue isNil 
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   411
            or:[red colorId isNil
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   412
            or:[green colorId isNil
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   413
            or:[blue colorId isNil]]]]]) ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   414
                'Color [warning]: cannot allocate primary color(s)' errorPrintCR.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   415
                dDepth := aDevice depth.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   416
                ((dDepth >= 4) and:[dDepth <= 8]) ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   417
                    "/
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   418
                    "/ see what we have ...
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   419
                    "/
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   420
                    lastPix := (1 bitShift:dDepth) - 1.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   421
                    0 to:lastPix do:[:pixel |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   422
                        colors := OrderedCollection new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   423
                        aDevice getRGBFrom:pixel into:[:r :g :b |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   424
                            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
   425
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   426
                    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   427
                    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
   428
                    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
   429
                    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
   430
                ] ifFalse:[
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   431
                    aDevice hasColors:false.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   432
                    aDevice hasGrayscales:false.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   433
                    red := green := blue := nil.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   434
                ]
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   435
            ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   436
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   437
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   438
        aDevice == Display ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   439
            "/ keep those around for the main display
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   440
            White := white.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   441
            Black := black.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   442
            Red := red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   443
            Green := green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   444
            Blue := blue
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   445
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   446
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   447
        aDevice visualType ~~ #TrueColor ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   448
            aDevice hasColors ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   449
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   450
                "preallocate some colors for dithering 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   451
                 - otherwise, they may not be available when we need them ...
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   452
                 these are: black, white, grey50,
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   453
                            red, green, blue, yellow, cyan and magenta.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   454
                "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   455
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   456
                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
   457
                clr := (self gray:50) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   458
                (clr notNil and:[clr colorId notNil]) ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   459
                    colors add:clr
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   460
                ].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   461
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   462
                colors add:white; add:black; add:red; add:green; add:blue.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   463
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   464
                colors add:((self red:100 green:100 blue:0) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   465
                colors add:((self red:100 green:0 blue:100) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   466
                colors add:((self red:0 green:100 blue:100) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   467
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   468
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   469
            aDevice hasGrayscales ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   470
                aDevice hasColors ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   471
                    colors := OrderedCollection new.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   472
                    colors add:((self gray:50) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   473
                    colors add:white; add:black.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   474
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   475
                ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   476
                colors add:((self gray:25) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   477
                colors add:((self gray:33) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   478
                colors add:((self gray:67) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   479
                colors add:((self gray:75) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   480
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   481
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   482
            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
   483
                colors := colors select:[:clr | clr notNil and:[clr colorId notNil]].
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   484
                aDevice setDitherColors:(colors asArray).
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   485
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   486
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   487
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   488
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   489
    "Created: 11.7.1996 / 18:09:28 / cg"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   490
    "Modified: 21.10.1997 / 02:42:28 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   491
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   492
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   493
initialize
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   494
    "setup tracker of known colors and initialize classvars with
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   495
     heavily used colors"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   496
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   497
    ColorAllocationFailSignal isNil ifTrue:[
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   498
        ColorAllocationFailSignal := ErrorSignal newSignalMayProceed:true.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   499
        ColorAllocationFailSignal nameClass:self message:#colorAllocationFailSignal.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   500
        ColorAllocationFailSignal notifierString:'color allocation failed'.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   501
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   502
        InvalidColorNameSignal := ErrorSignal newSignalMayProceed:true.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   503
        InvalidColorNameSignal nameClass:self message:#invalidColorNameSignal.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   504
        InvalidColorNameSignal notifierString:'invalid color name'.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   505
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   506
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   507
    MaxValue := 16rFFFF.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   508
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   509
    "want to be informed when returning from snapshot"
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   510
    ObjectMemory addDependent:self.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   511
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   512
    RetryAllocation := true.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   513
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   514
    DitherBits := self ditherBits.
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   515
    self initializeStandardColorNames.
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   516
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   517
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   518
     Color initialize
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   519
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   520
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   521
    "Modified: 6.3.1997 / 02:22:24 / cg"
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   522
!
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   523
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   524
initializeStandardColorNames
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   525
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   526
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   527
    "setup standard colors"
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   528
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   529
    StandardColorValues := Dictionary new.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   530
    #(
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   531
                'red'     (16rFFFF 16r0000 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   532
                'green'   (16r0000 16rFFFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   533
                'blue'    (16r0000 16r0000 100)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   534
                'yellow'  (16rFFFF 16rFFFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   535
                'magenta' (16rFFFF 16r0000 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   536
                'cyan'    (16r0000 16rFFFF 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   537
                'white'   (16rFFFF 16rFFFF 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   538
                'black'   (16r0000 16r0000 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   539
                'olive'   (16r7FFF 16r7FFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   540
                'teal'    (16r0000 16r7FFF 16r7FFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   541
                'silver'  (16r6666 16r6666 16r6666)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   542
                'lime'    (16r3333 16rFFFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   543
                'fuchsia' (16r9999 16r07ae 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   544
                'aqua'    (16r199a 16rFFFF 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   545
    ) pairWiseDo:[:name :value |
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   546
        StandardColorValues at:name put:value
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   547
    ].
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   548
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   549
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   550
     Color initializeStandardColorNames
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   551
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   552
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   553
    "Modified: 6.3.1997 / 02:28:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   554
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   555
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   556
update:something with:aParameter from:changedObject
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   557
    "handle image restarts and flush any device resource handles"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   558
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   559
    (something == #restarted) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   560
        self flushDeviceColors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   561
    ].
1370
37dfdffdd4b6 getPrimaryColors now invoked from device
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   562
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   563
    (something == #returnFromSnapshot) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   564
        Display visualType == #TrueColor ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   565
            Display releaseFixColors
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   566
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   567
            Display fixColors notNil ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   568
                ColorAllocationFailSignal handle:[:ex |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   569
                    ex return
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   570
                ] do:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   571
                    |nR nG nB|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   572
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   573
                    nR := Display numFixRed.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   574
                    nG := Display numFixGreen.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   575
                    nB := Display numFixBlue.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   576
                    Display releaseFixColors.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   577
                    self getColorsRed:nR
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   578
                                green:nG
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   579
                                 blue:nB
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   580
                                   on:Display
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   581
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   582
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   583
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   584
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   585
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   586
    "Created: 15.6.1996 / 15:14:03 / cg"
1370
37dfdffdd4b6 getPrimaryColors now invoked from device
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   587
    "Modified: 24.2.1997 / 22:08:05 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   588
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   589
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   590
!Color class methodsFor:'instance creation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   591
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   592
allColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   593
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   594
     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
   595
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   596
    PseudoAll isNil ifTrue:[
2062
b0fbc19bbcbb WIN32 stuff (from md)
Claus Gittinger <cg@exept.de>
parents: 1985
diff changeset
   597
	OperatingSystem isMSWINDOWSlike ifTrue:[
b0fbc19bbcbb WIN32 stuff (from md)
Claus Gittinger <cg@exept.de>
parents: 1985
diff changeset
   598
	    PseudoAll := White.
b0fbc19bbcbb WIN32 stuff (from md)
Claus Gittinger <cg@exept.de>
parents: 1985
diff changeset
   599
	] ifFalse:[
b0fbc19bbcbb WIN32 stuff (from md)
Claus Gittinger <cg@exept.de>
parents: 1985
diff changeset
   600
            PseudoAll := self basicNew setColorId:-1
b0fbc19bbcbb WIN32 stuff (from md)
Claus Gittinger <cg@exept.de>
parents: 1985
diff changeset
   601
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   602
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   603
    ^ PseudoAll
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   604
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   605
    "Modified: 17.1.1997 / 00:05:36 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   606
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   607
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   608
blue: blue
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   609
    "return a color from blue value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   610
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   611
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   612
    ^here scaledRed:   0
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   613
          scaledGreen: 0
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   614
          scaledBlue:  (blue * MaxValue // 100)
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   615
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   616
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   617
brightness:brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   618
    "create a gray color with given brightness (0..1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   619
     ST-80 compatibility."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   620
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   621
    ^ self scaledGray:(brightness * MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   622
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   623
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   624
colorId:id
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   625
    "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
   626
     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
   627
     or for bitblits if you want to manipulate a specific colorplane."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   628
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   629
    id == 0 ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   630
        ^ self noColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   631
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   632
    id == 1 ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   633
        Pseudo1 isNil ifTrue:[
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   634
            Pseudo1 := self basicNew setColorId:1
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   635
        ].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   636
        ^ Pseudo1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   637
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   638
    id == -1 ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   639
        ^ self allColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   640
    ].
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   641
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   642
    ^ self basicNew setColorId:id
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   643
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   644
    "Modified: 24.2.1997 / 18:16:30 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   645
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   646
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   647
cyan:c magenta:m yellow:y
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   648
    "return a color from cyan, magenta and yellow values.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   649
     all values are given in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   650
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   651
    ^ self
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   652
        redPercent:(100 - c)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   653
        greenPercent:(100 - m)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   654
        bluePercent:(100 - y)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   655
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   656
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   657
     Color cyan:100 magenta:0 yellow:0      - cyan    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   658
     Color cyan:100 magenta:100 yellow:0    - blue    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   659
     Color cyan:100 magenta:0 yellow:100    - green    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   660
     Color cyan:100 magenta:100 yellow:100  - black  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   661
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   662
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   663
    "Modified: 11.6.1996 / 18:29:15 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   664
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   665
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   666
dither:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   667
    "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
   668
     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
   669
     colors.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   670
     Useful, if you explicitely want a dithered color 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   671
     (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
   672
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   673
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   674
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   675
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   676
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   677
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   678
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   679
    (c1 isNil or:[c2 isNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   680
        '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
   681
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   682
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   683
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   684
    self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   685
        monoDitherFor:fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   686
        between:c1 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   687
        and:c2
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   688
        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   689
        into:[:c :f | newColor := c. form := f].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   690
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   691
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   692
    form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   693
        "/ cannot happen
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   694
        'Color [warning]: monoDither failed' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   695
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   696
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   697
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   698
    newColor := self basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   699
                        setScaledRed:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   700
                        scaledGreen:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   701
                        scaledBlue:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   702
                        device:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   703
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   704
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   705
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   706
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   707
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   708
     |c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   709
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   710
     c := Color dither: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
   711
     c inspect.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   712
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   713
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   714
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   715
    "Modified: 3.5.1997 / 11:10:51 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   716
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   717
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   718
dithered:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   719
    "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
   720
     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
   721
     colors.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   722
     Useful, if you explicitely want a dithered color 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   723
     (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
   724
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   725
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   726
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   727
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   728
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   729
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   730
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   731
    (c1 isNil or:[c2 isNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   732
        '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
   733
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   734
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   735
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   736
    self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   737
        monoDitherFor:fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   738
        between:c1 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   739
        and:c2
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   740
        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   741
        into:[:c :f | newColor := c. form := f].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   742
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   743
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   744
    form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   745
        "/ cannot happen
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   746
        'Color [warning]: monoDither failed' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   747
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   748
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   749
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   750
    newColor := self basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   751
                        setScaledRed:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   752
                        scaledGreen:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   753
                        scaledBlue:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   754
                        device:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   755
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   756
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   757
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   758
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   759
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   760
     |c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   761
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   762
     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
   763
     c inspect.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   764
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   765
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   766
     |v c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   767
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   768
     v := StandardSystemView new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   769
     v extent:100@100.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   770
     v openAndWait.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   771
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   772
     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
   773
     v paint:c.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   774
     v fillRectangle:(10@10 corner:90@90).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   775
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   776
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   777
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   778
    "Modified: 3.5.1997 / 11:13:12 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   779
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   780
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   781
fromUser
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   782
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   783
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   784
    "let user point on a screen pixel.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   785
     Return an instance for that pixels color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   786
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   787
    |p img|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   788
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   789
    p := Screen current pointFromUser.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   790
    img := Image fromScreen:(p corner:p+1).
1976
fcf9afd72f0f Do not use obsolete method Color>>at:
Stefan Vogel <sv@exept.de>
parents: 1971
diff changeset
   791
    ^ img colorAt:0@0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   792
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   793
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   794
     Color fromUser
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   795
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   796
1976
fcf9afd72f0f Do not use obsolete method Color>>at:
Stefan Vogel <sv@exept.de>
parents: 1971
diff changeset
   797
    "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
   798
    "Modified: / 9.1.1998 / 20:48:58 / stefan"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   799
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   800
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   801
green: green
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   802
    "return a color from green value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   803
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   804
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   805
    ^here scaledRed:   0
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   806
          scaledGreen: (green * MaxValue // 100)
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   807
          scaledBlue:  0
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   808
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   809
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   810
hue:h light:l saturation:s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   811
    "return a color from hue, light and saturation values.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   812
     Hue is in degrees (0..360); light and sturation are
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   813
     in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   814
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   815
    self withRGBFromHue:h light:l saturation:s do:[:r :g :b |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   816
        ^ self redPercent:r greenPercent:g bluePercent:b
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   817
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   818
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   819
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   820
     Color hue:0 light:50 saturation:100     - red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   821
     Color hue:60 light:50 saturation:100    - yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   822
     Color hue:120 light:50 saturation:100   - green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   823
     Color hue:120 light:75 saturation:100   - bright green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   824
     Color hue:120 light:25 saturation:100   - dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   825
     Color hue:120 light:50 saturation:50    - greyish dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   826
     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
   827
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   828
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   829
    "Modified: 23.4.1996 / 13:22:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   830
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   831
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   832
name:colorName
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   833
    "Return a named color (either exact or dithered).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   834
     Report an error, if aString is not a valid color name.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   835
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   836
     We hereby only guarantee that the 8 basic colors are supported
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   837
     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
   838
     names - other devices use a builtIn name table containing only the
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   839
     common names) - use with special names (such as 'mediumGoldenRod'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   840
     is not recommended). Better use: #name:ifIllegal: and provide a fallBack."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   841
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   842
    ^ self 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   843
        name:colorName 
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   844
        ifIllegal:[InvalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   845
                        raiseRequestWith:colorName
1534
73dd2c4b86c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1502
diff changeset
   846
                        errorString:'invalid colorName: ' , colorName]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   847
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   848
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   849
     Color name:'brown'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   850
     Color name:'foo'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   851
     Color name:'snow'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   852
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   853
1534
73dd2c4b86c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1502
diff changeset
   854
    "Modified: 4.4.1997 / 15:32:33 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   855
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   856
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   857
name:colorName ifIllegal:errorBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   858
    "Return a named color (either exact or dithered).
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   859
     If aString is not a valid color name, 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   860
     return the result from evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   861
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   862
    |triple r g b|
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   863
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   864
    triple := StandardColorValues at:colorName asString ifAbsent:nil.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   865
    triple notNil ifTrue:[
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   866
        r := triple at:1.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   867
        g := triple at:2.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   868
        b := triple at:3.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   869
    ] ifFalse:[
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   870
        "/ ask display ...
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   871
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   872
        Display
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   873
            getScaledRGBFromName:colorName 
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   874
            into:[:rr :gg :bb |
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   875
                r := rr.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   876
                g := gg.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   877
                b := bb
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   878
            ].
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   879
    ].
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   880
    r notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   881
        ^ here scaledRed:r scaledGreen:g scaledBlue:b
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   882
    ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   883
    ^ errorBlock value
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   884
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   885
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   886
     Color name:'brown' ifIllegal:[Color black]
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   887
     Color name:'red' ifIllegal:[Color black]      
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   888
     Color name:'fuchsia' ifIllegal:[Color black]      
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   889
     Color name:'foo' ifIllegal:[Color black]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   890
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   891
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   892
    "Modified: 6.3.1997 / 02:32:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   893
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   894
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   895
noColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   896
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   897
     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
   898
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   899
     Pseudo0 isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   900
         Pseudo0 := self basicNew setColorId:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   901
     ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   902
     ^ Pseudo0
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   903
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   904
    "Modified: 17.1.1997 / 00:06:49 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   905
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   906
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   907
red: red
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   908
    "return a color from red value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   909
     the argument r is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   910
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   911
    ^here scaledRed:   (red * MaxValue // 100)
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   912
          scaledGreen: 0
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   913
          scaledBlue:  0
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   914
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   915
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   916
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   917
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   918
     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
   919
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   920
    ^ here scaledRed:(r * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   921
           scaledGreen:(g * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   922
           scaledBlue:(b * MaxValue // 100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   923
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   924
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   925
redByte:r greenByte:g blueByte:b
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   926
    "return a color from red, green and blue values;
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   927
     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
   928
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   929
    ^ here scaledRed:(r * MaxValue // 255)
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   930
           scaledGreen:(g * MaxValue // 255)
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   931
           scaledBlue:(b * MaxValue // 255)
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   932
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   933
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   934
     (Color redByte:255 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   935
     (Color redByte:255 greenByte:255 blueByte:255) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   936
     (Color redByte:0 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   937
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   938
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   939
    "Modified: 16.1.1997 / 23:32:43 / cg"
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   940
!
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   941
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   942
redPercent:r greenPercent:g bluePercent:b
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   943
    "return a color from red, green and blue values;
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   944
     the arguments, r, g and b are interpreted as percent (0..100)"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   945
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   946
    ^ here scaledRed:(r * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   947
           scaledGreen:(g * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   948
           scaledBlue:(b * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   949
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   950
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   951
rgbValue:rgb
1928
caf10cc253c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1907
diff changeset
   952
    "return a color from a 24bit rgb value;
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   953
     The value is composed of r<<16 + g<<8 + b."
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   954
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   955
    |r g b|
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   956
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   957
    r := (rgb bitShift:-16) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   958
    g := (rgb bitShift:-8) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   959
    b := (rgb) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   960
    ^ self redByte:r greenByte:g blueByte:b
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   961
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   962
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   963
     (Color rgbValue:16rFF0000) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   964
     (Color rgbValue:16r00FF00) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   965
     (Color rgbValue:16r0000FF) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   966
     (Color rgbValue:16rFF00FF) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   967
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   968
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   969
    "Modified: 13.8.1997 / 20:24:37 / cg"
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   970
!
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   971
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   972
scaledGray:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   973
    "return a gray color with a scaled gray value (0..MaxValue)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   974
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   975
    ^ self scaledRed:aGrayValue scaledGreen:aGrayValue scaledBlue:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   976
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   977
    "Modified: 11.6.1996 / 16:31:42 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   978
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   979
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   980
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   981
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   982
     the arguments, r, g and b are interpreted as (0..MaxValue)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   983
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   984
    |newColor|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   985
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   986
"/    "look if already known"
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   987
"/
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   988
"/    aDevice deviceColors do:[:aColor |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   989
"/        (r == aColor scaledRed) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   990
"/            (g == aColor scaledGreen) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   991
"/                (b == aColor scaledBlue) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   992
"/                    ^ aColor
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   993
"/                ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   994
"/            ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   995
"/        ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   996
"/    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   997
    newColor := self basicNew setScaledRed:r scaledGreen:g scaledBlue:b device:nil.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   998
    ^ newColor
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1001
     (Color red:100 green:0 blue:0) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1002
     (Color red:100 green:50 blue:50) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1003
     (Color red:50 green:0 blue:0) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1004
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1005
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1006
    "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
  1007
    "Modified: 24.2.1997 / 18:18:47 / cg"
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1010
variableColorOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1011
    "return a variable color (i.e. allocate a writable colorcell) on
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1012
     aDevice. The returned color is not shared and its rgb components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1013
     are initially undefined. The components can be set to any value
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1014
     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
  1015
     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
  1016
     being a pseudocolor device using colormaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1017
     Returns nil, if no more colorCells are available, or the display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1018
     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
  1019
     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
  1020
     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
  1021
     things in another color)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1022
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1023
    |c lutIndex|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1024
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1025
    lutIndex := aDevice colorCell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1026
    lutIndex isNil ifTrue:[^ nil].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1027
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1028
    c := self new.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  1029
    c setDevice:aDevice colorId:lutIndex writable:true.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1030
    Cells isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1031
        Cells := Registry new.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1032
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1033
    Cells register:c.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1034
    ^ c
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1035
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1036
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1037
     |l cell|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1038
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1039
     l := Label new.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1040
     l label:('hello' asText allBold).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1041
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1042
     cell := Color variableColorOn:(Screen current).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1043
     l foregroundColor:cell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1044
     [
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1045
        1 to:40 do:[:i|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1046
            i odd ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1047
                cell red:100 green:0 blue:0
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1048
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1049
                cell red:0 green:0 blue:0
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1050
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1051
            Display flush.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1052
            (Delay forSeconds:0.4) wait
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1053
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1054
        l destroy.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1055
     ] fork.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1056
     l open
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1057
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1058
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1059
    "Modified: 13.5.1996 / 12:41:53 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1060
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1061
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1062
!Color class methodsFor:'Signal constants'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1063
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1064
colorAllocationFailSignal
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1065
    "return the signal raised when a color allocation failed."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1066
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1067
    ^ ColorAllocationFailSignal
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1068
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1069
    "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
  1070
!
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1071
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1072
invalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1073
    "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
  1074
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1075
    ^ InvalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1076
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1077
    "Created: 24.1.1997 / 13:36:25 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1078
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1079
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1080
!Color class methodsFor:'accessing'!
1023
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
allocatedColorsOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1083
    "return a collection of colors available on aDevice"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1084
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1085
    |colors|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1086
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1087
    colors := OrderedCollection new.
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1088
    aDevice deviceColors do:[:clr |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1089
        clr colorId notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1090
            colors add:clr
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1091
        ] ifFalse:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1092
            'color - oops' printCR.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1093
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1094
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1095
    ^ colors asArray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1096
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1097
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1098
     Color allocatedColorsOn:Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1099
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1100
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1101
    "Modified: 24.2.1997 / 18:16:14 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1102
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1103
1224
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1205
diff changeset
  1104
!Color class methodsFor:'cleanup'!
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1205
diff changeset
  1105
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1205
diff changeset
  1106
releaseResourcesOnDevice:aDevice
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1205
diff changeset
  1107
    "this is sent when a display connection is closed,
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1205
diff changeset
  1108
     to release all cached Colors from that device"
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1205
diff changeset
  1109
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1110
    aDevice releaseDeviceColors
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1111
    "/ Lobby unregisterAllForWhich:[:aColor | aColor graphicsDevice == aDevice]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1112
1224
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1205
diff changeset
  1113
    "Created: 16.1.1997 / 16:44:20 / cg"
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1114
    "Modified: 24.2.1997 / 18:18:22 / cg"
1224
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1205
diff changeset
  1115
! !
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1205
diff changeset
  1116
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1117
!Color class methodsFor:'color space conversions'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1118
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1119
withHLSFromRed:r green:g blue:b do:aBlock
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1120
    "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
  1121
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1122
    |max min r1 g1 b1 delta h l s|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1123
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1124
    "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
  1125
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1126
    r1 := r / 100.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1127
    g1 := g / 100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1128
    b1 := b / 100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1129
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1130
    max := (r1 max:g1) max:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1131
    min := (r1 min:g1) min:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1132
    l := (max + min) / 2.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1133
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1134
    max = min ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1135
        "achromatic, r=g=b"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1136
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1137
        s := 0.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1138
        h := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1139
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1140
        l < 0.5 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1141
            s := (max - min) / (max + min)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1142
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1143
            s := (max - min) / (2 - max - min)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1144
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1145
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1146
        "calc hue"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1147
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1148
        delta := max - min.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1149
        r1 = max ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1150
            h := (g1 - b1) / delta
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1151
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1152
            g1 = max ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1153
                h := 2 + ((b1 - r1) / delta)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1154
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1155
                h := 4 + ((r1 - g1) / delta)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1156
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1157
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1158
        h := h * 60.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1159
        h < 0 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1160
            h := h + 360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1161
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1162
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1163
    aBlock value:h value:(l * 100) value:(s * 100)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1164
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1165
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1166
withHLSFromScaledRed:r scaledGreen:g scaledBlue:b do:aBlock
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1167
    "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
  1168
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1169
    ^ self withHLSFromRed:(r * 100.0 / MaxValue)
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1170
                    green:(g * 100.0 / MaxValue) 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1171
                     blue:(b * 100.0 / MaxValue)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1172
                       do:aBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1173
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1174
    "Created: 11.6.1996 / 17:23:47 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1175
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1176
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1177
withRGBFromHue:h light:l saturation:s do:aBlock
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1178
    "compute rgb form hls, evaluate aBlock with r,g and b as arguments"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1179
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1180
    |valueFunc s1 l1 r g b m1 m2|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1181
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1182
    valueFunc := [:n1 :n2 :hIn |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1183
        |hue|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1184
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1185
        hue := hIn.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1186
        hue > 360 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1187
            hue := hue - 360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1188
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1189
            hue < 0 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1190
                hue := hue + 360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1191
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1192
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1193
        hue < 60 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1194
            n1 + ((n2 - n1) * hue / 60)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1195
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1196
            hue < 180 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1197
                n2
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1198
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1199
                hue < 240 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1200
                    n1 + ((n2 - n1) * (240 - hue) / 60)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1201
                ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1202
                    n1
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1203
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1204
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1205
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1206
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1207
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1208
    "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
  1209
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1210
    s1 := s / 100.0.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1211
    l1 := l / 100.0.
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
    l1 <= 0.5 ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1214
        m2 := l1 * (1 + s1)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1215
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1216
        m2 := l1 + s1 - (l1 * s1)
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1219
    m1 := 2 * l1 - m2.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1220
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1221
    s1 = 0 ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1222
        "achromatic, ignore hue"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1223
        r := g := b := l1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1224
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1225
        r := valueFunc value:m1 value:m2 value:h + 120.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1226
        g := valueFunc value:m1 value:m2 value:h.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1227
        b := valueFunc value:m1 value:m2 value:h - 120.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1228
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1229
    aBlock value:r*100 value:g*100 value:b*100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1230
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1231
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1232
!Color class methodsFor:'constant colors'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1233
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1234
black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1235
    "return the black color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1236
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1237
    Black isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1238
        Black := (self red:0 green:0 blue:0) exactOn:Display
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1239
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1240
    ^ Black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1241
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
     Color black inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1244
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1245
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1246
    "Modified: 11.6.1996 / 15:55:31 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1249
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1250
    "return the blue color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1251
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1252
    Blue isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1253
        Blue := self redPercent:0 greenPercent:0 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1254
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1255
    ^ Blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1256
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1257
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1258
     Color blue inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1259
    "
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
    "Modified: 23.4.1996 / 13:15:51 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1264
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1265
    "return the cyan color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1266
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1267
    ^ self redPercent:0 greenPercent:100 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1268
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1269
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1270
     Color cyan inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1271
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1272
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1273
    "Modified: 23.4.1996 / 13:16:07 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1276
darkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1277
    "return the dark grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1278
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1279
    DarkGrey isNil ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1280
        DarkGrey := self grayPercent:33
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1281
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1282
    ^ DarkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1283
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1284
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1285
     Color darkGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1286
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1287
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1288
    "Modified: 24.2.1997 / 21:33:11 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1289
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1290
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1291
darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1292
    "return the darkGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1293
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1294
    ^ self darkGray
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
     Color darkGrey inspect
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1300
    "Modified: 28.5.1996 / 20:47:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1301
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1302
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1303
gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1304
    "return a medium grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1305
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1306
    Grey isNil ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1307
        Grey := self grayPercent:50
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1308
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1309
    ^ Grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1310
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1311
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1312
     Color gray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1313
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1314
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1315
    "Modified: 24.2.1997 / 21:33:19 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1316
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1317
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1318
gray:gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1319
    "return a gray color (US version). 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1320
     The argument, gray is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1321
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1322
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1323
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1324
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1325
     Color gray:25
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1326
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1327
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1328
    "Modified: 28.5.1996 / 20:49:51 / cg"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1329
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1330
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1331
grayPercent:gray
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1332
    "return a gray color (US version). 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1333
     The argument, gray is interpreted as percent (0..100)."
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1334
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1335
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1336
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1337
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1338
     Color gray:25
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1339
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1340
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1341
    "Modified: 28.5.1996 / 20:49:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1342
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1343
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1344
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1345
    "return green"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1346
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1347
    Green isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1348
        Green := self redPercent:0 greenPercent:100 bluePercent:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1349
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1350
    ^ Green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1351
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1352
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1353
     Color green inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1354
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1355
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1356
    "Modified: 23.4.1996 / 13:23:08 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1357
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1358
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1359
grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1360
    "return the grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1361
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1362
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1363
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1364
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1365
     Color grey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1366
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1367
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1368
    "Modified: 28.5.1996 / 20:48:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1369
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1370
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1371
grey:grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1372
    "return a grey color (English version). 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1373
     The argument, grey is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1374
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1375
    ^ self grayPercent:grey
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1376
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1377
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1378
     Color grey:25
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1379
     Color grey:12.5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1380
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1381
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1382
    "Modified: 24.2.1997 / 21:33:28 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1383
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1384
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1385
lightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1386
    "return the lightGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1387
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1388
    LightGrey isNil ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1389
        LightGrey := self grayPercent:67
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1390
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1391
    ^ LightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1392
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1393
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1394
     Color lightGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1395
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1396
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1397
    "Modified: 24.2.1997 / 21:33:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1398
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1399
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1400
lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1401
    "return the lightGrey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1402
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1403
    ^ self lightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1404
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1405
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1406
     Color lightGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1407
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1408
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1409
    "Modified: 28.5.1996 / 20:51:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1410
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1411
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1412
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1413
    "return the magenta color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1414
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1415
    ^ self redPercent:100 greenPercent:0 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1416
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1417
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1418
     Color magenta inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1419
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1420
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1421
    "Modified: 23.4.1996 / 13:23:41 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1422
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1423
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1424
mediumGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1425
    "return medium-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1426
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1427
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1428
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1429
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1430
     Color mediumGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1431
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1432
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1433
    "Created: 23.4.1996 / 13:24:17 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1434
    "Modified: 28.5.1996 / 20:51:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1435
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1436
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1437
mediumGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1438
    "return medium-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1439
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1440
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1441
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1442
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1443
     Color mediumGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1444
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1445
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1446
    "Modified: 28.5.1996 / 20:51:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1447
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1448
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1449
orange
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1450
    "return the orange color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1451
2077
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1452
     ^ self orange:100
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1453
!
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1454
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1455
orange: orange
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1456
    "return a orange color;
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1457
     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
  1458
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1459
     ^ 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
  1460
                                     
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1461
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1462
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1463
pink 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1464
    "return the pink color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1465
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1466
     ^ self redPercent:100 greenPercent:0 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1467
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1468
    "Modified: 23.4.1996 / 13:29:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1469
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1470
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1471
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1472
    "return the red color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1473
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1474
    Red isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1475
        Red := self redPercent:100 greenPercent:0 bluePercent:0.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1476
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1477
    ^ Red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1478
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1479
    "Modified: 23.4.1996 / 13:29:44 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1480
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1481
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1482
veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1483
    "return a very dark-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1484
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1485
    ^ self grayPercent:13
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1486
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1487
    "Created: 23.4.1996 / 13:33:14 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1488
    "Modified: 24.2.1997 / 21:33:52 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1489
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1490
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1491
veryDarkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1492
    "return a very dark-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1493
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1494
    ^ self veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1495
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1496
    "Modified: 28.5.1996 / 20:52:49 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1497
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1498
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1499
veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1500
    "return a very light-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1501
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1502
    ^ self grayPercent:87
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1503
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1504
    "Created: 23.4.1996 / 13:33:46 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1505
    "Modified: 24.2.1997 / 21:33:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1506
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1507
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1508
veryLightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1509
    "return a very light-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1510
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1511
    ^ self veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1512
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1513
    "Modified: 28.5.1996 / 20:52:03 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1514
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1515
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1516
white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1517
    "return the white-color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1518
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1519
    White isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1520
        White := (self redPercent:100 greenPercent:100 bluePercent:100) exactOn:Display
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1521
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1522
    ^ White
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1523
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1524
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1525
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1526
    "return the yellow color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1527
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1528
    ^ self redPercent:100 greenPercent:100 bluePercent:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1529
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1530
    "Modified: 23.4.1996 / 13:33:56 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1531
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1532
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1533
!Color class methodsFor:'obsolete'!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1534
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1535
nameOrDither:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1536
    "return a named color - if the exact color is not available,
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1537
     return a dithered color. Report an error, if the colorname is 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1538
     illegal."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1539
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1540
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1541
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1542
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1543
    "Modified: 16.1.1997 / 23:01:03 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1544
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1545
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1546
nameOrDither:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1547
    "return a named color - if the exact color is not available,
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1548
     return a dithered color. If the colorname is illegal, return
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1549
     the value of evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1550
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1551
    self obsoleteMethodWarning:'use #name:ifIllegal:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1552
    ^ self name:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1553
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1554
    "Modified: 16.1.1997 / 23:01:32 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1555
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1556
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1557
nameOrNearest:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1558
    "return a named color - or its nearest match"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1559
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1560
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1561
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1562
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1563
    "Modified: 16.1.1997 / 23:02:18 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1564
! !
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1565
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1566
!Color class methodsFor:'private'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1567
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1568
colorNearRed:r green:g blue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1569
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1570
     almost matching. If there is one, nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1571
     This is tried as a last chance before dithering.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1572
     The algorithm needs rework, the color components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1573
     should be weighted according some theory :-)"
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
    |bestColor minDelta diff rr rg rb dRed|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1576
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1577
"/    rr := (r * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1578
"/    rg := (g * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1579
"/    rb := (b * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1580
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1581
    rr := r rounded.                "round to 1%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1582
    rg := (g * 2.0) rounded / 2.0.  "round to 0.5%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1583
    rb := (b / 2) rounded * 2.      "round to 2%"
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
    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
  1586
    aDevice deviceColors do:[:aColor |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1587
        dRed := rr - aColor red.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1588
        dRed < 10 ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1589
            diff := dRed asInteger squared
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1590
                    + (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
  1591
                    + (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
  1592
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1593
            diff < minDelta ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1594
                diff = 0 ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1595
                    "got it"
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1596
                    ^ aColor
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1597
                ].
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1598
                bestColor := aColor.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1599
                minDelta := diff
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1600
            ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1601
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1602
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1603
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1604
    "allow an error of 10% per component"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1605
    minDelta < (100+100+100) ifTrue:[ ^ bestColor ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1606
    ^ nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1607
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1608
    "Modified: 24.2.1997 / 18:17:24 / cg"
1023
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
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1611
existingColorRed:r green:g blue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1612
    "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
  1613
     if there is one, nil otherwise."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1614
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1615
    ^ self existingColorScaledRed:(r * MaxValue // 100)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1616
                        scaledGreen:(g * MaxValue // 100)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1617
                        scaledBlue:(b * MaxValue // 100)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1618
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1619
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1620
existingColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1621
    "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
  1622
     if there is one, nil otherwise."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1623
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1624
    aDevice deviceColors do:[:aColor |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1625
        (r == aColor scaledRed) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1626
            (g == aColor scaledGreen) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1627
                (b == aColor scaledBlue) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1628
                    ^ aColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1629
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1630
            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1631
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1632
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1633
    ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1634
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1635
    "Modified: 24.2.1997 / 18:17:35 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1636
! !
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1637
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1638
!Color class methodsFor:'private - dithering'!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1639
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1640
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
  1641
    "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
  1642
     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
  1643
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1644
    |errR errG errB f wantR wantG wantB clr 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1645
     dir   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1646
     start "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1647
     end   "{ Class: SmallInteger }" 
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1648
     map
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1649
     w     "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1650
     h     "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1651
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1652
"/    w := h := 32.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1653
"/    w := h := 4.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1654
    w := h := 2.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1655
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1656
    errR := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1657
    errG := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1658
    errB := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1659
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1660
    "get a form and clear it"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1661
    f := Form width:w height:h depth:(aDevice depth) on:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1662
    map := IdentityDictionary new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1663
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1664
    0 to:(w-1) do:[:x |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1665
        x even ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1666
            dir := 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1667
            start := 0.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1668
            end := (h-1).
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1669
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1670
            dir := -1.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1671
            start := (h-1).
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1672
            end := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1673
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1674
        start to:end by:dir do:[:y |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1675
            wantR := red + errR. 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1676
            wantR > MaxValue ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1677
                wantR := MaxValue
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1678
            ] ifFalse:[ wantR < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1679
                wantR := 0
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1680
            ]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1681
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1682
            wantG := green + errG.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1683
            wantG > MaxValue ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1684
                wantG := MaxValue
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1685
            ] ifFalse:[ wantG < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1686
                wantG := 0
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1687
            ]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1688
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1689
            wantB := blue + errB.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1690
            wantB > MaxValue ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1691
                wantB := MaxValue
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1692
            ] ifFalse:[ wantB < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1693
                wantB := 0
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1694
            ]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1695
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1696
            "find the nearest color"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1697
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1698
" "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1699
            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
  1700
" "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1701
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1702
            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
  1703
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1704
            clr isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1705
                clr := Color scaledRed:wantR scaledGreen:wantG scaledBlue:wantB.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1706
                clr brightness > 0.5 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1707
                    clr := Color white on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1708
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1709
                    clr := Color black on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1710
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1711
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1712
                ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1713
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1714
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1715
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1716
            f paint:clr.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1717
            f displayPointX:x y:y.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1718
            map at:clr colorId + 1 put:clr.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1719
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1720
            "compute the new error"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1721
            errR := wantR - clr scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1722
            errG := wantG - clr scaledGreen.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1723
            errB := wantB - clr scaledBlue.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1724
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1725
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1726
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1727
    f colorMap:map.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1728
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1729
'hard dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1730
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1731
    ^ aBlock value:nil value:f
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1732
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1733
    "Created: 3.5.1997 / 11:02:47 / cg"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1734
    "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
  1735
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1736
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1737
ditherBits
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1738
    "return a dither pattern for x/64; x in 1..63"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1739
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
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1742
        "/ 1in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1743
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1744
          #[2r10000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1745
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1746
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1747
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1748
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1749
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1750
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1751
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1752
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1753
        "/ 2in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1754
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1755
          #[2r10000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1756
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1757
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1758
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1759
            2r00001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1760
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1761
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1762
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1763
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1764
        "/ 3in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1765
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1766
          #[2r10000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1767
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1768
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1769
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1770
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1771
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1772
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1773
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1774
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1775
        "/ 4in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1776
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1777
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1778
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1779
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1780
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1781
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1782
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1783
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1784
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1785
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1786
        "/ 5in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1787
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1788
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1789
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1790
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1791
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1792
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1793
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1794
            2r00000010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1795
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1796
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1797
        "/ 6in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1798
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1799
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1800
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1801
            2r00100000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1802
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1803
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1804
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1805
            2r00000010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1806
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1807
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1808
        "/ 7in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1809
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1810
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1811
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1812
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1813
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1814
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1815
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1816
            2r00000010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1817
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1818
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1819
        "/ 8in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1820
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1821
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1822
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1823
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1824
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1825
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1826
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1827
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1828
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1829
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1830
        "/ 9in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1831
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1832
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1833
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1834
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1835
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1836
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1837
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1838
            2r10100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1839
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1840
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1841
        "/ 10in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1842
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1843
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1844
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1845
            2r00101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1846
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1847
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1848
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1849
            2r10100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1850
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1851
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1852
        "/ 11in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1853
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1854
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1855
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1856
            2r00101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1857
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1858
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1859
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1860
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1861
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1862
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1863
        "/ 12in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1864
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1865
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1866
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1867
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1868
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1869
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1870
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1871
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1872
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1873
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1874
        "/ 13in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1875
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1876
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1877
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1878
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1879
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1880
            2r10101000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1881
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1882
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1883
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1884
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1885
        "/ 14in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1886
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1887
          #[2r10001010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1888
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1889
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1890
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1891
            2r10101000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1892
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1893
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1894
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1895
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1896
        "/ 15in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1897
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1898
          #[2r10001010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1899
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1900
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1901
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1902
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1903
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1904
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1905
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1906
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1907
        "/ 16in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1908
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1909
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1910
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1911
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1912
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1913
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1914
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1915
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1916
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1917
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1918
        "/ 17in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1919
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1920
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1921
            2r01000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1922
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1923
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1924
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1925
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1926
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1927
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1928
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1929
        "/ 18in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1930
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1931
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1932
            2r01000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1933
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1934
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1935
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1936
            2r00000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1937
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1938
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1939
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1940
        "/ 19in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1941
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1942
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1943
            2r01000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1944
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1945
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1946
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1947
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1948
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1949
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1950
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1951
        "/ 20in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1952
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1953
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1954
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1955
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1956
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1957
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1958
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1959
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1960
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1961
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1962
        "/ 21in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1963
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1964
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1965
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1966
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1967
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1968
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1969
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1970
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1971
            2r00000001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1972
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1973
        "/ 22in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1974
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1975
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1976
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1977
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1978
            2r00010000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1979
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1980
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1981
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1982
            2r00000001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1983
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1984
        "/ 23in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1985
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1986
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1987
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1988
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1989
            2r00010001
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1990
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1991
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1992
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1993
            2r00000001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1994
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1995
        "/ 24in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1996
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1997
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1998
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1999
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2000
            2r00010001
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2001
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2002
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2003
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2004
            2r00010001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2005
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2006
        "/ 25in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2007
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2008
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2009
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2010
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2011
            2r00010001
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2012
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2013
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2014
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2015
            2r01010001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2016
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2017
        "/ 26in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2018
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2019
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2020
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2021
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2022
            2r00010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2023
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2024
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2025
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2026
            2r01010001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2027
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2028
        "/ 27in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2029
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2030
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2031
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2032
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2033
            2r00010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2034
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2035
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2036
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2037
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2038
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2039
        "/ 28in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2040
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2041
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2042
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2043
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2044
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2045
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2046
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2047
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2048
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2049
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2050
        "/ 29in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2051
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2052
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2053
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2054
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2055
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2056
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2057
            2r01010100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2058
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2059
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2060
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2061
        "/ 30in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2062
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2063
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2064
            2r01000101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2065
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2066
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2067
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2068
            2r01010100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2069
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2070
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2071
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2072
        "/ 31in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2073
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2074
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2075
            2r01000101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2076
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2077
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2078
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2079
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2080
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2081
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2082
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2083
        "/ 32in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2084
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2085
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2086
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2087
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2088
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2089
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2090
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2091
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2092
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2093
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2094
        "/ 33in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2095
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2096
          #[2r11101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2097
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2098
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2099
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2100
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2101
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2102
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2103
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2104
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2105
        "/ 34in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2106
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2107
          #[2r11101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2108
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2109
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2110
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2111
            2r10101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2112
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2113
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2114
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2115
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2116
        "/ 35in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2117
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2118
          #[2r11101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2119
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2120
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2121
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2122
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2123
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2124
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2125
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2126
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2127
        "/ 36in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2128
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2129
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2130
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2131
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2132
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2133
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2134
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2135
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2136
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2137
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2138
        "/ 37in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2139
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2140
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2141
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2142
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2143
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2144
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2145
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2146
            2r10101011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2147
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2148
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2149
        "/ 38in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2150
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2151
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2152
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2153
            2r10111010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2154
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2155
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2156
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2157
            2r10101011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2158
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2159
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2160
        "/ 39in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2161
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2162
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2163
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2164
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2165
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2166
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2167
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2168
            2r10101011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2169
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2170
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2171
        "/ 40in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2172
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2173
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2174
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2175
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2176
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2177
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2178
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2179
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2180
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2181
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2182
        "/ 41in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2183
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2184
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2185
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2186
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2187
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2188
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2189
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2190
            2r11111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2191
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2192
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2193
        "/ 42in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2194
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2195
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2196
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2197
            2r10111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2198
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2199
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2200
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2201
            2r11111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2202
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2203
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2204
        "/ 43in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2205
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2206
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2207
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2208
            2r10111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2209
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2210
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2211
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2212
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2213
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2214
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2215
        "/ 44in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2216
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2217
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2218
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2219
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2220
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2221
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2222
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2223
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2224
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2225
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2226
        "/ 45in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2227
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2228
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2229
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2230
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2231
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2232
            2r11111110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2233
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2234
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2235
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2236
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2237
        "/ 46in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2238
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2239
          #[2r11101111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2240
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2241
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2242
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2243
            2r11111110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2244
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2245
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2246
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2247
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2248
        "/ 47in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2249
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2250
          #[2r11101111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2251
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2252
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2253
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2254
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2255
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2256
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2257
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2258
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2259
        "/ 48in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2260
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2261
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2262
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2263
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2264
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2265
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2266
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2267
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2268
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2269
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2270
        "/ 49in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2271
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2272
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2273
            2r01110101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2274
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2275
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2276
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2277
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2278
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2279
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2280
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2281
        "/ 50in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2282
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2283
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2284
            2r01110101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2285
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2286
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2287
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2288
            2r01010111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2289
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2290
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2291
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2292
        "/ 51in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2293
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2294
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2295
            2r01110101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2296
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2297
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2298
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2299
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2300
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2301
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2302
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2303
        "/ 52in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2304
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2305
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2306
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2307
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2308
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2309
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2310
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2311
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2312
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2313
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2314
        "/ 53in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2315
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2316
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2317
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2318
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2319
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2320
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2321
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2322
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2323
            2r11010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2324
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2325
        "/ 54in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2326
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2327
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2328
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2329
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2330
            2r01011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2331
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2332
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2333
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2334
            2r11010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2335
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2336
        "/ 55in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2337
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2338
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2339
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2340
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2341
            2r11011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2342
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2343
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2344
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2345
            2r11010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2346
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2347
        "/ 56in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2349
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2350
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2351
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2352
            2r11011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2353
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2354
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2355
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2356
            2r11011101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2357
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2358
        "/ 57in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2359
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2360
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2361
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2362
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2363
            2r11011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2364
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2365
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2366
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2367
            2r11111101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2368
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2369
        "/ 58in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2370
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2371
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2372
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2373
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2374
            2r11011111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2375
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2376
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2377
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2378
            2r11111101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2379
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2380
        "/ 59in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2381
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2382
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2383
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2384
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2385
            2r11011111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2386
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2387
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2388
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2389
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2390
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2391
        "/ 60in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2392
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2393
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2394
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2395
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2396
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2397
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2398
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2399
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2400
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2401
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2402
        "/ 61in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2403
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2404
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2405
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2406
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2407
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2408
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2409
            2r01111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2410
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2411
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2412
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2413
        "/ 62in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2414
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2415
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2416
            2r11110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2417
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2418
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2419
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2420
            2r01111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2421
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2422
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2423
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2424
        "/ 63in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2425
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2426
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2427
            2r11110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2428
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2429
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2430
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2431
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2432
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2433
            2r11111111]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2434
     )
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2435
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2436
    "Modified: 23.4.1996 / 13:31:50 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2437
    "Created: 11.6.1996 / 15:34:29 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2438
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2439
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2440
ditherGrayFor:fraction on:aDevice into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2441
    "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
  2442
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2443
     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
  2444
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2445
    |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
  2446
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2447
    d := aDevice depth.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2448
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2449
    "/ special code for b&w displays
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2450
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2451
    d == 1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2452
        aDevice blackpixel == 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2453
            clr1 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2454
            clr2 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2455
            newFraction := fraction.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2456
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2457
            clr1 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2458
            clr2 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2459
            newFraction := 1 - fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2460
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2461
    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2462
        "/ special code for 2-plane displays (NeXT)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2463
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2464
        d == 2 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2465
            fraction <= 0.01 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2466
                clr1 := Black exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2467
            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2468
                (fraction between:0.32 and:0.34) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2469
                    clr1 := (Color gray:33) exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2470
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2471
                    (fraction between:0.66 and:0.68) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2472
                        clr1 := (Color gray:67) exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2473
                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2474
                        fraction >= 0.99 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2475
                            clr1 := White exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2476
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2477
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2478
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2479
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2480
            clr1 notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2481
                ^ aBlock value:clr1 value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2482
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2483
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2484
            (fraction between:0 and:0.33) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2485
                clr1 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2486
                clr2 := Color gray:33.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2487
            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2488
                (fraction between:0.34 and:0.66) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2489
                    clr1 := Color gray:33.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2490
                    clr2 := Color gray:67.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2491
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2492
                    clr1 := Color gray:67.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2493
                    clr2 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2494
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2495
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2496
            scaledGray1 := clr1 scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2497
            scaledGray2 := clr2 scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2498
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2499
            scaledGrey := (MaxValue * fraction) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2500
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2501
            newFraction := (scaledGrey - scaledGray1) asFloat / (scaledGray2 - scaledGray1).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2502
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2503
            nGray := (1 bitShift:d) - 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2504
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2505
            "/ scale greyValue into grey levels
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2506
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2507
            grayBelow := (fraction * nGray) truncated.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2508
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2509
            grayBelow < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2510
                ^ Color black exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2511
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2512
            grayBelow >= nGray ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2513
                ^ Color white exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2514
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2515
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2516
            scaledGrey := (MaxValue * fraction) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2517
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2518
            step := MaxValue // nGray.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2519
            scaledGray1 := grayBelow * step.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2520
            scaledGray2 := scaledGray1 + step.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2521
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2522
            clr1 := Color scaledGray:scaledGray1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2523
            clr2 := Color scaledGray:scaledGray2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2524
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2525
            "/ scale remainder in between low..high
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2526
            newFraction := (scaledGrey - scaledGray1) asFloat / (scaledGray2 - scaledGray1).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2527
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2528
            "/ dither between those two colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2529
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2530
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2531
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2532
    clr1 := clr1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2533
    clr2 := clr2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2534
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2535
    (clr1 isNil or:[clr2 isNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2536
        "/ fall back to b&w dither
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2537
        aDevice blackpixel == 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2538
            clr1 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2539
            clr2 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2540
            newFraction := fraction.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2541
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2542
            clr1 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2543
            clr2 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2544
            newFraction := 1 - fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2545
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2546
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2547
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2548
    ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2549
        monoDitherFor:newFraction 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2550
        between:clr1 and:clr2
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2551
        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2552
        into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2553
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2554
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2555
     Color basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2556
        ditherGrayFor:0.5 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2557
        on:Display 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2558
        into:[:clr :form | clr notNil ifTrue:[clr inspect].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2559
                           form notNil ifTrue:[(form magnifiedBy:16) inspect].]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2560
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2561
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2562
     Color basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2563
        ditherGrayFor:0.25 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2564
        on:Display 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2565
        into:[:clr :form | clr notNil ifTrue:[clr inspect].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2566
                           form notNil ifTrue:[(form magnifiedBy:16) inspect].]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2567
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2568
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2569
    "Created: 3.5.1997 / 10:59:57 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2570
    "Modified: 3.5.1997 / 11:05:09 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2571
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2572
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2573
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
  2574
    "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
  2575
     Returns 2 values (either color or ditherForm) through
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2576
     aBlock.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2577
     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
  2578
     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
  2579
     are handled"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2580
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2581
    |rh rl rs 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2582
     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
  2583
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2584
    "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
  2585
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2586
    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
  2587
        h notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2588
            rh := (h * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2589
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2590
        rl := (l * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2591
        rs := (s * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2592
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2593
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2594
    rh isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2595
        "achromatic,  dither between achromatic colors"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2596
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2597
        lowL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2598
        hiL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2599
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2600
        "find the 2 bounding colors"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2601
        aDevice deviceColors do:[:aColor |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2602
            aColor colorId notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2603
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2604
                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
  2605
                    | cl |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2606
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2607
                    h isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2608
                        cl := (l * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2609
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2610
                        cl > rl ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2611
                            hiL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2612
                                hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2613
                                hiValL := cl.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2614
                            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2615
                                cl < hiValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2616
                                    hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2617
                                    hiValL := cl.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2618
                                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2619
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2620
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2621
                            lowL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2622
                                lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2623
                                lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2624
                            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2625
                                cl > lowValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2626
                                    lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2627
                                    lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2628
                                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2629
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2630
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2631
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2632
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2633
            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2634
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2635
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2636
        (lowL notNil and:[hiL notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2637
            ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2638
                monoDitherFor:1.0 / (hiValL - lowValL) * (rl - lowValL)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2639
                between:lowL and:hiL 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2640
                on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2641
                into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2642
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2643
        "cannot happen, should always find at least black and white"
2071
20a74671b3e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2062
diff changeset
  2644
        '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
  2645
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2646
        ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2647
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2648
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2649
    "chromatic case"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2650
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2651
    aDevice hasColors ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2652
        "no chance, return nil values"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2653
        ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2654
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2655
    (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
  2656
        "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
  2657
        ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2658
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2659
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2660
    "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
  2661
     dither on light between those"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2662
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2663
    lowL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2664
    hiL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2665
    lowS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2666
    hiS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2667
    lowH := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2668
    hiH := nil.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2669
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2670
    aDevice deviceColors do:[:aColor |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2671
        aColor colorId notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2672
            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
  2673
                | cl ch cs|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2674
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2675
                h notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2676
                   ch := (h * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2677
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2678
                   ch := nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2679
                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2680
                cl := (l * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2681
                cs := (s * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2682
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2683
                ((ch = rh) and:[cs = rs]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2684
                    "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
  2685
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2686
                    cl > rl ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2687
                        hiL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2688
                            hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2689
                            hiValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2690
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2691
                            cl < hiValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2692
                                hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2693
                                hiValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2694
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2695
                        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2696
                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2697
                        lowL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2698
                            lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2699
                            lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2700
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2701
                            cl > lowValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2702
                                lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2703
                                lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2704
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2705
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2706
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2707
                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2708
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2709
                (((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
  2710
                    "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
  2711
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2712
                    cs > rs ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2713
                        hiS isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2714
                            hiS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2715
                            hiValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2716
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2717
                            cs < hiValS ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2718
                                hiS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2719
                                hiValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2720
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2721
                        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2722
                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2723
                        lowS isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2724
                            lowS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2725
                            lowValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2726
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2727
                            cs > lowValS ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2728
                                lowS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2729
                                lowValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2730
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2731
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2732
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2733
                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2734
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2735
                rh notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2736
                    cl = rl ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2737
                        cs = rs ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2738
                            ch notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2739
                                d := (ch - rh) abs.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2740
                                d > 300 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2741
                                    rh > 180 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2742
                                        ch := ch + 360
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2743
                                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2744
                                        ch := ch - 360
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2745
                                    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2746
                                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2747
                                ch > rh ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2748
                                    hiH isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2749
                                        hiH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2750
                                        hiValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2751
                                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2752
                                        ch < hiValH ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2753
                                            hiH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2754
                                            hiValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2755
                                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2756
                                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2757
                                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2758
                                    lowH isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2759
                                        lowH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2760
                                        lowValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2761
                                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2762
                                        ch > lowValH ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2763
                                            lowH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2764
                                            lowValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2765
                                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2766
                                    ] 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2767
                                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2768
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2769
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2770
                    ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2771
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2772
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2773
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2774
    ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2775
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2776
    "found bounds for light ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2777
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2778
    lowL notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2779
        rl = lowValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2780
            ^ aBlock value:lowL value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2781
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2782
        hiL notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2783
            ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2784
                monoDitherFor:1.0 / (hiValL - lowValL) / (rl - lowValL)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2785
                between:lowL and:hiL 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2786
                on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2787
                into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2788
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2789
        "found bound for light - dither with white"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2790
        ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2791
            monoDitherFor:1.0 / (100 - lowValL) / (rl - lowValL)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2792
            between:lowL and:White 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2793
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2794
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2795
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2796
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2797
    "found bound for light - dither with black"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2798
    hiL notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2799
        ^ self  
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2800
            monoDitherFor:1.0 / (hiValL) / (rl)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2801
            between:Black and:hiL 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2802
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2803
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2804
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2805
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2806
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2807
    "found bounds for saturation?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2808
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2809
    (lowS notNil and:[hiS notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2810
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2811
        'saturation dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2812
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2813
        ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2814
            monoDitherFor:1.0 / (hiValS - lowValS) / (rs - lowValS)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2815
            between:lowS and:hiS
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2816
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2817
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2818
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2819
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2820
    "found bounds for hue ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2821
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2822
    (lowH notNil and:[hiH notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2823
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2824
        'hue dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2825
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2826
        hiValH < lowValH ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2827
            hiValH := hiValH + 360
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2828
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2829
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2830
        d := hiValH - lowValH.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2831
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2832
        ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2833
            monoDitherFor:1.0 / (d / (rh - lowValH))
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2834
            between:lowH and:hiH 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2835
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2836
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2837
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2838
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2839
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2840
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2841
    "Modified: 3.5.1997 / 10:58:54 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2842
    "Created: 3.5.1997 / 11:02:03 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2843
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2844
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2845
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
  2846
    "get a dither form for an rgb value.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2847
     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
  2848
     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
  2849
     dither colors."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2850
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2851
    | 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2852
     nR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2853
     nG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2854
     nB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2855
     hR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2856
     hG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2857
     hB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2858
     eR eG eB
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2859
     rI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2860
     gI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2861
     bI  "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2862
     idx "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2863
     f clr
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2864
     r    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2865
     g    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2866
     b    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2867
     x1   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2868
     x2   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2869
     step "{ Class: SmallInteger }" 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2870
     lastIdx mx 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2871
     dS   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2872
     cube|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2873
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2874
    (cube := aDevice fixColors) notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2875
        dS := 4.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2876
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2877
        f := Form width:dS height:dS depth:(aDevice depth) on:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2878
        f initGC.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2879
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2880
        mx := MaxValue asFloat.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2881
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2882
        nR := aDevice numFixRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2883
        nG := aDevice numFixGreen.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2884
        nB := aDevice numFixBlue.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2885
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2886
        hR := nR // 2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2887
        hG := nG // 2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2888
        hB := nB // 2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2889
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2890
        eR := eG := eB := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2891
        r := redVal.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2892
        g := greenVal.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2893
        b := blueVal.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2894
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2895
        step := -1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2896
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2897
        0 to:dS-1 do:[:y |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2898
            step == -1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2899
                x1 := 0. x2 := dS-1. step := 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2900
            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2901
                x1 := dS-1. x2 := 0. step := -1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2902
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2903
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2904
            x1 to:x2 by:step do:[:x |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2905
                "/ the nearest along the grid
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2906
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2907
                r := redVal + eR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2908
                r > MaxValue ifTrue:[r := MaxValue]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2909
                             ifFalse:[r < 0 ifTrue:[r := 0]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2910
                g := greenVal + eG.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2911
                g > MaxValue ifTrue:[g := MaxValue]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2912
                             ifFalse:[g < 0 ifTrue:[g := 0]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2913
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2914
                b := blueVal + eB.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2915
                b > MaxValue ifTrue:[b := MaxValue]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2916
                             ifFalse:[b < 0 ifTrue:[b := 0]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2917
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2918
                rI := (r * (nR-1) + hR / mx) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2919
                gI := (g * (nG-1) + hG / mx) rounded .
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2920
                bI := (b * (nB-1) + hB / mx) rounded .
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2921
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2922
                idx := (((rI * nG) + gI) * nB + bI) + 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2923
                clr := (cube at:idx) exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2924
                lastIdx isNil ifTrue:[lastIdx := idx]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2925
                ifFalse:[lastIdx ~~ idx ifTrue:[lastIdx := -1]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2926
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2927
                f foreground:clr.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2928
                f displayPointX:x y:y.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2929
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2930
                eR := r  - clr scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2931
                eG := g  - clr scaledGreen.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2932
                eB := b  - clr scaledBlue.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2933
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2934
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2935
        f releaseGC.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2936
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2937
        lastIdx ~~ -1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2938
            ^ aBlock value:clr value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2939
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2940
        ^ aBlock value:nil value:f
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2941
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2942
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2943
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2944
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2945
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2946
    "Modified: 11.7.1996 / 18:30:28 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2947
    "Created: 3.5.1997 / 11:03:18 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2948
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2949
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2950
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
  2951
    "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
  2952
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2953
     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
  2954
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2955
    |form c1 c2 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2956
     index "{ Class:SmallInteger }"|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2957
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2958
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2959
    "/ 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
  2960
    "/ 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
  2961
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2962
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2963
    index := (fraction * 64) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2964
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2965
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2966
    index < 1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2967
        ^ aBlock value:c1 value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2968
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2969
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2970
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2971
    index >= 64 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2972
        ^ aBlock value:c2 value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2973
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2974
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2975
    form := Form width:8 height:8 fromArray:(DitherBits at:index) on:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2976
    form colorMap:(Array with:c1 with:c2).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2977
    ^ aBlock value:nil value:form
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2978
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2979
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2980
     Color basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2981
        monoDitherFor:(MaxValue // 2)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2982
        between:Color black 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2983
        and:Color white 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2984
        on:Display 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2985
        into:[:clr :dither | clr inspect. dither inspect]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2986
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2987
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2988
    "Created: 3.5.1997 / 10:55:06 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2989
    "Modified: 3.5.1997 / 11:05:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2990
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2991
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  2992
!Color class methodsFor:'queries'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2993
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2994
constantNames
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2995
    "return names known as instance creation messages"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2996
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2997
    ^ #(white black 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2998
        grey mediumGrey veryLightGrey lightGrey darkGrey veryDarkGrey
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2999
        red green blue cyan yellow pink orange magenta)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3000
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3001
    "Modified: 2.5.1996 / 11:34:05 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3002
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3003
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3004
scalingValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3005
    "ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3006
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3007
    ^ MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3008
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3009
    "Created: 2.5.1996 / 11:30:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3010
    "Modified: 11.7.1996 / 21:42:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3011
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3012
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3013
!Color class methodsFor:'special instance creation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3014
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3015
nearestColorRed:r green:g blue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3016
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3017
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3018
     If there is one, return it; nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3019
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3020
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3021
     vector distance (which may not be the best possible solution)."
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
    ^ self
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3024
        nearestColorScaledRed:(r * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3025
                  scaledGreen:(g * MaxValue // 100) 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3026
                   scaledBlue:(b * MaxValue // 100) 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3027
                           on:aDevice 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3028
                           in:colors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3029
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3030
    "Modified: 11.6.1996 / 18:04:55 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3031
    "Created: 14.6.1996 / 20:05:13 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3032
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3033
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3034
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
  3035
    "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
  3036
     collection, containing colors from a colorCube.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3037
     This is used with preallocated fixColors and is quite fast 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3038
     (no need to search)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3039
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3040
    |sR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3041
     sG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3042
     sB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3043
     idx "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3044
     nR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3045
     nG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3046
     nB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3047
     rI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3048
     gI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3049
     bI  "{ Class: SmallInteger }"|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3050
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3051
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3052
     round to the step given by FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3053
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3054
    nR := nRed.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3055
    nG := nGreen.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3056
    nB := nBlue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3057
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3058
    sR := MaxValue // (nR - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3059
    sG := MaxValue // (nG - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3060
    sB := MaxValue // (nB - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3061
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3062
    rI := (r + (sR // 2)) // sR.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3063
    gI := (g + (sG // 2)) // sG.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3064
    bI := (b + (sB // 2)) // sB.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3065
    idx := (((rI * nG) + gI) * nB + bI) + 1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3066
    ^ aColorCube at:idx
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3067
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3068
    "Modified: 11.7.1996 / 17:52:46 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3069
    "Created: 11.7.1996 / 18:20:13 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3070
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3071
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3072
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3073
    "return a device color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3074
     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
  3075
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3076
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3077
     vector distance (which may not be the best possible solution)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3078
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3079
    |cube|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3080
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3081
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3082
     if there are preallocated colors, things are much easier ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3083
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3084
    (cube := aDevice fixColors) notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3085
        ^ self 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3086
            nearestColorScaledRed:r 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3087
            scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3088
            scaledBlue:b
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3089
            inCube:cube
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3090
            numRed:(aDevice numFixRed)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3091
            numGreen:(aDevice numFixGreen)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3092
            numBlue:(aDevice numFixBlue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3093
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3094
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3095
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3096
     search in existing colors ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3097
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3098
    ^ self 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3099
        nearestColorScaledRed:r 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3100
        scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3101
        scaledBlue:b 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3102
        on:aDevice 
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3103
        in:aDevice deviceColors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3104
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3105
    "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
  3106
    "Modified: 24.2.1997 / 18:17:51 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3107
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3108
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3109
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3110
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3111
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3112
     If there is one, return it; nil otherwise."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3113
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3114
    |delta minDelta bestSoFar|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3115
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3116
    minDelta := 9999999.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3117
1619
4a7dbd25c588 handle the case where not even r/g/b primaries can be allocated
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3118
    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
  3119
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3120
    colors do:[:aColor |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3121
        |cr cg cb|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3122
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3123
        (aColor graphicsDevice == aDevice) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3124
            aColor colorId notNil ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3125
                delta := aColor deltaFromScaledRed:r scaledGreen:g scaledBlue:b.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3126
                delta < minDelta ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3127
                    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3128
                     an exact fit - no need to continue search
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3129
                    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3130
                    delta == 0 ifTrue:[^ aColor].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3131
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3132
                    bestSoFar := aColor.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3133
                    minDelta := delta
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3134
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3135
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3136
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3137
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3138
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3139
    ^ bestSoFar
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3140
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3141
    "Created: 11.6.1996 / 18:02:12 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3142
    "Modified: 5.7.1996 / 17:58:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3143
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3144
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3145
quickNearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3146
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3147
     same or near r/g/b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3148
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3149
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3150
     vector distance (which may not be the best possible solution).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3151
     This looks for primary colors only and is thus faster
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3152
     than the general nearestColor search (slightly uglier though)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3153
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3154
    |cube|
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
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3157
     if there are preallocated colors, things are much easier ...
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3158
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3159
    (cube := aDevice fixColors) notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3160
        ^ self 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3161
            nearestColorScaledRed:r 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3162
            scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3163
            scaledBlue:b 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3164
            inCube:cube
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3165
            numRed:(aDevice numFixRed)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3166
            numGreen:(aDevice numFixGreen)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3167
            numBlue:(aDevice numFixBlue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3168
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3169
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3170
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3171
     search in existing colors ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3172
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3173
    ^ self nearestColorScaledRed:r 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3174
                     scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3175
                      scaledBlue:b 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3176
                        on:aDevice 
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3177
                        in:(aDevice availableDitherColors)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3178
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3179
    "Created: 14.6.1996 / 20:13:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3180
    "Modified: 11.7.1996 / 18:20:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3181
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3182
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3183
!Color methodsFor:'ST-80 compatibility'!
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3184
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3185
asDevicePaintOn:aDevice
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3186
    "ST-80 compatibility: an alias for on:.
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3187
     create a new Color representing the same color as
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3188
     myself on aDevice; if one already exists, return the one"
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3189
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3190
    ^ self on:aDevice
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3191
! !
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3192
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3193
!Color methodsFor:'accessing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3194
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3195
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3196
    "return the blue component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3197
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3198
    (blue isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3199
        device getRGBFrom:colorId into:[:r :g :b | ^ b].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3200
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3201
    ^ blue * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3202
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3203
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3204
blueByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3205
    "return the blue components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3206
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3207
    ^ blue * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3208
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3209
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3210
     Color red blueByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3211
     Color blue blueByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3212
     Color green blueByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3213
     Color black blueByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3214
     Color grey blueByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3215
     Color white blueByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3216
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3217
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3218
    "Created: 7.6.1996 / 18:30:25 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3219
    "Modified: 7.6.1996 / 18:32:03 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3220
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3221
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3222
colorId
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3223
    "return the device-dependent color-id"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3224
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3225
    colorId notNil ifTrue:[^ colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3226
    replacementColor notNil ifTrue:[^ replacementColor colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3227
    ^ nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3228
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3229
    "Modified: 17.1.1997 / 00:03:18 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3230
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3231
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3232
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3233
    "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
  3234
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3235
    ^ 100 - self red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3236
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3237
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3238
    "Created: 11.6.1996 / 18:30:00 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3239
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3240
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3241
device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3242
    "return the device I am associated to"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3243
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3244
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3245
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3246
    "Modified: 23.4.1996 / 13:36:42 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3247
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3248
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3249
deviceBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3250
    "return the actual value of the blue component in percent."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3251
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3252
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3253
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3254
    device getRGBFrom:colorId into:[:r :g :b | v := b].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3255
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3256
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3257
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3258
deviceGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3259
    "return the actual value of the green component in percent.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3260
     (usually 16bit in X; but could be different on other systems)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3261
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3262
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3263
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3264
    device getRGBFrom:colorId into:[:r :g :b | v := g].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3265
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3266
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3267
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3268
deviceRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3269
    "return the actual value of the red component in percent."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3270
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3271
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3272
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3273
    device getRGBFrom:colorId into:[:r :g :b | v := r].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3274
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3275
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3276
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3277
     (Color yellow on:Display) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3278
     (Color yellow on:aPrinterPage) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3279
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3280
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3281
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3282
ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3283
    "return the form to dither the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3284
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3285
    ^ ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3286
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3287
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3288
graphicsDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3289
    "same as #device, for ST-80 compatibility naming.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3290
     Return the device I am associated with."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3291
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3292
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3293
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3294
    "Created: 28.5.1996 / 18:39:27 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3295
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3296
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3297
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3298
    "return the green component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3299
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3300
    (green isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3301
        device getRGBFrom:colorId into:[:r :g :b | ^ g].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3302
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3303
    ^ green * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3304
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3305
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3306
greenByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3307
    "return the green components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3308
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3309
    ^ green * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3310
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3311
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3312
     Color red greenByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3313
     Color blue greenByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3314
     Color green greenByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3315
     Color black greenByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3316
     Color grey greenByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3317
     Color white greenByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3318
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3319
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3320
    "Modified: 7.6.1996 / 18:31:30 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3321
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3322
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3323
hue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3324
    "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
  3325
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3326
    |r g b h|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3327
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3328
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3329
        device getRGBFrom:colorId into:[:xr :xg :xb |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3330
            r := xr.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3331
            g := xg.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3332
            b := xb.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3333
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3334
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3335
        r := self red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3336
        g := self green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3337
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3338
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3339
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3340
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3341
        h := xh
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3342
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3343
    ^ h
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3344
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3345
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3346
     Color yellow hue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3347
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3348
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3349
    "Modified: 11.6.1996 / 17:14:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3350
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3351
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3352
light 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3353
    "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
  3354
     This corresponds to the brightness of the color (if displayed on
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3355
     a b&w television screen)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3356
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3357
    |r g b l|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3358
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3359
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3360
        device getRGBFrom:colorId into:[:xr :xg :xb |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3361
            r := xr.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3362
            g := xg.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3363
            b := xb.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3364
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3365
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3366
        r := self red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3367
        g := self green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3368
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3369
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3370
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3371
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3372
        l := xl
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3373
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3374
    ^ l
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3375
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3376
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3377
     Color yellow light          
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3378
     Color yellow darkened light   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3379
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3380
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3381
    "Modified: 11.6.1996 / 17:15:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3382
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3383
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3384
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3385
    "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
  3386
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3387
    ^ 100 - self green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3388
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3389
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3390
    "Created: 11.6.1996 / 18:30:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3391
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3392
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3393
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3394
    "return the red component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3395
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3396
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3397
        device getRGBFrom:colorId into:[:r :g :b | ^ r].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3398
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3399
    red isNil ifTrue:[^ 0].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3400
    ^ red * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3401
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3402
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3403
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3404
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3405
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3406
    "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
  3407
     table in pseudocolor devices.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3408
     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
  3409
     Color>>variableColorOn: on pseudoColor displays). 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3410
     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
  3411
     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
  3412
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3413
    ^ self scaledRed:(r * MaxValue // 100)
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3414
           scaledGreen:(g * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3415
           scaledBlue:(b * MaxValue // 100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3416
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3417
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3418
     |c|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3419
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3420
     c := Color variableColorOn:Display.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3421
     c inspect.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3422
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3423
     c red:100 green:0 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3424
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3425
     c red:0 green:100 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3426
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3427
     c red:0 green:0 blue:100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3428
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3429
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3430
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3431
redByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3432
    "return the red components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3433
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3434
    ^ red * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3435
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3436
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3437
     Color red redByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3438
     Color blue redByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3439
     Color green redByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3440
     Color black redByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3441
     Color grey redByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3442
     Color white redByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3443
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3444
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3445
    "Modified: 7.6.1996 / 18:31:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3446
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3447
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3448
rgbValue
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3449
    "return the rgb byteValues packed into a 24bit integer;
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3450
     The returned value is composed of r<<16 + g<<8 + b."
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3451
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3452
    |t "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3453
     v "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3454
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3455
    v := red * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3456
    t := green * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3457
    v := (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3458
    t := blue * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3459
    ^ (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3460
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3461
    "
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3462
     Color red rgbValue hexPrintString  
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3463
     Color blue rgbValue hexPrintString  
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3464
     Color green rgbValue hexPrintString   
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3465
     Color black rgbValue hexPrintString   
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3466
     Color grey rgbValue hexPrintString   
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3467
     Color white rgbValue hexPrintString  
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3468
    "
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3469
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3470
    "Modified: 17.10.1997 / 20:00:25 / cg"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3471
!
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3472
1971
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3473
rowBlueByte
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3474
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3475
    blue isNil ifTrue: [^'mask'].
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3476
    ^self blueByte
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3477
!
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3478
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3479
rowGreenByte
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3480
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3481
    green isNil ifTrue: [^'mask'].
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3482
    ^self greenByte
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3483
!
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3484
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3485
rowRedByte
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3486
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3487
    red isNil ifTrue: [^'mask'].
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3488
    ^self redByte
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3489
!
10ccdbb00c85 additional methods for DataSetViews.
tz
parents: 1954
diff changeset
  3490
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3491
saturation 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3492
    "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
  3493
     This corresponds to the saturation setting of a color TV"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3494
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3495
    |r g b s|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3496
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3497
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3498
        device getRGBFrom:colorId into:[:xr :xg :xb |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3499
            r := xr.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3500
            g := xg.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3501
            b := xb.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3502
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3503
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3504
        r := self red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3505
        g := self green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3506
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3507
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3508
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3509
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3510
        s := xs
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3511
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3512
    ^ s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3513
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3514
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3515
     Color yellow saturation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3516
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3517
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3518
    "Modified: 11.6.1996 / 17:15:47 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3519
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3520
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3521
scaledBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3522
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3523
     return the blue components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3524
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3525
    ^ blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3526
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3527
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3528
     Color blue scaledBlue   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3529
     Color black scaledBlue  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3530
     Color grey scaledBlue   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3531
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3532
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3533
    "Modified: 7.6.1996 / 18:32:30 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3534
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3535
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3536
scaledGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3537
    "return the grey intensity scaled to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3538
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3539
    ^ ((red * 3) + (green * 6) + blue) // 10
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3540
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3541
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3542
     Color blue scaledGray   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3543
     Color black scaledGray  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3544
     Color white scaledGray  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3545
     Color grey scaledGray    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3546
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3547
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3548
    "Modified: 11.6.1996 / 14:43:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3549
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3550
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3551
scaledGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3552
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3553
     return the green components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3554
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3555
    ^ green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3556
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3557
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3558
     Color green scaledRed    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3559
     Color black scaledRed  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3560
     Color grey scaledRed   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3561
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3562
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3563
    "Modified: 7.6.1996 / 18:32:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3564
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3565
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3566
scaledRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3567
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3568
     return the red components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3569
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3570
    ^ red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3571
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3572
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3573
     Color red scaledRed    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3574
     Color black scaledRed  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3575
     Color grey scaledRed   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3576
    "
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
    "Modified: 7.6.1996 / 18:32:43 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3579
!
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
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3582
    "set r/g/b components in 0..MaxValue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3583
     This method will change the color lookup table in pseudocolor devices.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3584
     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
  3585
     Color>>variableColorOn: on pseudoColor displays).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3586
     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
  3587
     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
  3588
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3589
    (colorId isNil or:[red notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3590
        ^ self error:'operation is not allowed for shared colors'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3591
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3592
    device setColor:colorId scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3593
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3594
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3595
writable
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3596
    "return true, if this is a writable colorcell"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3597
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3598
    ^ writable == true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3599
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3600
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3601
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3602
    "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
  3603
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3604
    ^ 100 - self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3605
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3606
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3607
    "Created: 11.6.1996 / 18:30:20 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3608
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3609
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3610
!Color methodsFor:'binary storage'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3611
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3612
readBinaryContentsFrom: stream manager: manager
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3613
    "tell the newly restored Color about restoration"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3614
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3615
    super readBinaryContentsFrom:stream manager:manager.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3616
    self postCopy
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3619
!Color methodsFor:'comparing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3620
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3621
= aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3622
    "two colors are considered equal, if the color components are;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3623
     independent of the device, the color is on"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3624
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3625
    aColor == self ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3626
    aColor isColor ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3627
        (red == aColor scaledRed) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3628
            (green == aColor scaledGreen) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3629
                (blue == aColor scaledBlue) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3630
                    ^ true
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3631
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3632
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3633
        ]
1023
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
    ^ false
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3636
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3637
1390
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3638
almostSameAs:aColor
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3639
    "return true, if aColor looks almost the same as the receiver
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3640
     (i.e. the components differ by a small, invisible amount).
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3641
     We assume, that the human eye can distinguish roughly 100 grey levels
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3642
     (which is optimistic ;-);
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3643
     therefore, allow a 1 percent difference in each component for the colors
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3644
     to compare as looking the same."
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3645
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3646
     (self red - aColor red) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3647
     (self green - aColor green) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3648
     (self blue - aColor blue) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3649
     ^ true
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3650
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3651
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3652
      (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
  3653
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3654
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3655
    "Modified: 28.2.1997 / 12:00:01 / cg"
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3656
!
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  3657
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3658
hash
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3659
    "return an integer useful as hash key for the receiver.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3660
     Redefined since = is redefined"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3661
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3662
    ^ red + green + blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3663
! !
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
!Color methodsFor:'converting'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3666
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3667
fromLiteralArrayEncoding:encoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3668
    "read my values from an encoding.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3669
     The encoding is supposed to be of the form: 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3670
        (#Color redPart greenPart bluePart)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3671
     This is the reverse operation to #literalArrayEncoding."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3672
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3673
    red := ((encoding at:2) / 100.0 * MaxValue) rounded.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3674
    green := ((encoding at:3) / 100.0 * MaxValue) rounded.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3675
    blue := ((encoding at:4) / 100.0 * MaxValue) rounded.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3676
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
      Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
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
!
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
literalArrayEncoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3683
    "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
  3684
     can be reconstructed with #decodeAsLiteralArray.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3685
     The encoding is: 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3686
        (#Color redPart greenPart bluePart)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3687
    "
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
    ^ Array
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3690
        with:self class name asSymbol
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3691
        with:(red * 100.0 / MaxValue)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3692
        with:(green * 100.0 / MaxValue)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3693
        with:(blue * 100.0 / MaxValue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3694
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3695
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3696
      Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3697
      (Color red:25 green:30 blue:70) literalArrayEncoding 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3698
    "
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
    "Modified: 22.4.1996 / 13:00:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3701
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3702
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3703
!Color methodsFor:'copying'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3704
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3705
postCopy
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3706
    "redefined to clear out any device handles in the copy"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3707
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3708
    device := colorId := ditherForm := replacementColor := nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3709
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3710
    "Modified: 17.1.1997 / 00:03:42 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3711
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3712
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3713
!Color methodsFor:'getting a device color'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3714
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3715
exactOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3716
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3717
     myself on aDevice; if one already exists, return the one.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3718
     Do not dither or otherwise approximate the color, but return
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3719
     nil, if the exact color is not available. 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3720
     Used to aquire primary colors for dithering, during startup."
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
    |newColor id r g b|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3723
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3724
    "if Iam already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3725
    (device == aDevice and:[ditherForm isNil]) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3726
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3727
    r := red.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3728
    g := green.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3729
    b := blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3730
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  3731
    "first look if not already there"
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  3732
    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
  3733
    (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
  3734
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3735
    r := (r bitAnd:16rFF00) bitOr:(r bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3736
    g := (g bitAnd:16rFF00) bitOr:(g bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3737
    b := (b bitAnd:16rFF00) bitOr:(b bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3738
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3739
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3740
    id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3741
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3742
        "/ this is a kludge: scavenge to free unused colors
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3743
        "/  and try again ...
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3744
        ObjectMemory scavenge; finalize.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3745
        id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3746
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3747
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3748
        "no such color - fail"
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
"/      'COLOR: no color for ' infoPrint. self displayString infoPrintCR.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3751
        ^ nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3752
    ].
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
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3755
    device isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3756
        device := aDevice.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3757
        colorId := id.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3758
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3759
        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
  3760
            "/ Lobby register:self.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3761
            aDevice registerColor:self.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3762
        ].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3763
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3764
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3765
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3766
    "receiver was already associated to another device - need a new color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3767
    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
  3768
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3769
    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
  3770
        "/ Lobby register:newColor.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3771
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3772
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3773
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3774
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3775
    "Modified: 24.2.1997 / 18:23:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3776
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3777
1856
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3778
exactOrNearestOn:aDevice
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3779
    "get a device color for the receiver, which is either exact
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3780
     or the nearest, but never dithered.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3781
     This can be used for viewBackgrounds, where the exact greyLevel
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3782
     does not matter, but a dithered color is not wanted."
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3783
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3784
    |deviceColor|
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3785
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3786
    deviceColor := self exactOn:aDevice.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3787
    deviceColor isNil ifTrue:[
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3788
        deviceColor := self nearestOn:aDevice
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3789
    ].
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3790
    ^ deviceColor
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3791
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3792
    "Created: 13.8.1997 / 15:25:48 / cg"
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3793
!
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  3794
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3795
nearestOn:aDevice 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3796
    "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
  3797
     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
  3798
     search for the nearest match"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3799
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3800
    |newColor id|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3801
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3802
    "if I'am already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3803
    (device == aDevice) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3804
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3805
    "first look if not already there"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3806
    newColor := Color nearestColorScaledRed:red scaledGreen:green scaledBlue:blue on:aDevice.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3807
    newColor notNil ifTrue:[^ newColor].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3808
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3809
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3810
    id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3811
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3812
        "this is a kludge: 
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3813
            scavenge to possuby free unused colors and try again ...
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3814
            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
  3815
            but that is too expensive.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3816
        "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3817
" "
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3818
        ObjectMemory scavenge; finalize.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3819
        id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3820
" "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3821
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3822
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3823
        "no color - fail"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3824
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3825
        ^ nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3826
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3827
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3828
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3829
    device isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3830
        device := aDevice.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3831
        colorId := id.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3832
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3833
        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
  3834
            "/ Lobby register:self.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3835
            aDevice registerColor:self.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3836
        ].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3837
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3838
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3839
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3840
    "receiver was already associated to another device - need a new color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3841
    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
  3842
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3843
    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
  3844
        "/ Lobby register:newColor.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3845
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3846
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3847
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3848
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3849
    "Modified: 24.2.1997 / 18:23:26 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3850
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3851
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3852
on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3853
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3854
     myself on aDevice; if one already exists, return the one"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3855
1855
dc59c0c86b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1770
diff changeset
  3856
    |newColor id form 
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3857
     greyV "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3858
     rV    "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3859
     gV    "{ Class: SmallInteger }" 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3860
     bV    "{ Class: SmallInteger }"
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3861
     deviceVisual deviceFixColors|
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3862
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3863
    "/ the most common cases (already allocated) first 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3864
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3865
    colorId notNil ifTrue:[
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3866
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3867
        "/ is someone validating me before drawing on aDevice ?
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3868
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3869
        aDevice notNil ifTrue:[
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3870
            aDevice == device ifTrue:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3871
                ^ self
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3872
            ]
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3873
        ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3874
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3875
        "/ a special case for pseudo-colors (0 and 1 in bitmaps)
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3876
        "/ those have nil r/g/b values, but a nonNil colorId
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3877
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3878
        red isNil ifTrue:[^ self].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3879
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3880
        "/ want to release color ?
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3881
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3882
        (aDevice isNil and:[device notNil]) ifTrue:[
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3883
            "/ trueColor device-colors are not registered
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3884
            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
  3885
                "/ Lobby unregister:self.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3886
                device unregisterColor:newColor.
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  3887
                device freeColor:colorId
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  3888
            ].
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3889
            device := nil.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3890
            colorId := nil.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3891
            ^ self
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  3892
        ].
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  3893
    ].
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  3894
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3895
    device == aDevice ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3896
        ditherForm notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3897
            ^ self
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3898
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3899
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3900
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3901
    "/ 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
  3902
    "/ especially freeing colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3903
    "/ (no need to remember in Lobby)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3904
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3905
    (deviceVisual := aDevice visualType) == #TrueColor ifTrue:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3906
        aDevice depth >= 15 ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3907
            id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3908
            id notNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3909
                device isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3910
                    colorId := id.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3911
                    ditherForm := nil.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3912
                    ^ self
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3913
                ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3914
                newColor := (self class basicNew) 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3915
                                    setScaledRed:red 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3916
                                    scaledGreen:green 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3917
                                    scaledBlue:blue 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3918
                                    device:aDevice.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3919
                newColor setColorId:id.
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3920
                ^ newColor
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3921
            ] 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3922
        ] 
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3923
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3924
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3925
    "/ round a bit within 1% in red & green, 2% in blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3926
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  3927
    rV := red.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  3928
    gV := green.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  3929
    bV := blue.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  3930
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  3931
"/    rV := (red / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  3932
"/    gV := (green / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  3933
"/    bV := (blue / 50.0) rounded * 50.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3934
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3935
    "/ if I am already assigned to that device ...
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  3936
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3937
"/    ((device == aDevice) and:[ditherForm notNil]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3938
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3939
"/        "/ 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
  3940
"/        "/ try again - maybe some colors were reclaimed in the meanwhile
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3941
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3942
"/        deviceFixColors := aDevice fixColors.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3943
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3944
"/        (deviceFixColors isNil
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3945
"/         and:[RetryAllocation]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3946
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3947
"/             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
  3948
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3949
"/            aDevice depth > 2 ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3950
"/                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3951
"/                id notNil ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3952
"/                    colorId := id.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3953
"/                    ditherForm := nil.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3954
"/                    "/ Lobby register:self.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3955
"/                    device registerColor:self.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3956
"/                ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3957
"/            ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3958
"/        ].
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3959
"/        ^ self
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3960
"/    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3961
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3962
    newColor := Color existingColorScaledRed:rV scaledGreen:gV scaledBlue:bV on:aDevice.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3963
    newColor notNil ifTrue:[^ newColor].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3964
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3965
    "/
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3966
    "/ ok, we are going to dither that color.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3967
    "/ 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
  3968
    "/
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3969
    greyV := (3 * red) + (6 * green) + (1 * blue).
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3970
    greyV := (greyV / 1000.0) rounded * 100.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3971
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3972
    "/ allow an error of 1% in red & green, 2% in blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3973
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3974
    ((rV - greyV) abs <= 655                    "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3975
    and:[(gV - greyV) abs <= 655                "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3976
    and:[(bV - greyV) abs <= 1310]]) ifTrue:[   "/ MaxValue // 100 * 2
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3977
        rV := gV := bV := greyV.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3978
    ] ifFalse:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3979
        rV := red. gV := green. bV := blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3980
    ].
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
    aDevice hasColors ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  3983
        deviceFixColors := aDevice fixColors.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3984
        deviceFixColors isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3985
            "/ ask that device for the exact color
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3986
            id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3987
            id isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3988
                "/ this is a kludge: scavenge to free unused colors
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3989
                "/ and try again ...
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3990
                ObjectMemory scavenge; finalize.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3991
                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3992
            ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3993
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3994
            id isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3995
                "/ no such color - try color dithers
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3996
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3997
                self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3998
                    ditherRed:rV green:gV blue:bV 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3999
                    on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4000
                    into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4001
                newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4002
            ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4003
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4004
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4005
        "/ none found ? -> do a hard dither using fixColors
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4006
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4007
        (id isNil and:[form isNil]) ifTrue:[
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4008
            deviceFixColors notNil ifTrue:[
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4009
                self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4010
                    fixDitherRed:rV green:gV blue:bV 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4011
                    on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4012
                    into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4013
                newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4014
            ]
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4015
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4016
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4017
        "/ still none found ? -> do a very hard dither using existing colors
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4018
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4019
        (id isNil and:[form isNil]) ifTrue:[
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4020
            self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4021
                complexDitherRed:rV green:gV blue:bV 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4022
                on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4023
                into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4024
            newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4025
        ].
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4028
    (id isNil and:[form isNil]) ifTrue:[
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4029
        "still no result - try graying"
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4030
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4031
        greyV == 0 ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4032
            id := aDevice blackpixel
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4033
        ] ifFalse:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4034
            greyV == MaxValue ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4035
                id := aDevice whitepixel
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4036
            ] ifFalse:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4037
                aDevice hasGrayscales ifTrue:[
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4038
                    self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4039
                        ditherGrayFor:(greyV / MaxValue)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4040
                        on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4041
                        into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4042
                    newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4043
                ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4044
                form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4045
                    "/ still none - dither b&w
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4046
                    self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4047
                        monoDitherFor:(greyV / MaxValue)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4048
                        between:Black and:White
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4049
                        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4050
                        into:[:c :f | newColor := c. form := f].
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4051
                    newColor notNil ifTrue:[^ newColor].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4052
                    form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4053
                        "/ cannot happen
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4054
                        'Color [warning]: monoDither failed' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4055
                        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4056
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4057
                ]
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4058
            ]
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4059
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4060
    ].
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
    device isNil ifTrue:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4063
        "/ receiver was not associated - do it now & return mySelf
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4064
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4065
        device := aDevice.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4066
        id isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4067
            ditherForm := form
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4068
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4069
        colorId := id.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4070
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4071
        "/ have to tell Lobby - otherwise it keeps old info around
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4072
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4073
        id notNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4074
            deviceVisual ~~ #TrueColor ifTrue:[    
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4075
                "/ Lobby register:self.
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4076
                aDevice registerColor:self.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4077
            ]
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4078
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4079
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4080
    ].
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
    "/ receiver was already associated to another device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4083
    "/ - need a new color and return it
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4084
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4085
    newColor := (self class basicNew) 
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4086
                        setScaledRed:red 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4087
                        scaledGreen:green 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4088
                        scaledBlue:blue 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4089
                        device:aDevice.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4090
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4091
        newColor setDitherForm:form
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4092
    ] ifFalse:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4093
        newColor setColorId:id.
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4094
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4095
        "/ trueColor device-colors are not registered
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4096
        deviceVisual ~~ #TrueColor ifTrue:[    
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4097
            "/ Lobby register:newColor.
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4098
            aDevice registerColor:newColor.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4099
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4100
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4101
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4102
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4103
    "Created: 16.11.1995 / 20:16:42 / cg"
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4104
    "Modified: 3.5.1997 / 11:09:30 / cg"
1502
684c734d784b #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  4105
!
684c734d784b #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  4106
684c734d784b #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  4107
onDevice:aDevice
684c734d784b #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  4108
    "create a new Color representing the same color as
684c734d784b #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  4109
     myself on aDevice; if one already exists, return the one"
684c734d784b #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  4110
684c734d784b #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  4111
    ^ self on:aDevice
684c734d784b #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  4112
684c734d784b #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  4113
    "Created: 29.3.1997 / 16:20:09 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4114
! !
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
!Color methodsFor:'inspecting'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4117
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4118
inspectorClass
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4119
    "return the class of an appropriate inspector.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4120
     ST/X has a specialized ColorInspectorView for that"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4121
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4122
    ^ ColorInspectorView
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4123
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4124
    "Modified: 23.4.1996 / 13:39:50 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4125
! !
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
!Color methodsFor:'instance creation'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4128
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4129
asHiliteColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4130
    "same as lightened - for ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4131
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4132
    ^ self lightened
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4135
asShadowColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4136
    "same as darkened - for ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4137
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4138
    ^ self darkened
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4141
blendWith:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4142
    "create a new color from equally mixing the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4143
     and the argument, aColor.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4144
     Mixing is done by adding components 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4145
     (which is different from mixing colors on paper ..)"
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 ifTrue:[
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4148
        ^ aColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4149
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4150
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4151
    ^ (self class)
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4152
        scaledRed:(red + aColor scaledRed) // 2
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4153
        scaledGreen:(green + aColor scaledGreen) // 2
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4154
        scaledBlue:(blue + aColor scaledBlue) // 2
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4155
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4156
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4157
     (Color red) blendWith:(Color yellow)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4158
     (Color red) blendWith:(Color blue)
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4159
     (Color red) blendWith:(Color black)
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4160
     (Color red) blendWith:(Color white)
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
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4163
    "Modified: 10.2.1997 / 22:08:14 / cg"
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4166
darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4167
    "return a new color, which is slightly darker than the receiver"
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
    ^ self blendWith:Black
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
     (Color red) darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4173
     (Color red) darkened darkened
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4176
    "Modified: 11.6.1996 / 18:10:37 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4177
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4178
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4179
lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4180
    "return a new color, which is slightly lighter than the receiver"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4181
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4182
    ^ self blendWith:White
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4183
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4184
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4185
     (Color red) lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4186
     (Color red) lightened lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4187
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4188
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4189
    "Modified: 11.6.1996 / 18:10:49 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4190
! !
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
!Color methodsFor:'instance release'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4193
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4194
shallowCopyForFinalization
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4195
    "redefined, since for finalization only device and colorIndex
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4196
     are needed - thus a faster copy is possible here"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4197
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4198
    |aCopy|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4199
1234
f06543bb7a8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  4200
    aCopy := DeviceColorHandle basicNew.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4201
    aCopy setDevice:device colorId:colorId.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4202
    ^ aCopy
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4203
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4204
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4205
!Color methodsFor:'printing & storing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4206
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4207
printOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4208
    "append a string representing of the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4209
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4210
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4211
    self storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4212
!
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
storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4215
    "append a string representing an expression to reconstruct the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4216
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4217
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4218
    red isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4219
        colorId notNil ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4220
            aStream nextPutAll:'(Color colorId:'.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4221
            colorId storeOn:aStream.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4222
            aStream nextPut:$).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4223
            ^ self
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4224
        ]
1023
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
    (red == green and:[red == blue]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4227
        red == 0 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4228
            aStream nextPutAll:'(Color black)'.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4229
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4230
            red == MaxValue ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4231
                aStream nextPutAll:'(Color white)'.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4232
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4233
                aStream nextPutAll:'(Color grey:'.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4234
                (self red) storeOn:aStream.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4235
                aStream nextPut:$).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4236
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4237
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4238
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4239
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4240
    aStream nextPutAll:'(Color red:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4241
    (self red) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4242
    aStream nextPutAll:' green:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4243
    (self green) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4244
    aStream nextPutAll:' blue:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4245
    (self blue) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4246
    aStream nextPut:$).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4247
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4248
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4249
!Color methodsFor:'private'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4250
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4251
restored
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4252
    "private: color has been restored (either from snapin or binary store);
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4253
     flush device stuff or reallocate a cell."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4254
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4255
    ditherForm := replacementColor := nil.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4256
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4257
    red notNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4258
        device := nil.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4259
        colorId := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4260
    ] ifFalse:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4261
        "a variable color has been restored"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4262
        (colorId notNil and:[writable == true and:[device notNil]]) ifTrue:[
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4263
            colorId := device colorCell.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4264
            device setColor:colorId scaledRed:red scaledGreen:green scaledBlue:blue
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4265
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4266
    ]
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4267
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4268
    "Modified: 17.1.1997 / 00:04:14 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4269
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4270
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4271
setColorId:anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4272
    "private: set the deviceId"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4273
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4274
    colorId := anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4275
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4276
    "Created: 17.1.1997 / 00:05:41 / cg"
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4279
setDevice:aDevice colorId:aNumber
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4280
    "private:set device and colorId"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4281
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4282
    device := aDevice.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4283
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4284
    writable := false.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4285
!
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4286
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4287
setDevice:aDevice colorId:aNumber writable:wBool
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4288
    "private:set device, colorId and writable flag"
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4289
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4290
    device := aDevice.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4291
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4292
    writable := wBool.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4293
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4294
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4295
setDitherForm:aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4296
    "private: set the ditherForm"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4297
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4298
    ditherForm := aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4299
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4300
    "Created: 17.1.1997 / 00:04:57 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4301
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4302
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4303
setScaledRed:r scaledGreen:g scaledBlue:b device:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4304
    "private: set the components"
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
    red notNil ifTrue:[
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4307
        "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
  4308
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4309
        self error:'Colors cannot change their components'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4310
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4311
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4312
    red := r.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4313
    green := g.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4314
    blue := b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4315
    device := aDevice
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4316
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4317
    "Modified: 16.1.1997 / 22:39:26 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4318
! !
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
!Color methodsFor:'queries'!
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
averageColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4323
    "return the average color - thats myself.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4324
     This method has been added for compatibility with the image
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4325
     protocol."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4326
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4327
    ^ self 
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4330
averageColorIn:aRectangle
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4331
    "return the average color - thats myself.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4332
     This method has been added for compatibility with the image
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4333
     protocol."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4334
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4335
    ^ self 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4336
!
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
brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4339
    "ST80 compatibility: return the grey intensity in [0..1]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4340
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4341
    ^ ((3 * red) + (6 * green) + (blue)) / 10.0 / MaxValue
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
    "Modified: 7.6.1996 / 19:42:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4344
!
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
deltaFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4347
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4348
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4349
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4350
    ^ aColor deltaFromRed:self red green:self green blue:self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4351
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4352
    "Created: 14.6.1996 / 20:07:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4353
    "Modified: 14.6.1996 / 20:49:32 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4354
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4355
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4356
deltaFromRed:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4357
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4358
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4359
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
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4362
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4363
    ^ (self red - r) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4364
      + (self green - g) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4365
      + (self blue - b) abs.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4366
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4367
    "Created: 14.6.1996 / 20:03:58 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4368
    "Modified: 14.6.1996 / 20:20:24 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4371
deltaFromScaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4372
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4373
     by r/g/b values"
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
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4377
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4378
    ^ (red - r) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4379
      + (green - g) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4380
      + (blue - b) abs.
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
    "Created: 11.6.1996 / 18:01:12 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4383
    "Modified: 14.6.1996 / 20:36:14 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4386
errorFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4387
    "return some value which can be used to compare colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4388
     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
  4389
     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
  4390
     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
  4391
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4392
    ^ (red - aColor scaledRed) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4393
       + (green - aColor scaledGreen) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4394
       + (blue - aColor scaledBlue) squared.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4395
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4396
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4397
grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4398
    "return the grey intensity in percent [0..100] (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4399
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4400
    ^ ((3 * red) + (6 * green) + (1 * blue)) * 10.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4401
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4402
    "Created: 2.5.1996 / 11:38:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4403
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4404
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4405
greyIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4406
    "return the grey intensity in percent [0..100] (English version ;-)"
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
    ^ self grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4409
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4410
    "Modified: 28.5.1996 / 20:45:41 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4413
isColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4414
    "return true if the receiver is a Color."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4415
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4416
    ^ true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4417
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4418
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4419
isDithered
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4420
    "return true, if this is a dithered Color.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4421
     Only makes sense if the receiver is a device color."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4422
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4423
    ^ ditherForm notNil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4424
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4425
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4426
isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4427
    "same as isGrayColor - for ST80 compatibility."
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4428
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4429
    ^ self isGrayColor
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4430
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4431
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4432
     (Color grey:50) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4433
     (Color red) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4434
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4435
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4436
    "Created: 10.2.1997 / 22:10:25 / cg"
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4437
!
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4438
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4439
isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4440
    "return true, if this color is a gray one -
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4441
     i.e. red = green = blue"
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
    red ~~ green ifTrue:[^ false].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4444
    ^ red == blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4445
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4446
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4447
     (Color grey:50) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4448
     (Color red) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4449
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4450
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4451
    "Created: 2.5.1996 / 11:38:48 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4452
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4453
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4454
isGreyColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4455
    "return true, if this color is a grey one (English version ;-) -
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4456
     i.e. red = green = blue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4457
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4458
    ^ self isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4459
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4460
    "(Color grey:50) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4461
    "(Color red) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4462
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4463
    "Modified: 28.5.1996 / 20:44:36 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4464
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4465
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4466
!Color methodsFor:'testing'!
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4467
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4468
isColorObject
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4469
    ^ true
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4470
! !
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4471
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4472
!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
  4473
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4474
documentation
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4475
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4476
    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
  4477
    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
  4478
    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
  4479
    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
  4480
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4481
    [see also:]
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4482
        Color
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4483
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4484
    [author:]
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4485
        Claus Gittinger
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4486
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4487
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4488
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4489
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4490
!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
  4491
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4492
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
  4493
    "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
  4494
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4495
    device := aDevice.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4496
    colorId := anId.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4497
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4498
    "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
  4499
    "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
  4500
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4501
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4502
!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
  4503
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4504
disposed
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4505
    "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
  4506
     - release system resources"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4507
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4508
    colorId notNil ifTrue:[
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4509
        device freeColor:colorId.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4510
        colorId := nil.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4511
    ].
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4512
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4513
    "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
  4514
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  4515
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4516
!Color class methodsFor:'documentation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4517
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4518
version
2077
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  4519
    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.112 1998-03-07 16:28:47 tz Exp $'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4520
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4521
Color initialize!