Color.st
author Claus Gittinger <cg@exept.de>
Tue, 22 Aug 2000 12:11:24 +0200
changeset 3264 ab71c2bd250f
parent 3240 c93e33069fb5
child 3277 9b1f784f04b2
permissions -rw-r--r--
fixed #brightness:
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
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
    13
"{ Package: 'stx:libview' }"
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
    14
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    15
Object subclass:#Color
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    16
	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
    17
		writable'
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    18
	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
    19
		Pseudo1 PseudoAll Red Green Blue RetryAllocation DitherBits
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
    20
		ColorErrorSignal ColorAllocationFailSignal InvalidColorNameSignal
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
    21
		StandardColorValues Transparent'
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    22
	poolDictionaries:''
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    23
	category:'Graphics-Support'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    24
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    25
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    26
Object subclass:#DeviceColorHandle
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    27
	instanceVariableNames:'device colorId'
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    28
	classVariableNames:''
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    29
	poolDictionaries:''
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    30
	privateIn:Color
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    31
!
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    32
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    33
!Color class methodsFor:'documentation'!
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    36
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    37
 COPYRIGHT (c) 1992 by Claus Gittinger
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
    38
              All Rights Reserved
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    39
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    40
 This software is furnished under a license and may be used
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    41
 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
    42
 inclusion of the above copyright notice.   This software may not
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    43
 be provided or otherwise made available to, or used by, any
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    44
 other person.  No title to or ownership of the software is
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    45
 hereby transferred.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    46
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    47
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    48
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    49
documentation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    50
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    51
    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
    52
    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
    53
    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
    54
    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
    55
    for that device.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    56
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    57
    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
    58
    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
    59
    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
    60
    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
    61
    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
    62
    colormap (as usual for bitmaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    63
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    64
    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
    65
    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
    66
    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
    67
    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
    68
    to ugly looking dither colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    69
    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
    70
    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
    71
    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
    72
    (beside 5x5x5, there are various other size combinations available).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    73
    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
    74
    preallocated table may steal colors from the image ...
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
    [Instance variables:]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    77
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    78
      red             <Integer>       the red component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    79
      green           <Integer>       the green component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    80
      blue            <Integer>       the blue component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    81
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    82
      device          <Device>        the device I am on, or nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    83
      colorId         <Object>        some device dependent identifier (or nil if dithered)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    84
      ditherForm      <Form>          the Form to dither this color (if non-nil)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    85
      writable        <Boolean>       true if this is for a writable color cell
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
    [Class variables:]
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
      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
    90
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    91
      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
    92
                                      colors for reuse and finalization.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    93
                                      (dont use it: this will be moved to the device)
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    94
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    95
      Cells           <Registry>      keeps track of allocated writable color cells
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
    96
                                      (dont use it: this will be moved to the device)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    97
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    98
      FixColors       <Array>         preallocated colors for dithering on Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    99
      NumRedFix       <Integer>       number of distinct red values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   100
      NumGreenFix     <Integer>       number of distinct green values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   101
      NumBlueFix      <Integer>       number of distinct blue values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   102
    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   103
      Black           <Color>         for fast return of black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   104
      White           <Color>         for fast return of white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   105
      Grey            <Color>         for fast return of grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   106
      LightGrey       <Color>         for fast return of lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   107
      DarkGrey        <Color>         for fast return of darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   108
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   109
      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
   110
      Pseudo1         <Color>         a color with 1 as handle (for forms)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   111
      PseudoAll       <Color>         a color with allPlanes as handle (for bitblit)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   112
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   113
      Red             <Color>         red, needed for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   114
      Green           <Color>         green, for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   115
      Blue            <Color>         blue, for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   116
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   117
      DitherColors    <Collection>    some preallocated colors for dithering
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   118
                                      (kept, so they are available when needed)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   119
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   120
      RetryAllocation <Boolean>       this flag controls how a request for a
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   121
                                      color should be handled which failed previously.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   122
                                      I.e. a color is asked for, which was dithered
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   123
                                      the last time. Since it could happen, that in
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   124
                                      the meantime more colors became free, the request
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   125
                                      might succeed this time - however, your screen may
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   126
                                      look a bit funny, due to having both dithered and
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   127
                                      undithered versions around.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   128
                                      The default is true, which means: do retry
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   129
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   130
    compatibility issues:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   131
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   132
        ST-80 seems to represent colors internally with scaled smallInteger
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   133
        components (this can be guessed from uses of
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   134
        scaledRed:scaledGreen:scaledBlue:). The main instance creation method is
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   135
        via 'ColorValue red:green:blue:', passing components in 0..1.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   136
        In ST/X, component are internally represented as percent.
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   137
        For more compatibility (when subclassing color), these internals may
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   138
        change in the near future. For migration, a compatibility subclass
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   139
        called ColorValue is provided. 
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   140
        After the change, Color will be renamed to ColorValue and Color
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   141
        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
   142
        backward compatibility).
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   143
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   144
    [see also:]
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   145
        DeviceWorkstation 
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   146
        GraphicsContext DeviceDrawable Form Image Colormap
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   147
        Font Cursor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   148
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   149
    [author:]
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   150
        Claus Gittinger
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   151
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   152
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   153
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   154
!Color class methodsFor:'initialization'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   155
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   156
flushDeviceColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   157
    "unassign all colors from their device"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   158
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   159
    self allInstances do:[:aColor |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   160
        aColor restored
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   161
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   162
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   163
    "Modified: 24.2.1997 / 18:27:06 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   164
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   165
3240
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   166
flushDeviceColorsFor:aDevice
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   167
    self allInstancesDo:[:aColor |
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   168
        aColor device == aDevice ifTrue:[
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   169
            aColor restored
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   170
        ]
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   171
    ]
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   172
!
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   173
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   174
getColors6x6x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   175
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   176
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   177
    "preallocates a 6x6x4 (144) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   178
     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
   179
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   180
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   181
    self getColorsRed:6 green:6 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   182
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   183
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   184
     Color getColors6x6x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   185
    "
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
getColors6x6x5
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   189
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   190
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   191
    "preallocates a 6x6x5 (180) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   192
     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
   193
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   194
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   195
    self getColorsRed:6 green:6 blue:5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   196
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   197
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   198
     Color getColors6x6x5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   199
    "
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
getColors6x6x6
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   203
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   204
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   205
    "preallocates a 6x6x6 (196) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   206
     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
   207
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   208
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   209
    self getColorsRed:6 green:6 blue:6
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   210
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   211
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   212
     Color getColors6x6x6
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   213
    "
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
getColors6x7x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   217
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   218
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   219
    "preallocates a 6x7x4 (168) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   220
     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
   221
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   222
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   223
    self getColorsRed:6 green:7 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   224
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   225
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   226
     Color getColors6x7x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   227
    "
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
    "Created: 12.6.1996 / 17:41:57 / cg"
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
getColors7x8x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   233
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   234
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   235
    "preallocates a 7x8x4 (224) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   236
     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
   237
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   238
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   239
    self getColorsRed:7 green:8 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   240
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   241
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   242
     Color getColors7x8x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   243
    "
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
getColorsRed:nRed green:nGreen blue:nBlue
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   247
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   248
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   249
    "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
   250
     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
   251
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   252
2999
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   253
    self getColorsRed:nRed green:nGreen blue:nBlue on:Screen current
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   254
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   255
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   256
     Color getColorsRed:2 green:2 blue:2
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   257
    "
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
    "Modified: 11.7.1996 / 17:58:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   260
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   261
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   262
getColorsRed:nRed green:nGreen blue:nBlue on:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   263
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   264
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   265
    "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
   266
     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
   267
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   268
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   269
    |nR "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   270
     nG "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   271
     nB "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   272
     dR dG dB red green blue dstIndex clr round
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   273
     fixColors|
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
    aDevice visualType == #TrueColor ifTrue:[^ self].
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
    nR := nRed.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   278
    nG := nGreen.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   279
    nB := nBlue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   280
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   281
    dR := 100.0 / (nR - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   282
    dG := 100.0 / (nG - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   283
    dB := 100.0 / (nB - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   284
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   285
    fixColors := Array new:(nR * nG * nB).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   286
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   287
    round := 0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   288
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   289
    dstIndex := 1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   290
    1 to:nR do:[:sR |
1165
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   291
        red := dR * (sR - 1).
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   292
        1 to:nG do:[:sG |
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   293
            green := dG * (sG - 1).
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   294
            1 to:nB do:[:sB |
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   295
                blue := dB * (sB - 1).
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   296
                clr := (self red:red green:green blue:blue) exactOn:aDevice.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   297
                clr isNil ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   298
                    round == 0 ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   299
                        'Color [info]: scavenge to reclaim colors' infoPrintCR.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   300
                        ObjectMemory scavenge.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   301
                        round := 1.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   302
                        clr := (self red:red green:green blue:blue) exactOn:aDevice.
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
                ].
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   305
                clr isNil ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   306
                    round == 1 ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   307
                        'Color [info]: collect garbage to reclaim colors' infoPrintCR.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   308
                        ObjectMemory performLowSpaceCleanup.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   309
                        ObjectMemory garbageCollect.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   310
                        round := 2.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   311
                        clr := (self red:red green:green blue:blue) exactOn:aDevice.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   312
                   ].
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   313
                ].
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   314
                clr isNil ifTrue:[
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   315
                    ColorAllocationFailSignal raiseErrorString:'failed to allocate fix color'.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   316
                    ^ self
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   317
                ].
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   318
                fixColors at:dstIndex put:clr.
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   319
                dstIndex := dstIndex + 1
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   320
            ]
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   321
        ]
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
    aDevice setFixColors:fixColors
1165
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   324
                  numRed:nR numGreen:nG numBlue:nB
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   325
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   326
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   327
     Color getColorsRed:2 green:2 blue:2 on:Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   328
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   329
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   330
    "Created: 11.7.1996 / 17:55:32 / cg"
1165
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   331
    "Modified: 10.1.1997 / 15:37:13 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   332
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   333
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   334
getGrayColors:nGray on:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   335
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   336
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   337
    "preallocates nGray gray colors for later use in dithering.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   338
     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
   339
     however, colors may be either inexact or dithered."
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   340
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   341
    |nG "{Class: SmallInteger }"
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   342
     d gray dstIndex clr round
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   343
     fixGrayColors|
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   344
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   345
    aDevice visualType == #TrueColor ifTrue:[^ self].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   346
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   347
    nG := nGray.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   348
    d := 100.0 / (nG - 1).
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   349
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   350
    fixGrayColors := Array new:nG.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   351
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   352
    round := 0.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   353
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   354
    dstIndex := 1.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   355
    1 to:nG do:[:sG |
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   356
        gray := d * (sG - 1).
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   357
        clr := (self red:gray green:gray blue:gray) exactOn:aDevice.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   358
        clr isNil ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   359
            round == 0 ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   360
                'Color [info]: scavenge to reclaim colors' infoPrintCR.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   361
                ObjectMemory scavenge.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   362
                round := 1.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   363
                clr := (self red:gray green:gray blue:gray) exactOn:aDevice.
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
        ].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   366
        clr isNil ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   367
            round == 1 ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   368
                'Color [info]: collect garbage to reclaim colors' infoPrintCR.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   369
                ObjectMemory performLowSpaceCleanup.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   370
                ObjectMemory garbageCollect.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   371
                round := 2.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   372
                clr := (self red:gray green:gray blue:gray) exactOn:aDevice.
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
        clr isNil ifTrue:[
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   376
            ColorAllocationFailSignal raiseErrorString:'failed to allocate fix gray color'.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   377
            ^ self
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   378
        ].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   379
        fixGrayColors at:dstIndex put:clr.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   380
        dstIndex := dstIndex + 1
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   381
    ].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   382
    aDevice setFixGrayColors:fixGrayColors
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   383
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   384
    "
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   385
     Color getGrayColors:16 on:Display
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   386
    "
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   387
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   388
    "Created: 23.6.1997 / 15:29:50 / cg"
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   389
!
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   390
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   391
getPrimaryColorsOn:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   392
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   393
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   394
    "preallocate the primary colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   395
     Doing so during early startup prevents us from running out
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   396
     of (at least those required) colors later.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   397
     This guarantees, that at least some colors are available
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   398
     for dithering (although, with only black, white, red, green and blue,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   399
     dithered images look very poor)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   400
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   401
    |colors white black red green blue clr dDepth
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   402
     lastPix "{ Class: SmallInteger }" |
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   403
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   404
    (aDevice notNil and:[aDevice ditherColors isNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   405
        white := (self red:100 green:100 blue:100) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   406
        white colorId isNil ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   407
            'Color [warning]: cannot allocate white color' errorPrintCR.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   408
        ].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   409
        black := (self red:0 green:0 blue:0) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   410
        black colorId isNil ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   411
            'Color [warning]: cannot allocate black color' errorPrintCR.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   412
        ].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   413
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   414
        aDevice hasColors ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   415
            red := (self red:100 green:0 blue:0) exactOn:aDevice.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   416
            green := (self red:0 green:100 blue:0) exactOn:aDevice.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   417
            blue := (self red:0 green:0 blue:100) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   418
            (red isNil 
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   419
            or:[green isNil 
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   420
            or:[blue isNil 
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   421
            or:[red colorId isNil
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   422
            or:[green colorId isNil
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   423
            or:[blue colorId isNil]]]]]) ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   424
                'Color [warning]: cannot allocate primary color(s)' errorPrintCR.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   425
                dDepth := aDevice depth.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   426
                ((dDepth >= 4) and:[dDepth <= 8]) ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   427
                    "/
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   428
                    "/ see what we have ...
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   429
                    "/
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   430
                    lastPix := (1 bitShift:dDepth) - 1.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   431
                    0 to:lastPix do:[:pixel |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   432
                        colors := OrderedCollection new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   433
                        aDevice getRGBFrom:pixel into:[:r :g :b |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   434
                            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
   435
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   436
                    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   437
                    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
   438
                    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
   439
                    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
   440
                ] ifFalse:[
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   441
                    aDevice hasColors:false.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   442
                    aDevice hasGrayscales:false.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   443
                    red := green := blue := nil.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   444
                ]
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   445
            ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   446
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   447
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   448
        aDevice == Display ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   449
            "/ keep those around for the main display
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   450
            White := white.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   451
            Black := black.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   452
            Red := red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   453
            Green := green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   454
            Blue := blue
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   455
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   456
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   457
        aDevice visualType ~~ #TrueColor ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   458
            aDevice hasColors ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   459
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   460
                "preallocate some colors for dithering 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   461
                 - otherwise, they may not be available when we need them ...
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   462
                 these are: black, white, grey50,
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   463
                            red, green, blue, yellow, cyan and magenta.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   464
                "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   465
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   466
                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
   467
                clr := (self gray:50) exactOn:aDevice.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   468
                (clr notNil and:[clr colorId notNil]) ifTrue:[
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   469
                    colors add:clr
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   470
                ].
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   471
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   472
                colors add:white; add:black; add:red; add:green; add:blue.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   473
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   474
                colors add:((self red:100 green:100 blue:0) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   475
                colors add:((self red:100 green:0 blue:100) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   476
                colors add:((self red:0 green:100 blue:100) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   477
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   478
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   479
            aDevice hasGrayscales ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   480
                aDevice hasColors ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   481
                    colors := OrderedCollection new.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   482
                    colors add:((self gray:50) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   483
                    colors add:white; add:black.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   484
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   485
                ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   486
                colors add:((self gray:25) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   487
                colors add:((self gray:33) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   488
                colors add:((self gray:67) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   489
                colors add:((self gray:75) exactOn:aDevice).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   490
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   491
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   492
            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
   493
                colors := colors select:[:clr | clr notNil and:[clr colorId notNil]].
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   494
                aDevice setDitherColors:(colors asArray).
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   495
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   496
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   497
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   498
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   499
    "Created: 11.7.1996 / 18:09:28 / cg"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   500
    "Modified: 21.10.1997 / 02:42:28 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   501
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   502
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   503
initialize
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   504
    "setup tracker of known colors and initialize classvars with
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   505
     heavily used colors"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   506
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   507
    ColorErrorSignal isNil ifTrue:[
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   508
        ColorErrorSignal := ErrorSignal newSignalMayProceed:true.
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   509
        ColorErrorSignal nameClass:self message:#colorErrorSignal.
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   510
        ColorErrorSignal notifierString:'color error'.
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   511
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   512
        ColorAllocationFailSignal := ColorErrorSignal newSignalMayProceed:true.
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   513
        ColorAllocationFailSignal nameClass:self message:#colorAllocationFailSignal.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   514
        ColorAllocationFailSignal notifierString:'color allocation failed'.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   515
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   516
        InvalidColorNameSignal := ColorErrorSignal newSignalMayProceed:true.
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   517
        InvalidColorNameSignal nameClass:self message:#invalidColorNameSignal.
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   518
        InvalidColorNameSignal notifierString:'invalid color name'.
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   519
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   520
        MaxValue := 16rFFFF.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   521
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   522
        "want to be informed when returning from snapshot"
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   523
        ObjectMemory addDependent:self.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   524
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   525
        RetryAllocation := true.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   526
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   527
        DitherBits := self ditherBits.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   528
        self initializeStandardColorNames.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   529
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   530
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   531
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   532
     Color initialize
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   533
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   534
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   535
    "Modified: / 30.9.1998 / 21:56:50 / cg"
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   536
!
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   537
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   538
initializeStandardColorNames
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   539
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   540
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   541
    "setup standard colors"
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   542
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   543
    StandardColorValues := Dictionary new.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   544
    #(
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   545
                'red'     (16rFFFF 16r0000 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   546
                'green'   (16r0000 16rFFFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   547
                'blue'    (16r0000 16r0000 100)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   548
                'yellow'  (16rFFFF 16rFFFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   549
                'magenta' (16rFFFF 16r0000 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   550
                'cyan'    (16r0000 16rFFFF 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   551
                'white'   (16rFFFF 16rFFFF 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   552
                'black'   (16r0000 16r0000 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   553
                'olive'   (16r7FFF 16r7FFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   554
                'teal'    (16r0000 16r7FFF 16r7FFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   555
                'silver'  (16r6666 16r6666 16r6666)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   556
                'lime'    (16r3333 16rFFFF 16r0000)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   557
                'fuchsia' (16r9999 16r07ae 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   558
                'aqua'    (16r199a 16rFFFF 16rFFFF)
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   559
    ) pairWiseDo:[:name :value |
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   560
        StandardColorValues at:name put:value
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   561
    ].
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   562
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   563
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   564
     Color initializeStandardColorNames
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   565
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   566
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   567
    "Modified: 6.3.1997 / 02:28:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   568
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   569
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   570
update:something with:aParameter from:changedObject
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   571
    "handle image restarts and flush any device resource handles"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   572
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   573
    (something == #returnFromSnapshot) ifTrue:[
2999
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   574
	Display notNil ifTrue:[
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   575
            Display visualType == #TrueColor ifTrue:[
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   576
                Display releaseFixColors
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   577
            ] ifFalse:[
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   578
                Display fixColors notNil ifTrue:[
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   579
                    ColorAllocationFailSignal handle:[:ex |
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   580
                        ex return
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   581
                    ] do:[
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   582
                        |nR nG nB|
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   583
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   584
                        nR := Display numFixRed.
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   585
                        nG := Display numFixGreen.
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   586
                        nB := Display numFixBlue.
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   587
                        Display releaseFixColors.
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   588
                        self getColorsRed:nR
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   589
                                    green:nG
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   590
                                     blue:nB
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   591
                                       on:Display
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   592
		    ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   593
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   594
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   595
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   596
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   597
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   598
    "Created: 15.6.1996 / 15:14:03 / cg"
1370
37dfdffdd4b6 getPrimaryColors now invoked from device
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   599
    "Modified: 24.2.1997 / 22:08:05 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   600
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   601
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   602
!Color class methodsFor:'instance creation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   603
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   604
allColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   605
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   606
     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
   607
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   608
    PseudoAll isNil ifTrue:[
2288
4241c24b7e2a no manfred, pseudoAll is always all - also on windows.
Claus Gittinger <cg@exept.de>
parents: 2198
diff changeset
   609
        PseudoAll := self basicNew setColorId:-1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   610
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   611
    ^ PseudoAll
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   612
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   613
    "Modified: 17.1.1997 / 00:05:36 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   614
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   615
2455
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   616
bgrValue:bgr
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   617
    "return a color from a 24bit BGR value (intentionally not RGB);
2455
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   618
     The value is composed of b<<16 + g<<8 + r.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   619
     (this byte-order is sometimes encountered with windows systems (progs)"
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   620
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   621
    |r g b|
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   622
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   623
    b := (bgr bitShift:-16) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   624
    g := (bgr bitShift:-8) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   625
    r := (bgr) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   626
    ^ self redByte:r greenByte:g blueByte:b
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   627
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   628
!
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   629
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   630
blue: blue
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   631
    "return a color from blue value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   632
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   633
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   634
    ^ here 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   635
        scaledRed:0 scaledGreen:0 scaledBlue:(blue * MaxValue // 100)
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   636
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   637
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   638
     (Color blue:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   639
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   640
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   641
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   642
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   643
brightness:brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   644
    "create a gray color with given brightness (0..1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   645
     ST-80 compatibility."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   646
3264
ab71c2bd250f fixed #brightness:
Claus Gittinger <cg@exept.de>
parents: 3240
diff changeset
   647
    ^ self scaledGray:(brightness * MaxValue) rounded
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   648
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   649
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   650
colorId:id
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   651
    "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
   652
     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
   653
     or for bitblits if you want to manipulate a specific colorplane."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   654
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   655
    id == 0 ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   656
        ^ self noColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   657
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   658
    id == 1 ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   659
        Pseudo1 isNil ifTrue:[
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   660
            Pseudo1 := self basicNew setColorId:1
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   661
        ].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   662
        ^ Pseudo1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   663
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   664
    id == -1 ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   665
        ^ self allColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   666
    ].
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   667
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   668
    ^ self basicNew setColorId:id
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   669
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   670
    "Modified: 24.2.1997 / 18:16:30 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   671
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   672
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   673
cyan:c magenta:m yellow:y
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   674
    "return a color from cyan, magenta and yellow values.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   675
     all values are given in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   676
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   677
    ^ self
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   678
        redPercent:(100 - c)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   679
        greenPercent:(100 - m)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   680
        bluePercent:(100 - y)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   681
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   682
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   683
     Color cyan:100 magenta:0 yellow:0      - cyan    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   684
     Color cyan:100 magenta:100 yellow:0    - blue    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   685
     Color cyan:100 magenta:0 yellow:100    - green    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   686
     Color cyan:100 magenta:100 yellow:100  - black  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   687
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   688
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   689
    "Modified: 11.6.1996 / 18:29:15 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   690
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   691
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   692
cyan:c magenta:m yellow:y black:k
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   693
    "return a color from cyan, magenta, yellow and black values.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   694
     all values are given in percent (0..100).
2889
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   695
     The value returned here is questionable.
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   696
     TODO: we loose information about one component here,
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   697
     and should actually return an instance of CMYK color, which keeps this
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   698
     information internally for later use (when saving)."
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   699
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   700
    |scale r g b|
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   701
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   702
    "/ mhmh - how should we scale black into the components ?
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   703
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   704
    r := (100 - c).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   705
    g := (100 - m).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   706
    b := (100 - y).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   707
    k ~~ 0 ifTrue:[
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   708
        "/ more black - darker
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   709
        scale := (100-k) max:0.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   710
        scale := scale / 100.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   711
        r := r * scale.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   712
        g := g * scale.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   713
        b := b * scale.
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   714
    ].
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   715
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   716
    ^ self redPercent:r greenPercent:g bluePercent:b
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   717
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   718
    "
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   719
     Color cyan:100 magenta:0 yellow:0 black:0      - cyan    
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   720
     Color cyan:100 magenta:0 yellow:0 black:50     - cyan darkened   
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   721
     Color cyan:100 magenta:50 yellow:50 black:0    - cyan darkened   
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   722
     Color cyan:0 magenta:0 yellow:0 black:100      - black  
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   723
    "
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   724
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   725
    "Modified: 11.6.1996 / 18:29:15 / cg"
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   726
!
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   727
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   728
dither:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   729
    "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
   730
     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
   731
     colors.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   732
     Useful, if you explicitely want a dithered color 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   733
     (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
   734
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   735
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   736
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   737
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   738
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   739
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   740
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   741
    (c1 isNil or:[c2 isNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   742
        '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
   743
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   744
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   745
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   746
    self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   747
        monoDitherFor:fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   748
        between:c1 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   749
        and:c2
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   750
        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   751
        into:[:c :f | newColor := c. form := f].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   752
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   753
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   754
    form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   755
        "/ cannot happen
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   756
        'Color [warning]: monoDither failed' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   757
        ^ nil
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
    newColor := self basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   761
                        setScaledRed:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   762
                        scaledGreen:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   763
                        scaledBlue:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   764
                        device:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   765
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   766
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   767
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   768
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   769
    "
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   770
     (Color dither:0.25 between:Color red and:Color yellow on:Display) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   771
     (Color dither:0.5 between:Color red and:Color yellow on:Display) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   772
     (Color dither:0.75 between:Color red and:Color yellow on:Display) inspect
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   773
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   774
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   775
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   776
    "Modified: 3.5.1997 / 11:10:51 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   777
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   778
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   779
dithered:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   780
    "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
   781
     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
   782
     colors.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   783
     Useful, if you explicitely want a dithered color 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   784
     (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
   785
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   786
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   787
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   788
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   789
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   790
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   791
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   792
    (c1 isNil or:[c2 isNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   793
        '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
   794
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   795
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   796
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   797
    self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   798
        monoDitherFor:fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   799
        between:c1 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   800
        and:c2
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   801
        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   802
        into:[:c :f | newColor := c. form := f].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   803
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   804
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   805
    form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   806
        "/ cannot happen
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   807
        'Color [warning]: monoDither failed' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   808
        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   809
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   810
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   811
    newColor := self basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   812
                        setScaledRed:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   813
                        scaledGreen:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   814
                        scaledBlue:nil 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   815
                        device:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   816
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   817
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   818
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   819
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   820
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   821
     |c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   822
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   823
     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
   824
     c inspect.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   825
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   826
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   827
     |v c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   828
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   829
     v := StandardSystemView new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   830
     v extent:100@100.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   831
     v openAndWait.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   832
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   833
     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
   834
     v paint:c.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   835
     v fillRectangle:(10@10 corner:90@90).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   836
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   837
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   838
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   839
    "Modified: 3.5.1997 / 11:13:12 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   840
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   841
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   842
fromUser
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   843
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   844
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   845
    "let user point on a screen pixel.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   846
     Return an instance for that pixels color"
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
    |p img|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   849
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   850
    p := Screen current pointFromUser.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   851
    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
   852
    ^ img colorAt:0@0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   853
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   854
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   855
     Color fromUser
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   856
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   857
1976
fcf9afd72f0f Do not use obsolete method Color>>at:
Stefan Vogel <sv@exept.de>
parents: 1971
diff changeset
   858
    "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
   859
    "Modified: / 9.1.1998 / 20:48:58 / stefan"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   860
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   861
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   862
green:green
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   863
    "return a color from green value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   864
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   865
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   866
    ^ here 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   867
        scaledRed:0 scaledGreen:(green * MaxValue // 100) scaledBlue:0
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   868
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   869
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   870
     (Color green:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   871
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   872
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   873
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   874
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   875
hue:h light:l saturation:s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   876
    "return a color from hue, light and saturation values.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   877
     Hue is in degrees (0..360); light and sturation are
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   878
     in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   879
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   880
    self withRGBFromHue:h light:l saturation:s do:[:r :g :b |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   881
        ^ self redPercent:r greenPercent:g bluePercent:b
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   882
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   883
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
     Color hue:0 light:50 saturation:100     - red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   886
     Color hue:60 light:50 saturation:100    - yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   887
     Color hue:120 light:50 saturation:100   - green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   888
     Color hue:120 light:75 saturation:100   - bright green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   889
     Color hue:120 light:25 saturation:100   - dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   890
     Color hue:120 light:50 saturation:50    - greyish dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   891
     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
   892
    "
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
    "Modified: 23.4.1996 / 13:22:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   895
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   896
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   897
name:colorName
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   898
    "Return a named color (either exact or dithered).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   899
     Report an error, if aString is not a valid color name.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   900
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   901
     We hereby only guarantee that the 8 basic colors are supported
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   902
     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
   903
     names - other devices use a builtIn name table containing only the
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   904
     common names) 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   905
     - use with special names (such as 'mediumGoldenRod' is not recommended). 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   906
     Better use: #name:ifIllegal: and provide a fallBack."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   907
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   908
    ^ self 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   909
        name:colorName 
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   910
        ifIllegal:[InvalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
   911
                        raiseRequestWith:colorName
1534
73dd2c4b86c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1502
diff changeset
   912
                        errorString:'invalid colorName: ' , colorName]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   913
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   914
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   915
     Color name:'brown'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   916
     Color name:'foo'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   917
     Color name:'snow'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   918
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   919
1534
73dd2c4b86c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1502
diff changeset
   920
    "Modified: 4.4.1997 / 15:32:33 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   921
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   922
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   923
name:colorName ifIllegal:errorBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   924
    "Return a named color (either exact or dithered).
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   925
     If aString is not a valid color name, 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   926
     return the result from evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   927
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   928
    |triple r g b|
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   929
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   930
    triple := StandardColorValues at:colorName asString ifAbsent:nil.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   931
    triple notNil ifTrue:[
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   932
        r := triple at:1.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   933
        g := triple at:2.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   934
        b := triple at:3.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   935
    ] ifFalse:[
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   936
        "/ ask display ...
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   937
2999
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   938
        Screen current
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   939
            getScaledRGBFromName:colorName 
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   940
            into:[:rr :gg :bb |
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   941
                r := rr.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   942
                g := gg.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   943
                b := bb
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   944
            ].
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   945
    ].
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   946
    r notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   947
        ^ here scaledRed:r scaledGreen:g scaledBlue:b
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   948
    ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   949
    ^ errorBlock value
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   950
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   951
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   952
     Color name:'brown' ifIllegal:[Color black]
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   953
     Color name:'red' ifIllegal:[Color black]      
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   954
     Color name:'fuchsia' ifIllegal:[Color black]      
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   955
     Color name:'foo' ifIllegal:[Color black]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   956
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   957
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   958
    "Modified: 6.3.1997 / 02:32:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   959
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   960
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   961
noColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   962
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   963
     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
   964
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   965
     Pseudo0 isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   966
         Pseudo0 := self basicNew setColorId:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   967
     ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   968
     ^ Pseudo0
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   969
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   970
    "Modified: 17.1.1997 / 00:06:49 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   971
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   972
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   973
red:red
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   974
    "return a color from red value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   975
     the argument r is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   976
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   977
    ^ here 
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   978
        scaledRed:(red * MaxValue // 100) scaledGreen:0 scaledBlue:0
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   979
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   980
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   981
     (Color red:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   982
    "
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   983
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   984
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   985
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   986
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   987
     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
   988
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   989
    ^ here scaledRed:(r * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   990
           scaledGreen:(g * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   991
           scaledBlue:(b * MaxValue // 100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   992
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   993
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   994
redByte:r greenByte:g blueByte:b
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   995
    "return a color from red, green and blue values;
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   996
     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
   997
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   998
    ^ here scaledRed:(r * MaxValue // 255)
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   999
           scaledGreen:(g * MaxValue // 255)
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1000
           scaledBlue:(b * MaxValue // 255)
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1001
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1002
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1003
     (Color redByte:255 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1004
     (Color redByte:255 greenByte:255 blueByte:255) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1005
     (Color redByte:0 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1006
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1007
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1008
    "Modified: 16.1.1997 / 23:32:43 / cg"
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1009
!
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1010
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1011
redPercent:r greenPercent:g bluePercent:b
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1012
    "return a color from red, green and blue values;
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1013
     the arguments, r, g and b are interpreted as percent (0..100)"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1014
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1015
    ^ here scaledRed:(r * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1016
           scaledGreen:(g * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1017
           scaledBlue:(b * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1018
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1019
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1020
rgbValue:rgb
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1021
    "return a color from a 24bit RGB value;
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1022
     The value is composed of r<<16 + g<<8 + b."
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1023
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1024
    |r g b|
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1025
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1026
    r := (rgb bitShift:-16) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1027
    g := (rgb bitShift:-8) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1028
    b := (rgb) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1029
    ^ self redByte:r greenByte:g blueByte:b
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1030
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1031
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1032
     (Color rgbValue:16rFF0000) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1033
     (Color rgbValue:16r00FF00) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1034
     (Color rgbValue:16r0000FF) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1035
     (Color rgbValue:16rFF00FF) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1036
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1037
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1038
    "Modified: 13.8.1997 / 20:24:37 / cg"
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1039
!
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1040
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1041
scaledGray:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1042
    "return a gray color with a scaled gray value (0..MaxValue)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1043
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1044
    ^ self scaledRed:aGrayValue scaledGreen:aGrayValue scaledBlue:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1045
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1046
    "Modified: 11.6.1996 / 16:31:42 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1047
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1048
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1049
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1050
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1051
     the arguments, r, g and b are interpreted as (0..MaxValue)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1052
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1053
    |newColor|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1054
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1055
"/    "look if already known"
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1056
"/
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1057
"/    aDevice deviceColors do:[:aColor |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1058
"/        (r == aColor scaledRed) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1059
"/            (g == aColor scaledGreen) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1060
"/                (b == aColor scaledBlue) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1061
"/                    ^ aColor
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1062
"/                ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1063
"/            ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1064
"/        ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1065
"/    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1066
    newColor := self basicNew setScaledRed:r scaledGreen:g scaledBlue:b device:nil.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1067
    ^ newColor
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1070
     (Color red:100 green:0 blue:0) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1071
     (Color red:100 green:50 blue:50) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1072
     (Color red:50 green:0 blue:0) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1073
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1074
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1075
    "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
  1076
    "Modified: 24.2.1997 / 18:18:47 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1077
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1078
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1079
variableColorOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1080
    "return a variable color (i.e. allocate a writable colorcell) on
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1081
     aDevice. The returned color is not shared and its rgb components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1082
     are initially undefined. The components can be set to any value
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1083
     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
  1084
     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
  1085
     being a pseudocolor device using colormaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1086
     Returns nil, if no more colorCells are available, or the display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1087
     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
  1088
     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
  1089
     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
  1090
     things in another color)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1091
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1092
    |c lutIndex|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1093
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1094
    lutIndex := aDevice colorCell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1095
    lutIndex isNil ifTrue:[^ nil].
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
    c := self new.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  1098
    c setDevice:aDevice colorId:lutIndex writable:true.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1099
    Cells isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1100
        Cells := Registry new.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1101
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1102
    Cells register:c.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1103
    ^ c
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1104
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1105
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1106
     |l cell|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1107
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1108
     l := Label new.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1109
     l label:('hello' asText allBold).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1110
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1111
     cell := Color variableColorOn:(Screen current).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1112
     l foregroundColor:cell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1113
     [
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1114
        1 to:40 do:[:i|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1115
            i odd ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1116
                cell red:100 green:0 blue:0
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1117
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1118
                cell red:0 green:0 blue:0
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1119
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1120
            Display flush.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1121
            (Delay forSeconds:0.4) wait
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1122
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1123
        l destroy.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1124
     ] fork.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1125
     l open
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1126
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1127
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1128
    "Modified: 13.5.1996 / 12:41:53 / cg"
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
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1131
!Color class methodsFor:'Compatibility - Squeak'!
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1132
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1133
colorPaletteForDepth: depth extent: chartExtent
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1134
        "Squeak mimicri:
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1135
         Display a palette of colors sorted horizontally by hue and vertically by lightness. Useful for eyeballing the color gamut of the display, or for choosing a color interactively."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1136
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1137
        "Note: It is slow to build this palette, so it should be cached for quick access."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1138
        "(Color colorPaletteForDepth: 16 extent: 190@60) display"
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1139
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1140
        | basicHue x y c startHue palette transHt vSteps transCaption grayWidth hSteps |
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1141
        Smalltalk isSmalltalkX ifTrue:[
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1142
            palette := Image extent:chartExtent depth:24.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1143
            palette photometric:#rgb.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1144
            palette data:(ByteArray new:chartExtent x * chartExtent y * 3).   
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1145
        ] ifFalse:[
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1146
            palette := Form extent: chartExtent depth: depth.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1147
        ].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1148
        transCaption := "(DisplayText text: 'no color' asText textStyle: (TextConstants at: #ComicPlain)) form storeString"
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1149
                (Form extent: 34@9 depth: 1
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1150
                        fromArray: #(0 0 256 0 256 0 3808663859 2147483648 2491688266 2147483648 2491688266 0 2491688266 0 2466486578 0 0 0)
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1151
                        offset: 0@0).
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1152
        transHt := transCaption height.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1153
        palette fillWhite: (0@0 extent: palette width@transHt).
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1154
        palette fillBlack: (0@transHt extent: palette width@1).
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1155
"/        transCaption displayOn: palette at: palette boundingBox topCenter - ((transCaption width // 2)@0).
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1156
        grayWidth := 10.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1157
        startHue := 338.0.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1158
        vSteps := palette height - transHt // 2.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1159
        hSteps := palette width - grayWidth.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1160
        x := 0.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1161
        startHue to: startHue + 360.0 by: 360.0/hSteps do: [:h |
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1162
                basicHue := Color h: h asFloat s: 1.0 v: 1.0.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1163
                y := transHt+1.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1164
                0 to: vSteps do: [:n |
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1165
                        c := basicHue mixed: (n asFloat / vSteps asFloat) with: Color white.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1166
                        palette fill: (x@y extent: 1@1) fillColor: c.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1167
                        y := y + 1].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1168
                1 to: vSteps do: [:n |
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1169
                        c := Color black mixed: (n asFloat / vSteps asFloat) with: basicHue.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1170
                        y < palette height ifTrue:[
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1171
                            palette fill: (x@y extent: 1@1) fillColor: c.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1172
                        ].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1173
                        y := y + 1].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1174
                x := x + 1].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1175
        y := transHt + 1.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1176
        1 to: vSteps * 2 do: [:n |
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1177
                c := Color black mixed: (n asFloat / (vSteps*2) asFloat) with: Color white.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1178
                palette fill: (x@y corner:(((x@y) +(10@1))min:palette extent)) fillColor: c.
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1179
                y := y + 1].
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1180
        ^ palette
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1181
!
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1182
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1183
fromRgbTriplet:aTriple
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1184
    ^ self r:(aTriple at:1)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1185
           g:(aTriple at:2)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1186
           b:(aTriple at:3)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1187
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1188
!
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1189
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1190
h:hue s:saturation v:brightness
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1191
    "Squeak mimicri:
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1192
     Create a color with the given hue, saturation, and brightness. 
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1193
     Hue is given as the angle in degrees of the color on the color circle,
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1194
     where red is zero degrees. 
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1195
     Saturation and brightness are numbers in [0.0..1.0],
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1196
     where larger values are more saturated or brighter colors. 
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1197
     For example, (Color h: 0 s: 1 v: 1) is pure red."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1198
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1199
    "Note: By convention, brightness is abbreviated 'v' to to avoid confusion with blue."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1200
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1201
    ^ self hue:hue light:(brightness*50) saturation:(saturation*100)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1202
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1203
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1204
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1205
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1206
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1207
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1208
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1209
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1210
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1211
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1212
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1213
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1214
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1215
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1216
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1217
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1218
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1219
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1220
!
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1221
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1222
pixelScreenForDepth: depth
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1223
        "Return a 50% stipple containing alternating pixels of all-zeros and all-ones to be used as a mask at the given depth."
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1224
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1225
        | mask bits |
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1226
        Smalltalk isSmalltalkX ifTrue:[
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1227
            depth == 1 ifTrue:[
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1228
                ^ Form mediumGreyFormOn:Screen current
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1229
            ].
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1230
            self halt.
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1231
        ].
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1232
        mask _ (1 bitShift: depth) - 1.
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1233
        bits _ 2 * depth.
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1234
        [bits >= 32] whileFalse: [
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1235
                mask _ mask bitOr: (mask bitShift: bits).  "double the length of mask"
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1236
                bits _ bits + bits].
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1237
        ^ Bitmap with: mask with: mask bitInvert32
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1238
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1239
        "
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1240
         self pixelScreenForDepth: depth
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1241
        "
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1242
!
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1243
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1244
r:redFraction g:greenFraction b:blueFraction
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1245
    "Squeak mimicri:
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1246
     return a color from red, green and blue fractional values;
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1247
     the arguments, r, g and b are in (0..1)"
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1248
2937
4536e6de438a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  1249
    ^ here scaledRed:(redFraction * MaxValue) rounded
4536e6de438a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  1250
           scaledGreen:(greenFraction * MaxValue) rounded
4536e6de438a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  1251
           scaledBlue:(blueFraction * MaxValue) rounded
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1252
! !
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1253
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1254
!Color class methodsFor:'Signal constants'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1255
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1256
colorAllocationFailSignal
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1257
    "return the signal raised when a color allocation failed."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1258
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1259
    ^ ColorAllocationFailSignal
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
    "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
  1262
!
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1263
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1264
colorErrorSignal
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1265
    "return the parent signal of all color error signals."
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1266
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1267
    ^ ColorErrorSignal
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1268
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1269
    "Created: / 30.9.1998 / 21:56:04 / cg"
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1270
!
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1271
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1272
invalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1273
    "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
  1274
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1275
    ^ InvalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1276
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1277
    "Created: 24.1.1997 / 13:36:25 / cg"
1023
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
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1280
!Color class methodsFor:'accessing'!
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
allocatedColorsOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1283
    "return a collection of colors available on aDevice"
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
    |colors|
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
    colors := OrderedCollection new.
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1288
    aDevice deviceColors do:[:clr |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1289
        clr colorId notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1290
            colors add:clr
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1291
        ] ifFalse:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1292
            'color - oops' printCR.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1293
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1294
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1295
    ^ colors asArray
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1298
     Color allocatedColorsOn:Display
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
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1301
    "Modified: 24.2.1997 / 18:16:14 / cg"
1023
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
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1304
!Color class methodsFor:'color space conversions'!
1023
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
withHLSFromRed:r green:g blue:b do:aBlock
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1307
    "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
  1308
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1309
    |max min r1 g1 b1 delta h l s|
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
    "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
  1312
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1313
    r1 := r / 100.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1314
    g1 := g / 100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1315
    b1 := b / 100.
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
    max := (r1 max:g1) max:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1318
    min := (r1 min:g1) min:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1319
    l := (max + min) / 2.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1320
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1321
    max = min ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1322
        "achromatic, r=g=b"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1323
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1324
        s := 0.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1325
        h := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1326
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1327
        l < 0.5 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1328
            s := (max - min) / (max + min)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1329
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1330
            s := (max - min) / (2 - max - min)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1331
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1332
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1333
        "calc hue"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1334
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1335
        delta := max - min.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1336
        r1 = max ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1337
            h := (g1 - b1) / delta
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1338
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1339
            g1 = max ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1340
                h := 2 + ((b1 - r1) / delta)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1341
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1342
                h := 4 + ((r1 - g1) / delta)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1343
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1344
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1345
        h := h * 60.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1346
        h < 0 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1347
            h := h + 360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1348
        ].
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
    aBlock value:h value:(l * 100) value:(s * 100)
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
withHLSFromScaledRed:r scaledGreen:g scaledBlue:b do:aBlock
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1354
    "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
  1355
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1356
    ^ self withHLSFromRed:(r * 100.0 / MaxValue)
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1357
                    green:(g * 100.0 / MaxValue) 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1358
                     blue:(b * 100.0 / MaxValue)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1359
                       do:aBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1360
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1361
    "Created: 11.6.1996 / 17:23:47 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1362
!
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
withRGBFromHue:h light:l saturation:s do:aBlock
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1365
    "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
  1366
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1367
    |valueFunc s1 l1 r g b m1 m2|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1368
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1369
    valueFunc := [:n1 :n2 :hIn |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1370
        |hue|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1371
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1372
        hue := hIn.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1373
        hue > 360 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1374
            hue := hue - 360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1375
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1376
            hue < 0 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1377
                hue := hue + 360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1378
            ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1379
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1380
        hue < 60 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1381
            n1 + ((n2 - n1) * hue / 60)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1382
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1383
            hue < 180 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1384
                n2
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1385
            ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1386
                hue < 240 ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1387
                    n1 + ((n2 - n1) * (240 - hue) / 60)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1388
                ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1389
                    n1
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1390
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1391
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1392
        ]
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1395
    "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
  1396
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1397
    s1 := s / 100.0.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1398
    l1 := l / 100.0.
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
    l1 <= 0.5 ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1401
        m2 := l1 * (1 + s1)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1402
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1403
        m2 := l1 + s1 - (l1 * s1)
1023
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
    m1 := 2 * l1 - m2.
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
    s1 = 0 ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1409
        "achromatic, ignore hue"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1410
        r := g := b := l1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1411
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1412
        r := valueFunc value:m1 value:m2 value:h + 120.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1413
        g := valueFunc value:m1 value:m2 value:h.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1414
        b := valueFunc value:m1 value:m2 value:h - 120.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1415
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1416
    aBlock value:r*100 value:g*100 value:b*100
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
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1419
!Color class methodsFor:'constant colors'!
1023
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
black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1422
    "return the black color"
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
    Black isNil ifTrue:[
3039
1c5a5ddfbefb do not depend on Screen class being present in Color black/white.
Claus Gittinger <cg@exept.de>
parents: 3030
diff changeset
  1425
        Black := self red:0 green:0 blue:0
1023
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
    ^ Black
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 black 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
    "Modified: 11.6.1996 / 15:55:31 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1434
!
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
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1437
    "return the blue color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1438
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1439
    Blue isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1440
        Blue := self redPercent:0 greenPercent:0 bluePercent:100
1023
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
    ^ Blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1443
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
     Color blue inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1446
    "
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
    "Modified: 23.4.1996 / 13:15:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1449
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1450
2962
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1451
brown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1452
    ^ self redPercent:60 greenPercent:20 bluePercent:0
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1453
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1454
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1455
     Color brown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1456
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1457
!
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1458
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1459
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1460
    "return the cyan color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1461
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1462
    ^ self cyan:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1463
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1464
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1465
     Color cyan inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1466
    "
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:16:07 / 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
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1471
cyan: cyan
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1472
    "return a cyan color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1473
     the argument cyan is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1474
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1475
     ^ self cyan:100 magenta:100-cyan yellow:100-cyan
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1476
                                     
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1477
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1478
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1479
darkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1480
    "return the dark grey color (English version ;-)"
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
    DarkGrey isNil ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1483
        DarkGrey := self grayPercent:33
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1484
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1485
    ^ DarkGrey
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1488
     Color darkGray inspect
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
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1491
    "Modified: 24.2.1997 / 21:33:11 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1492
!
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
darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1495
    "return the darkGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1496
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1497
    ^ self darkGray
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1500
     Color darkGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1501
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1502
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1503
    "Modified: 28.5.1996 / 20:47:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1504
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1505
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1506
gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1507
    "return a medium grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1508
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1509
    Grey isNil ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1510
        Grey := self grayPercent:50
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1511
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1512
    ^ Grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1513
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
     Color gray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1516
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1517
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1518
    "Modified: 24.2.1997 / 21:33:19 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1519
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1520
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1521
gray:gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1522
    "return a gray color (US version). 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1523
     The argument, gray is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1524
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1525
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1526
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1527
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1528
     Color gray:25
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1529
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1530
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1531
    "Modified: 28.5.1996 / 20:49:51 / cg"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1532
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1533
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1534
grayPercent:gray
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1535
    "return a gray color (US version). 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1536
     The argument, gray is interpreted as percent (0..100)."
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1537
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1538
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1539
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1540
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1541
     Color gray:25
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1542
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1543
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1544
    "Modified: 28.5.1996 / 20:49:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1545
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1546
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1547
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1548
    "return green"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1549
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1550
    Green isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1551
        Green := self redPercent:0 greenPercent:100 bluePercent:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1552
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1553
    ^ Green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1554
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1555
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1556
     Color green inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1557
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1558
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1559
    "Modified: 23.4.1996 / 13:23:08 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1560
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1561
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1562
grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1563
    "return the grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1564
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1565
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1566
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
     Color grey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1569
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1570
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1571
    "Modified: 28.5.1996 / 20:48:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1572
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1573
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1574
grey:grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1575
    "return a grey color (English version). 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1576
     The argument, grey is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1577
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1578
    ^ self grayPercent:grey
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1579
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
     Color grey:25
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1582
     Color grey:12.5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1583
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1584
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1585
    "Modified: 24.2.1997 / 21:33:28 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1586
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1587
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1588
lightBlue
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1589
    "return a light blue color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1590
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1591
    ^ self redPercent:50 greenPercent:50 bluePercent:100
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1592
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1593
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1594
     Color lightBlue inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1595
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1596
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1597
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1598
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1599
2962
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1600
lightBrown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1601
    ^ self brown lighter
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1602
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1603
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1604
     Color lightBrown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1605
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1606
!
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1607
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1608
lightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1609
    "return the lightGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1610
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1611
    LightGrey isNil ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1612
        LightGrey := self grayPercent:67
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1613
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1614
    ^ LightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1615
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1616
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1617
     Color lightGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1618
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1619
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1620
    "Modified: 24.2.1997 / 21:33:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1621
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1622
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1623
lightGreen
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1624
    "return a light green color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1625
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1626
    ^ self redPercent:50 greenPercent:100 bluePercent:50
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1627
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1628
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1629
     Color lightGreen inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1630
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1631
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1632
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1633
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1634
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1635
lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1636
    "return the lightGrey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1637
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1638
    ^ self lightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1639
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1640
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1641
     Color lightGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1642
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1643
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1644
    "Modified: 28.5.1996 / 20:51:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1645
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1646
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1647
lightRed
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1648
    "return a light red color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1649
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1650
    ^ self redPercent:100 greenPercent:50 bluePercent:50
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1651
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1652
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1653
     Color lightRed inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1654
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1655
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1656
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1657
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1658
2949
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1659
lightYellow
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1660
    ^ self yellow lighter
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1661
!
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1662
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1663
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1664
    "return the magenta color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1665
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1666
    ^ self magenta:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1667
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1668
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1669
     Color magenta inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1670
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1671
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1672
    "Modified: 23.4.1996 / 13:23:41 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1673
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1674
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1675
magenta: magenta
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1676
    "return a magenta color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1677
     the argument magenta is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1678
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1679
     ^ self cyan:100-magenta magenta:100 yellow:100-magenta
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1680
                                     
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1681
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1682
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1683
mediumGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1684
    "return medium-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1685
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1686
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1687
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1688
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1689
     Color mediumGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1690
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1691
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1692
    "Created: 23.4.1996 / 13:24:17 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1693
    "Modified: 28.5.1996 / 20:51:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1694
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1695
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1696
mediumGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1697
    "return medium-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1698
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1699
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1700
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1701
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1702
     Color mediumGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1703
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1704
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1705
    "Modified: 28.5.1996 / 20:51:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1706
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1707
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1708
orange
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1709
    "return the orange color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1710
2077
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1711
     ^ self orange:100
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1712
!
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1713
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1714
orange: orange
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1715
    "return a orange color;
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1716
     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
  1717
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1718
     ^ 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
  1719
                                     
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1720
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1721
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1722
pink 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1723
    "return the pink color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1724
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1725
     ^ self redPercent:100 greenPercent:0 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1726
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1727
    "Modified: 23.4.1996 / 13:29:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1728
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1729
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1730
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1731
    "return the red color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1732
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1733
    Red isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1734
        Red := self redPercent:100 greenPercent:0 bluePercent:0.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1735
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1736
    ^ Red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1737
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1738
    "Modified: 23.4.1996 / 13:29:44 / cg"
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
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1741
transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1742
    "return the transparent-color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1743
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1744
    Transparent isNil ifTrue:[
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  1745
        Transparent := TranslucentColor scaledRed:0 scaledGreen:0 scaledBlue:0.
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1746
        Transparent setAlphaByte:0.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1747
    ].
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1748
    ^ Transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1749
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1750
    "
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1751
     self transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1752
    "
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1753
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1754
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1755
veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1756
    "return a very dark-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1757
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1758
    ^ self grayPercent:13
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1759
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1760
    "Created: 23.4.1996 / 13:33:14 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1761
    "Modified: 24.2.1997 / 21:33:52 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1762
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1763
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1764
veryDarkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1765
    "return a very dark-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1766
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1767
    ^ self veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1768
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1769
    "Modified: 28.5.1996 / 20:52:49 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1770
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1771
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1772
veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1773
    "return a very light-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1774
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1775
    ^ self grayPercent:87
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1776
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1777
    "Created: 23.4.1996 / 13:33:46 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1778
    "Modified: 24.2.1997 / 21:33:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1779
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1780
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1781
veryLightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1782
    "return a very light-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1783
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1784
    ^ self veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1785
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1786
    "Modified: 28.5.1996 / 20:52:03 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1787
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1788
3030
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1789
veryVeryLightGray
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1790
    "return a very very light-grey color (US version ;-)"
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1791
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1792
    ^ self grayPercent:93
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1793
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1794
!
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1795
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1796
white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1797
    "return the white-color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1798
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1799
    White isNil ifTrue:[
3039
1c5a5ddfbefb do not depend on Screen class being present in Color black/white.
Claus Gittinger <cg@exept.de>
parents: 3030
diff changeset
  1800
        White := self redPercent:100 greenPercent:100 bluePercent:100.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1801
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1802
    ^ White
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1803
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1804
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1805
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1806
    "return the yellow color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1807
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1808
    ^ self yellow:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1809
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1810
    "Modified: 23.4.1996 / 13:33:56 / cg"
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1811
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1812
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1813
yellow: yellow
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1814
    "return a yellow color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1815
     the argument yellow is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1816
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1817
     ^ self cyan:100-yellow magenta:100-yellow yellow:100
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1818
                                     
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1819
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1820
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1821
!Color class methodsFor:'obsolete'!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1822
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1823
nameOrDither:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1824
    "return a named color - if the exact color is not available,
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1825
     return a dithered color. Report an error, if the colorname is 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1826
     illegal."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1827
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1828
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1829
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1830
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1831
    "Modified: 16.1.1997 / 23:01:03 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1832
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1833
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1834
nameOrDither:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1835
    "return a named color - if the exact color is not available,
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1836
     return a dithered color. If the colorname is illegal, return
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1837
     the value of evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1838
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1839
    self obsoleteMethodWarning:'use #name:ifIllegal:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1840
    ^ self name:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1841
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1842
    "Modified: 16.1.1997 / 23:01:32 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1843
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1844
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1845
nameOrNearest:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1846
    "return a named color - or its nearest match"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1847
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1848
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1849
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1850
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1851
    "Modified: 16.1.1997 / 23:02:18 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1852
! !
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1853
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1854
!Color class methodsFor:'private'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1855
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1856
colorNearRed:r green:g blue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1857
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1858
     almost matching. If there is one, nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1859
     This is tried as a last chance before dithering.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1860
     The algorithm needs rework, the color components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1861
     should be weighted according some theory :-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1862
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1863
    |bestColor minDelta diff rr rg rb dRed|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1864
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1865
"/    rr := (r * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1866
"/    rg := (g * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1867
"/    rb := (b * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1868
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1869
    rr := r rounded.                "round to 1%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1870
    rg := (g * 2.0) rounded / 2.0.  "round to 0.5%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1871
    rb := (b / 2) rounded * 2.      "round to 2%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1872
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1873
    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
  1874
    aDevice deviceColors do:[:aColor |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1875
        dRed := rr - aColor red.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1876
        dRed < 10 ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1877
            diff := dRed asInteger squared
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1878
                    + (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
  1879
                    + (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
  1880
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1881
            diff < minDelta ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1882
                diff = 0 ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1883
                    "got it"
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1884
                    ^ aColor
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1885
                ].
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1886
                bestColor := aColor.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1887
                minDelta := diff
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1888
            ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1889
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1890
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1891
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1892
    "allow an error of 10% per component"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1893
    minDelta < (100+100+100) ifTrue:[ ^ bestColor ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1894
    ^ nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1895
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1896
    "Modified: 24.2.1997 / 18:17:24 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1897
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1898
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1899
existingColorRed:r green:g blue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1900
    "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
  1901
     if there is one, nil otherwise."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1902
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1903
    ^ self existingColorScaledRed:(r * MaxValue // 100)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1904
                        scaledGreen:(g * MaxValue // 100)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1905
                        scaledBlue:(b * MaxValue // 100)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1906
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1907
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1908
existingColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1909
    "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
  1910
     if there is one, nil otherwise."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1911
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1912
    aDevice deviceColors do:[:aColor |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1913
        (r == aColor scaledRed) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1914
            (g == aColor scaledGreen) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1915
                (b == aColor scaledBlue) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1916
                    ^ aColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1917
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1918
            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1919
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1920
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1921
    ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1922
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1923
    "Modified: 24.2.1997 / 18:17:35 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1924
! !
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1925
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1926
!Color class methodsFor:'private - dithering'!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1927
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1928
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
  1929
    "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
  1930
     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
  1931
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1932
    |errR errG errB f wantR wantG wantB clr 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1933
     dir   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1934
     start "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1935
     end   "{ Class: SmallInteger }" 
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1936
     map
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1937
     w     "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1938
     h     "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1939
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1940
"/    w := h := 32.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1941
"/    w := h := 4.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1942
    w := h := 2.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1943
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1944
    errR := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1945
    errG := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1946
    errB := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1947
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1948
    "get a form and clear it"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1949
    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
  1950
    map := IdentityDictionary new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1951
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1952
    0 to:(w-1) do:[:x |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1953
        x even ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1954
            dir := 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1955
            start := 0.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1956
            end := (h-1).
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1957
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1958
            dir := -1.
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  1959
            start := (h-1).
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1960
            end := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1961
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1962
        start to:end by:dir do:[:y |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1963
            wantR := red + errR. 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1964
            wantR > MaxValue ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1965
                wantR := MaxValue
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1966
            ] ifFalse:[ wantR < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1967
                wantR := 0
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1968
            ]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1969
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1970
            wantG := green + errG.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1971
            wantG > MaxValue ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1972
                wantG := MaxValue
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1973
            ] ifFalse:[ wantG < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1974
                wantG := 0
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1975
            ]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1976
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1977
            wantB := blue + errB.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1978
            wantB > MaxValue ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1979
                wantB := MaxValue
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1980
            ] ifFalse:[ wantB < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1981
                wantB := 0
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1982
            ]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1983
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1984
            "find the nearest color"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1985
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1986
" "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1987
            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
  1988
" "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1989
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1990
            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
  1991
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1992
            clr isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1993
                clr := Color scaledRed:wantR scaledGreen:wantG scaledBlue:wantB.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1994
                clr brightness > 0.5 ifTrue:[
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1995
                    clr := Color white
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1996
                ] ifFalse:[
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1997
                    clr := Color black
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1998
                ].
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1999
                clr := clr onDevice:aDevice
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2000
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2001
                ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2002
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2003
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2004
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2005
            f paint:clr.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2006
            f displayPointX:x y:y.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2007
            map at:clr colorId + 1 put:clr.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2008
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2009
            "compute the new error"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2010
            errR := wantR - clr scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2011
            errG := wantG - clr scaledGreen.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2012
            errB := wantB - clr scaledBlue.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2013
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2014
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2015
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2016
    f colorMap:map.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2017
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2018
'hard dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2019
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2020
    ^ aBlock value:nil value:f
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2021
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2022
    "Created: 3.5.1997 / 11:02:47 / cg"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2023
    "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
  2024
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2025
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2026
ditherBits
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2027
    "return a dither pattern for x/64; x in 1..63"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2028
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2029
    ^ #(
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2030
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2031
        "/ 1in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2032
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2033
          #[2r10000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2034
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2035
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2036
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2037
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2038
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2039
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2040
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2041
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2042
        "/ 2in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2043
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2044
          #[2r10000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2045
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2046
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2047
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2048
            2r00001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2049
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2050
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2051
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2052
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2053
        "/ 3in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2054
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2055
          #[2r10000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2056
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2057
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2058
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2059
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2060
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2061
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2062
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2063
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2064
        "/ 4in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2065
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2066
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2067
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2068
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2069
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2070
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2071
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2072
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2073
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2074
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2075
        "/ 5in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2076
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2077
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2078
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2079
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2080
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2081
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2082
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2083
            2r00000010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2084
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2085
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2086
        "/ 6in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2087
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2088
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2089
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2090
            2r00100000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2091
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2092
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2093
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2094
            2r00000010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2095
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2096
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2097
        "/ 7in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2098
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2099
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2100
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2101
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2102
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2103
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2104
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2105
            2r00000010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2106
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2107
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2108
        "/ 8in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2109
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2110
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2111
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2112
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2113
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2114
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2115
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2116
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2117
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2118
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2119
        "/ 9in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2120
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2121
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2122
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2123
            2r00100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2124
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2125
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2126
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2127
            2r10100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2128
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2129
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2130
        "/ 10in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2131
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2132
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2133
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2134
            2r00101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2135
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2136
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2137
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2138
            2r10100010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2139
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2140
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2141
        "/ 11in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2142
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2143
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2144
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2145
            2r00101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2146
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2147
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2148
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2149
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2150
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2151
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2152
        "/ 12in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2153
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2154
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2155
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2156
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2157
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2158
            2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2159
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2160
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2161
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2162
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2163
        "/ 13in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2164
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2165
          #[2r10001000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2166
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2167
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2168
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2169
            2r10101000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2170
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2171
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2172
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2173
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2174
        "/ 14in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2175
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2176
          #[2r10001010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2177
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2178
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2179
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2180
            2r10101000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2181
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2182
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2183
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2184
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2185
        "/ 15in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2186
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2187
          #[2r10001010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2188
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2189
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2190
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2191
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2192
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2193
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2194
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2195
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2196
        "/ 16in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2197
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2198
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2199
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2200
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2201
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2202
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2203
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2204
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2205
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2206
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2207
        "/ 17in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2208
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2209
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2210
            2r01000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2211
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2212
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2213
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2214
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2215
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2216
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2217
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2218
        "/ 18in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2219
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2220
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2221
            2r01000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2222
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2223
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2224
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2225
            2r00000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2226
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2227
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2228
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2229
        "/ 19in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2230
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2231
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2232
            2r01000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2233
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2234
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2235
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2236
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2237
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2238
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2239
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2240
        "/ 20in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2241
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2242
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2243
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2244
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2245
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2246
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2247
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2248
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2249
            2r00000000]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2250
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2251
        "/ 21in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2252
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2253
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2254
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2255
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2256
            2r00000000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2257
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2258
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2259
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2260
            2r00000001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2261
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2262
        "/ 22in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2263
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2264
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2265
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2266
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2267
            2r00010000
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2268
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2269
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2270
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2271
            2r00000001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2272
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2273
        "/ 23in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2274
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2275
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2276
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2277
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2278
            2r00010001
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2279
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2280
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2281
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2282
            2r00000001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2283
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2284
        "/ 24in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2285
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2286
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2287
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2288
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2289
            2r00010001
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2290
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2291
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2292
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2293
            2r00010001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2294
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2295
        "/ 25in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2296
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2297
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2298
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2299
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2300
            2r00010001
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2301
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2302
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2303
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2304
            2r01010001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2305
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2306
        "/ 26in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2307
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2308
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2309
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2310
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2311
            2r00010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2312
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2313
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2314
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2315
            2r01010001]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2316
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2317
        "/ 27in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2318
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2319
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2320
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2321
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2322
            2r00010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2323
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2324
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2325
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2326
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2327
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2328
        "/ 28in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2329
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2330
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2331
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2332
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2333
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2334
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2335
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2336
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2337
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2338
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2339
        "/ 29in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2340
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2341
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2342
            2r01000100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2343
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2344
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2345
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2346
            2r01010100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2347
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2348
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2349
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2350
        "/ 30in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2351
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2352
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2353
            2r01000101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2354
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2355
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2356
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2357
            2r01010100
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2358
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2359
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2360
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2361
        "/ 31in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2362
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2363
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2364
            2r01000101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2365
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2366
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2367
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2368
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2369
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2370
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2371
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2372
        "/ 32in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2373
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2374
          #[2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2375
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2376
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2377
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2378
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2379
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2380
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2381
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2382
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2383
        "/ 33in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2384
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2385
          #[2r11101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2386
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2387
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2388
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2389
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2390
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2391
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2392
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2393
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2394
        "/ 34in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2395
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2396
          #[2r11101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2397
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2398
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2399
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2400
            2r10101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2401
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2402
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2403
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2404
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2405
        "/ 35in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2406
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2407
          #[2r11101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2408
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2409
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2410
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2411
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2412
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2413
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2414
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2415
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2416
        "/ 36in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2417
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2418
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2419
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2420
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2421
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2422
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2423
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2424
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2425
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2426
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2427
        "/ 37in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2428
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2429
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2430
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2431
            2r10101010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2432
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2433
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2434
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2435
            2r10101011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2436
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2437
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2438
        "/ 38in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2439
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2440
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2441
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2442
            2r10111010
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2443
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2444
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2445
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2446
            2r10101011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2447
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2448
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2449
        "/ 39in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2450
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2451
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2452
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2453
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2454
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2455
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2456
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2457
            2r10101011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2458
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2459
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2460
        "/ 40in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2461
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2462
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2463
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2464
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2465
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2466
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2467
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2468
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2469
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2470
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2471
        "/ 41in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2472
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2473
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2474
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2475
            2r10111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2476
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2477
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2478
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2479
            2r11111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2480
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2481
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2482
        "/ 42in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2483
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2484
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2485
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2486
            2r10111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2487
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2488
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2489
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2490
            2r11111011
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2491
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2492
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2493
        "/ 43in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2494
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2495
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2496
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2497
            2r10111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2498
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2499
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2500
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2501
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2502
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2503
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2504
        "/ 44in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2505
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2506
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2507
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2508
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2509
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2510
            2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2511
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2512
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2513
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2514
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2515
        "/ 45in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2516
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2517
          #[2r11101110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2518
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2519
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2520
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2521
            2r11111110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2522
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2523
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2524
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2525
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2526
        "/ 46in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2527
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2528
          #[2r11101111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2529
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2530
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2531
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2532
            2r11111110
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2533
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2534
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2535
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2536
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2537
        "/ 47in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2538
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2539
          #[2r11101111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2540
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2541
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2542
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2543
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2544
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2545
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2546
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2547
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2548
        "/ 48in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2549
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2550
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2551
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2552
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2553
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2554
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2555
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2556
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2557
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2558
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2559
        "/ 49in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2560
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2561
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2562
            2r01110101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2563
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2564
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2565
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2566
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2567
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2568
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2569
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2570
        "/ 50in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2571
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2572
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2573
            2r01110101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2574
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2575
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2576
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2577
            2r01010111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2578
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2579
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2580
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2581
        "/ 51in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2582
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2583
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2584
            2r01110101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2585
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2586
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2587
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2588
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2589
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2590
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2591
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2592
        "/ 52in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2593
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2594
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2595
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2596
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2597
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2598
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2599
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2600
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2601
            2r01010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2602
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2603
        "/ 53in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2604
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2605
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2606
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2607
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2608
            2r01010101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2609
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2610
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2611
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2612
            2r11010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2613
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2614
        "/ 54in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2615
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2616
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2617
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2618
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2619
            2r01011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2620
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2621
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2622
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2623
            2r11010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2624
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2625
        "/ 55in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2626
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2627
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2628
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2629
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2630
            2r11011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2631
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2632
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2633
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2634
            2r11010101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2635
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2636
        "/ 56in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2637
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2638
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2639
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2640
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2641
            2r11011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2642
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2643
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2644
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2645
            2r11011101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2646
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2647
        "/ 57in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2648
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2649
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2650
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2651
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2652
            2r11011101
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2653
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2654
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2655
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2656
            2r11111101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2657
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2658
        "/ 58in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2659
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2660
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2661
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2662
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2663
            2r11011111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2664
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2665
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2666
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2667
            2r11111101]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2668
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2669
        "/ 59in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2670
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2671
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2672
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2673
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2674
            2r11011111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2675
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2676
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2677
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2678
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2679
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2680
        "/ 60in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2681
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2682
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2683
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2684
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2685
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2686
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2687
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2688
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2689
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2690
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2691
        "/ 61in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2692
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2693
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2694
            2r01110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2695
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2696
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2697
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2698
            2r01111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2699
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2700
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2701
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2702
        "/ 62in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2703
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2704
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2705
            2r11110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2706
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2707
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2708
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2709
            2r01111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2710
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2711
            2r11111111]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2712
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2713
        "/ 63in64
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2714
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2715
          #[2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2716
            2r11110111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2717
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2718
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2719
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2720
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2721
            2r11111111
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2722
            2r11111111]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2723
     )
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2724
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2725
    "Modified: 23.4.1996 / 13:31:50 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2726
    "Created: 11.6.1996 / 15:34:29 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2727
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2728
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2729
ditherGrayFor:fraction on:aDevice into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2730
    "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
  2731
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2732
     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
  2733
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2734
    |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
  2735
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2736
    d := aDevice depth.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2737
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2738
    "/ special code for b&w displays
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2739
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2740
    d == 1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2741
        aDevice blackpixel == 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2742
            clr1 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2743
            clr2 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2744
            newFraction := fraction.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2745
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2746
            clr1 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2747
            clr2 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2748
            newFraction := 1 - fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2749
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2750
    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2751
        "/ special code for 2-plane displays (NeXT)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2752
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2753
        d == 2 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2754
            fraction <= 0.01 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2755
                clr1 := Black exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2756
            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2757
                (fraction between:0.32 and:0.34) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2758
                    clr1 := (Color gray:33) exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2759
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2760
                    (fraction between:0.66 and:0.68) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2761
                        clr1 := (Color gray:67) exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2762
                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2763
                        fraction >= 0.99 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2764
                            clr1 := White exactOn:aDevice
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
            clr1 notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2770
                ^ aBlock value:clr1 value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2771
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2772
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2773
            (fraction between:0 and:0.33) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2774
                clr1 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2775
                clr2 := Color gray:33.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2776
            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2777
                (fraction between:0.34 and:0.66) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2778
                    clr1 := Color gray:33.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2779
                    clr2 := Color gray:67.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2780
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2781
                    clr1 := Color gray:67.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2782
                    clr2 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2783
                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2784
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2785
            scaledGray1 := clr1 scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2786
            scaledGray2 := clr2 scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2787
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2788
            scaledGrey := (MaxValue * fraction) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2789
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2790
            newFraction := (scaledGrey - scaledGray1) asFloat / (scaledGray2 - scaledGray1).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2791
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2792
            nGray := (1 bitShift:d) - 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2793
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2794
            "/ scale greyValue into grey levels
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
            grayBelow := (fraction * nGray) truncated.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2797
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2798
            grayBelow < 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2799
                ^ Color black exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2800
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2801
            grayBelow >= nGray ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2802
                ^ Color white exactOn:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2803
            ].
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
            scaledGrey := (MaxValue * fraction) rounded.
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
            step := MaxValue // nGray.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2808
            scaledGray1 := grayBelow * step.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2809
            scaledGray2 := scaledGray1 + step.
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
            clr1 := Color scaledGray:scaledGray1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2812
            clr2 := Color scaledGray:scaledGray2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2813
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2814
            "/ scale remainder in between low..high
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2815
            newFraction := (scaledGrey - scaledGray1) asFloat / (scaledGray2 - scaledGray1).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2816
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2817
            "/ dither between those two colors
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
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2821
    clr1 := clr1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2822
    clr2 := clr2 exactOn:aDevice.
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
    (clr1 isNil or:[clr2 isNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2825
        "/ fall back to b&w dither
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2826
        aDevice blackpixel == 0 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2827
            clr1 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2828
            clr2 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2829
            newFraction := fraction.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2830
        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2831
            clr1 := White.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2832
            clr2 := Black.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2833
            newFraction := 1 - fraction
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2834
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2835
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2836
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2837
    ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2838
        monoDitherFor:newFraction 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2839
        between:clr1 and:clr2
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2840
        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2841
        into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2842
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
     Color basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2845
        ditherGrayFor:0.5 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2846
        on:Display 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2847
        into:[:clr :form | clr notNil ifTrue:[clr inspect].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2848
                           form notNil ifTrue:[(form magnifiedBy:16) inspect].]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2849
    "
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
     Color basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2852
        ditherGrayFor:0.25 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2853
        on:Display 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2854
        into:[:clr :form | clr notNil ifTrue:[clr inspect].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2855
                           form notNil ifTrue:[(form magnifiedBy:16) inspect].]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2856
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2857
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2858
    "Created: 3.5.1997 / 10:59:57 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2859
    "Modified: 3.5.1997 / 11:05:09 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2860
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2861
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2862
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
  2863
    "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
  2864
     Returns 2 values (either color or ditherForm) through
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2865
     aBlock.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2866
     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
  2867
     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
  2868
     are handled"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2869
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2870
    |rh rl rs 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2871
     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
  2872
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2873
    "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
  2874
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2875
    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
  2876
        h notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2877
            rh := (h * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2878
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2879
        rl := (l * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2880
        rs := (s * 3.0) rounded / 3.0.
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
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2883
    rh isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2884
        "achromatic,  dither between achromatic colors"
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
        lowL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2887
        hiL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2888
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2889
        "find the 2 bounding colors"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2890
        aDevice deviceColors do:[:aColor |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2891
            aColor colorId notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2892
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2893
                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
  2894
                    | cl |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2895
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2896
                    h isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2897
                        cl := (l * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2898
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2899
                        cl > rl ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2900
                            hiL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2901
                                hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2902
                                hiValL := cl.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2903
                            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2904
                                cl < hiValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2905
                                    hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2906
                                    hiValL := cl.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2907
                                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2908
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2909
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2910
                            lowL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2911
                                lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2912
                                lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2913
                            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2914
                                cl > lowValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2915
                                    lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2916
                                    lowValL := cl
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
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2919
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2920
                    ]
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
            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2923
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2924
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2925
        (lowL notNil and:[hiL notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2926
            ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2927
                monoDitherFor:1.0 / (hiValL - lowValL) * (rl - lowValL)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2928
                between:lowL and:hiL 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2929
                on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2930
                into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2931
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2932
        "cannot happen, should always find at least black and white"
2071
20a74671b3e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2062
diff changeset
  2933
        '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
  2934
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2935
        ^ aBlock value:nil value:nil
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
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2938
    "chromatic case"
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
    aDevice hasColors ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2941
        "no chance, return nil values"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2942
        ^ aBlock value:nil value:nil
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
    (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
  2945
        "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
  2946
        ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2947
    ].
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
    "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
  2950
     dither on light between those"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2951
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2952
    lowL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2953
    hiL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2954
    lowS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2955
    hiS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2956
    lowH := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2957
    hiH := nil.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2958
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2959
    aDevice deviceColors do:[:aColor |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2960
        aColor colorId notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2961
            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
  2962
                | cl ch cs|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2963
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2964
                h notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2965
                   ch := (h * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2966
                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2967
                   ch := 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
                cl := (l * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2970
                cs := (s * 3.0) rounded / 3.0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2971
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2972
                ((ch = rh) and:[cs = rs]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2973
                    "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
  2974
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2975
                    cl > rl ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2976
                        hiL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2977
                            hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2978
                            hiValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2979
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2980
                            cl < hiValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2981
                                hiL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2982
                                hiValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2983
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2984
                        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2985
                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2986
                        lowL isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2987
                            lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2988
                            lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2989
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2990
                            cl > lowValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2991
                                lowL := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2992
                                lowValL := cl
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2993
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2994
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2995
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2996
                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2997
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2998
                (((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
  2999
                    "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
  3000
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3001
                    cs > rs ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3002
                        hiS isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3003
                            hiS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3004
                            hiValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3005
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3006
                            cs < hiValS ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3007
                                hiS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3008
                                hiValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3009
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3010
                        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3011
                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3012
                        lowS isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3013
                            lowS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3014
                            lowValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3015
                        ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3016
                            cs > lowValS ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3017
                                lowS := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3018
                                lowValS := cs
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3019
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3020
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3021
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3022
                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3023
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3024
                rh notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3025
                    cl = rl ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3026
                        cs = rs ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3027
                            ch notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3028
                                d := (ch - rh) abs.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3029
                                d > 300 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3030
                                    rh > 180 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3031
                                        ch := ch + 360
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3032
                                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3033
                                        ch := ch - 360
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3034
                                    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3035
                                ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3036
                                ch > rh ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3037
                                    hiH isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3038
                                        hiH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3039
                                        hiValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3040
                                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3041
                                        ch < hiValH ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3042
                                            hiH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3043
                                            hiValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3044
                                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3045
                                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3046
                                ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3047
                                    lowH isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3048
                                        lowH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3049
                                        lowValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3050
                                    ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3051
                                        ch > lowValH ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3052
                                            lowH := aColor.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3053
                                            lowValH := ch
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3054
                                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3055
                                    ] 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3056
                                ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3057
                            ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3058
                        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3059
                    ]
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3060
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3061
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3062
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3063
    ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3064
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3065
    "found bounds for light ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3066
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3067
    lowL notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3068
        rl = lowValL ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3069
            ^ aBlock value:lowL value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3070
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3071
        hiL notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3072
            ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3073
                monoDitherFor:1.0 / (hiValL - lowValL) / (rl - lowValL)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3074
                between:lowL and:hiL 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3075
                on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3076
                into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3077
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3078
        "found bound for light - dither with white"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3079
        ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3080
            monoDitherFor:1.0 / (100 - lowValL) / (rl - lowValL)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3081
            between:lowL and:White 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3082
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3083
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3084
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3085
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3086
    "found bound for light - dither with black"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3087
    hiL notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3088
        ^ self  
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3089
            monoDitherFor:1.0 / (hiValL) / (rl)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3090
            between:Black and:hiL 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3091
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3092
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3093
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3094
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3095
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3096
    "found bounds for saturation?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3097
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3098
    (lowS notNil and:[hiS notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3099
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3100
        'saturation dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3101
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3102
        ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3103
            monoDitherFor:1.0 / (hiValS - lowValS) / (rs - lowValS)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3104
            between:lowS and:hiS
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3105
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3106
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3107
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3108
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3109
    "found bounds for hue ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3110
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3111
    (lowH notNil and:[hiH notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3112
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3113
        'hue dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3114
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3115
        hiValH < lowValH ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3116
            hiValH := hiValH + 360
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3117
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3118
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3119
        d := hiValH - lowValH.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3120
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3121
        ^ self 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3122
            monoDitherFor:1.0 / (d / (rh - lowValH))
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3123
            between:lowH and:hiH 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3124
            on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3125
            into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3126
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3127
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3128
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3129
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3130
    "Modified: 3.5.1997 / 10:58:54 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3131
    "Created: 3.5.1997 / 11:02:03 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3132
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3133
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3134
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
  3135
    "get a dither form for an rgb value.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3136
     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
  3137
     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
  3138
     dither colors."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3139
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3140
    | 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3141
     nR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3142
     nG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3143
     nB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3144
     hR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3145
     hG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3146
     hB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3147
     eR eG eB
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3148
     rI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3149
     gI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3150
     bI  "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3151
     idx "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3152
     f clr
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3153
     r    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3154
     g    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3155
     b    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3156
     x1   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3157
     x2   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3158
     step "{ Class: SmallInteger }" 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3159
     lastIdx mx 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3160
     dS   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3161
     cube|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3162
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3163
    (cube := aDevice fixColors) notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3164
        dS := 4.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3165
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3166
        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
  3167
        f initGC.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3168
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3169
        mx := MaxValue asFloat.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3170
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3171
        nR := aDevice numFixRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3172
        nG := aDevice numFixGreen.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3173
        nB := aDevice numFixBlue.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3174
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3175
        hR := nR // 2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3176
        hG := nG // 2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3177
        hB := nB // 2.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3178
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3179
        eR := eG := eB := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3180
        r := redVal.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3181
        g := greenVal.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3182
        b := blueVal.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3183
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3184
        step := -1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3185
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3186
        0 to:dS-1 do:[:y |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3187
            step == -1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3188
                x1 := 0. x2 := dS-1. step := 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3189
            ] ifFalse:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3190
                x1 := dS-1. x2 := 0. step := -1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3191
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3192
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3193
            x1 to:x2 by:step do:[:x |
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3194
                "/ the nearest along the grid
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3195
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3196
                r := redVal + eR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3197
                r > MaxValue ifTrue:[r := MaxValue]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3198
                             ifFalse:[r < 0 ifTrue:[r := 0]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3199
                g := greenVal + eG.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3200
                g > MaxValue ifTrue:[g := MaxValue]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3201
                             ifFalse:[g < 0 ifTrue:[g := 0]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3202
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3203
                b := blueVal + eB.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3204
                b > MaxValue ifTrue:[b := MaxValue]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3205
                             ifFalse:[b < 0 ifTrue:[b := 0]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3206
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3207
                rI := (r * (nR-1) + hR / mx) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3208
                gI := (g * (nG-1) + hG / mx) rounded .
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3209
                bI := (b * (nB-1) + hB / mx) rounded .
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3210
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3211
                idx := (((rI * nG) + gI) * nB + bI) + 1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3212
                clr := (cube at:idx) exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3213
                lastIdx isNil ifTrue:[lastIdx := idx]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3214
                ifFalse:[lastIdx ~~ idx ifTrue:[lastIdx := -1]].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3215
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3216
                f foreground:clr.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3217
                f displayPointX:x y:y.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3218
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3219
                eR := r  - clr scaledRed.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3220
                eG := g  - clr scaledGreen.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3221
                eB := b  - clr scaledBlue.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3222
            ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3223
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3224
        f releaseGC.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3225
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3226
        lastIdx ~~ -1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3227
            ^ aBlock value:clr value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3228
        ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3229
        ^ aBlock value:nil value:f
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3230
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3231
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3232
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3233
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3234
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3235
    "Modified: 11.7.1996 / 18:30:28 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3236
    "Created: 3.5.1997 / 11:03:18 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3237
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3238
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3239
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
  3240
    "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
  3241
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3242
     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
  3243
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3244
    |form c1 c2 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3245
     index "{ Class:SmallInteger }"|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3246
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3247
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3248
    "/ 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
  3249
    "/ 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
  3250
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3251
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3252
    index := (fraction * 64) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3253
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3254
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3255
    index < 1 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3256
        ^ aBlock value:c1 value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3257
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3258
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3259
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3260
    index >= 64 ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3261
        ^ aBlock value:c2 value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3262
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3263
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3264
    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
  3265
    form colorMap:(Array with:c1 with:c2).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3266
    ^ aBlock value:nil value:form
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3267
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3268
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3269
     Color basicNew
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3270
        monoDitherFor:(MaxValue // 2)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3271
        between:Color black 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3272
        and:Color white 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3273
        on:Display 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3274
        into:[:clr :dither | clr inspect. dither inspect]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3275
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3276
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3277
    "Created: 3.5.1997 / 10:55:06 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3278
    "Modified: 3.5.1997 / 11:05:20 / cg"
1023
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
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3281
!Color class methodsFor:'queries'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3282
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3283
constantNames
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3284
    "return names known as instance creation messages"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3285
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3286
    ^ #(white black 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3287
        grey mediumGrey veryLightGrey lightGrey darkGrey veryDarkGrey
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3288
        red green blue cyan yellow pink orange magenta)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3289
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3290
    "Modified: 2.5.1996 / 11:34:05 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3293
scalingValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3294
    "ST-80 compatibility"
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
    ^ MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3297
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3298
    "Created: 2.5.1996 / 11:30:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3299
    "Modified: 11.7.1996 / 21:42:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3300
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3301
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3302
!Color class methodsFor:'special instance creation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3303
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3304
nearestColorRed:r green:g blue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3305
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3306
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3307
     If there is one, return it; nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3308
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3309
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3310
     vector distance (which may not be the best possible solution)."
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
    ^ self
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3313
        nearestColorScaledRed:(r * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3314
                  scaledGreen:(g * MaxValue // 100) 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3315
                   scaledBlue:(b * MaxValue // 100) 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3316
                           on:aDevice 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3317
                           in:colors
1023
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
    "Modified: 11.6.1996 / 18:04:55 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3320
    "Created: 14.6.1996 / 20:05:13 / 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
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
  3324
    "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
  3325
     collection, containing colors from a colorCube.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3326
     This is used with preallocated fixColors and is quite fast 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3327
     (no need to search)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3328
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3329
    |sR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3330
     sG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3331
     sB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3332
     idx "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3333
     nR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3334
     nG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3335
     nB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3336
     rI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3337
     gI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3338
     bI  "{ Class: SmallInteger }"|
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3341
     round to the step given by FixColors
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
    nR := nRed.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3344
    nG := nGreen.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3345
    nB := nBlue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3346
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3347
    sR := MaxValue // (nR - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3348
    sG := MaxValue // (nG - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3349
    sB := MaxValue // (nB - 1).
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
    rI := (r + (sR // 2)) // sR.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3352
    gI := (g + (sG // 2)) // sG.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3353
    bI := (b + (sB // 2)) // sB.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3354
    idx := (((rI * nG) + gI) * nB + bI) + 1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3355
    ^ aColorCube at:idx
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
    "Modified: 11.7.1996 / 17:52:46 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3358
    "Created: 11.7.1996 / 18:20:13 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3359
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3360
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3361
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3362
    "return a device color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3363
     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
  3364
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3365
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3366
     vector distance (which may not be the best possible solution)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3367
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3368
    |cube|
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
     if there are preallocated colors, things are much easier ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3372
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3373
    (cube := aDevice fixColors) notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3374
        ^ self 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3375
            nearestColorScaledRed:r 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3376
            scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3377
            scaledBlue:b
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3378
            inCube:cube
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3379
            numRed:(aDevice numFixRed)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3380
            numGreen:(aDevice numFixGreen)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3381
            numBlue:(aDevice numFixBlue)
1023
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3385
     search in existing colors ...
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
    ^ self 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3388
        nearestColorScaledRed:r 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3389
        scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3390
        scaledBlue:b 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3391
        on:aDevice 
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3392
        in:aDevice deviceColors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3393
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3394
    "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
  3395
    "Modified: 24.2.1997 / 18:17:51 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3396
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3397
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3398
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3399
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3400
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3401
     If there is one, return it; nil otherwise."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3402
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3403
    |delta minDelta bestSoFar|
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
    minDelta := 9999999.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3406
1619
4a7dbd25c588 handle the case where not even r/g/b primaries can be allocated
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3407
    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
  3408
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3409
    colors do:[:aColor |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3410
        |cr cg cb|
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3411
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3412
        (aDevice isNil 
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3413
        or:[(aColor graphicsDevice == aDevice)
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3414
            and:[aColor colorId notNil]]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3415
                delta := aColor deltaFromScaledRed:r scaledGreen:g scaledBlue:b.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3416
                delta < minDelta ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3417
                    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3418
                     an exact fit - no need to continue search
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3419
                    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3420
                    delta == 0 ifTrue:[^ aColor].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3421
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3422
                    bestSoFar := aColor.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3423
                    minDelta := delta
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3424
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3425
            ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3426
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3427
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3428
    ^ bestSoFar
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3429
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3430
    "Created: / 11.6.1996 / 18:02:12 / cg"
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3431
    "Modified: / 28.7.1998 / 20:40:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3432
!
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
quickNearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3435
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3436
     same or near r/g/b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3437
     This looks for primary colors only and is thus faster
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3438
     than the general nearestColor search (slightly uglier though)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3439
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3440
    |cube|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3441
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3442
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3443
     if there are preallocated colors, things are much easier ...
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3444
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3445
    (cube := aDevice fixColors) notNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3446
        ^ self 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3447
            nearestColorScaledRed:r 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3448
            scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3449
            scaledBlue:b 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3450
            inCube:cube
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3451
            numRed:(aDevice numFixRed)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3452
            numGreen:(aDevice numFixGreen)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3453
            numBlue:(aDevice numFixBlue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3454
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3455
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3456
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3457
     search in existing colors ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3458
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3459
    ^ self nearestColorScaledRed:r 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3460
                     scaledGreen:g 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3461
                      scaledBlue:b 
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3462
                        on:aDevice 
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3463
                        in:(aDevice availableDitherColors)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3464
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3465
    "Created: 14.6.1996 / 20:13:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3466
    "Modified: 11.7.1996 / 18:20:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3467
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3468
3145
be28f5978253 category renamining
Claus Gittinger <cg@exept.de>
parents: 3122
diff changeset
  3469
!Color methodsFor:'Compatibility - ST80'!
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3470
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3471
asDevicePaintOn:aDevice
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3472
    "ST-80 compatibility: an alias for on:.
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3473
     create a new Color representing the same color as
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3474
     myself on aDevice; if one already exists, return the one"
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3475
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  3476
    ^ self onDevice:aDevice
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3477
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3478
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3479
asHiliteColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3480
    "same as lightened - for ST-80 compatibility"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3481
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3482
    ^ self lightened
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3483
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3484
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3485
asShadowColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3486
    "same as darkened - for ST-80 compatibility"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3487
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3488
    ^ self darkened
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3489
! !
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3490
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3491
!Color methodsFor:'Compatibility - Squeak'!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3492
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3493
bitPatternForDepth: depth
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3494
    "Return a Bitmap, possibly containing a stipple pattern, 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3495
     that best represents this color at the given depth. 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3496
     BitBlt calls this method to convert colors into Bitmaps. 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3497
     The resulting Bitmap may be multiple words to represent a stipple 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3498
     pattern of several lines.  "
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3499
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3500
    "See also:      
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3501
        pixelValueAtDepth:      -- value for single pixel
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3502
        pixelWordAtDepth:       -- a 32-bit word filled with the pixel value"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3503
    "Details: The pattern for the most recently requested depth is cached."
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3504
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3505
^ self.
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3506
"/    depth == cachedDepth ifTrue: [^ cachedBitPattern].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3507
"/    cachedDepth _ depth.
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3508
"/
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3509
"/    depth > 2 ifTrue: [^ cachedBitPattern _ Bitmap with: (self pixelWordForDepth: depth)].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3510
"/    depth = 1 ifTrue: [^ cachedBitPattern _ self halfTonePattern1].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3511
"/    depth = 2 ifTrue: [^ cachedBitPattern _ self halfTonePattern2].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3512
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3513
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3514
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3515
darker
3030
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3516
    "return a new color, which is darker than the receiver.
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3517
     Almost the same as darkened for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3518
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3519
    ^ self mixed:0.8333 with:Black
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3520
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3521
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3522
     (Color red) darker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3523
     (Color red) muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3524
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3525
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3526
    "Modified: 11.6.1996 / 18:10:37 / cg"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3527
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3528
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3529
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3530
lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3531
    "return a new color, which is slightly lighter than the receiver.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3532
     Almost the same as lightened for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3533
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3534
    ^ self mixed:0.8333 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3535
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3536
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3537
     (Color red) 
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3538
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3539
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3540
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3541
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3542
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3543
    "Modified: 11.6.1996 / 18:10:49 / cg"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3544
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3545
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3546
muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3547
    "return a new color, which is much darker than the receiver.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3548
     Added for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3549
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3550
    ^ self mixed:0.233 with:Black
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3551
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3552
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3553
     (Color red) darker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3554
     (Color red) muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3555
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3556
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3557
    "Modified: 11.6.1996 / 18:10:49 / cg"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3558
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3559
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3560
muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3561
    "return a new color, which is much lighter than the receiver.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3562
     Added for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3563
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3564
    ^ self mixed:0.233 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3565
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3566
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3567
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3568
     (Color red) mixed:0.833 with:Color white
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3569
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3570
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3571
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3572
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3573
    "Modified: 11.6.1996 / 18:10:49 / cg"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3574
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3575
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  3576
newTileMorphRepresentative
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  3577
	^ ColorTileMorph new colorSwatchColor: self!
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  3578
3030
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3579
slightlyDarker
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3580
    "return a new color, which is slightly darker than the receiver.
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3581
     Almost the same as darkened for Squeak compatibility."
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3582
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3583
    ^ self mixed:0.8333 with:Black
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3584
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3585
    "
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3586
     (Color red) darker
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3587
     (Color red) muchDarker
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3588
    "
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3589
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3590
    "Modified: 11.6.1996 / 18:10:37 / cg"
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3591
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3592
!
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3593
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3594
slightlyLighter
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3595
    "return a new color, which is slightly lighter than the receiver.
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3596
     Almost the same as darkened for Squeak compatibility."
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3597
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3598
    ^ self mixed:0.2 with:White
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3599
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3600
    "
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3601
     (Color red) lighter
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3602
     (Color red) slightlyLighter
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3603
    "
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3604
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3605
    "Modified: 11.6.1996 / 18:10:37 / cg"
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3606
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3607
!
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  3608
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3609
veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3610
    "return a new color, which is very much lighter than the receiver.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3611
     Added for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3612
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3613
    ^ self mixed:0.1165 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3614
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3615
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3616
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3617
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3618
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3619
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3620
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3621
    "Modified: 11.6.1996 / 18:10:49 / cg"
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3622
! !
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3623
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3624
!Color methodsFor:'accessing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3625
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3626
alpha
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3627
    "return the alpha value (0..1),
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3628
     where 0 is completely transparent and 1 is completely opaque"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3629
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3630
    ^ 1.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3631
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  3632
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3633
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3634
    "return the blue component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3635
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3636
    (blue isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3637
        device getRGBFrom:colorId into:[:r :g :b | ^ b].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3638
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3639
    ^ blue * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3640
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3641
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3642
blueByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3643
    "return the blue components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3644
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3645
    blue isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3646
    ^ blue * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3647
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3648
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3649
     Color red blueByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3650
     Color blue blueByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3651
     Color green blueByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3652
     Color black blueByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3653
     Color grey blueByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3654
     Color white blueByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3655
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3656
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3657
    "Created: / 7.6.1996 / 18:30:25 / cg"
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3658
    "Modified: / 26.7.1998 / 12:31:44 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3659
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3660
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3661
colorId
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3662
    "return the device-dependent color-id"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3663
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3664
    colorId notNil ifTrue:[^ colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3665
    replacementColor notNil ifTrue:[^ replacementColor colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3666
    ^ nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3667
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  3668
    "Modified: 17.1.1997 / 00:03:18 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3669
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3670
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3671
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3672
    "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
  3673
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3674
    ^ 100 - self red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3675
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3676
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3677
    "Created: 11.6.1996 / 18:30:00 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3678
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3679
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3680
device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3681
    "return the device I am associated to"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3682
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3683
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3684
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3685
    "Modified: 23.4.1996 / 13:36:42 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3686
!
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
deviceBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3689
    "return the actual value of the blue component in percent."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3690
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3691
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3692
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3693
    device getRGBFrom:colorId into:[:r :g :b | v := b].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3694
    ^ v
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3697
deviceGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3698
    "return the actual value of the green component in percent.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3699
     (usually 16bit in X; but could be different on other systems)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3700
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3701
    |v|
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
    device getRGBFrom:colorId into:[:r :g :b | v := g].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3704
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3705
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3706
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3707
deviceRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3708
    "return the actual value of the red component in percent."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3709
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3710
    |v|
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
    device getRGBFrom:colorId into:[:r :g :b | v := r].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3713
    ^ v
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3716
     (Color yellow on:Display) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3717
     (Color yellow on:aPrinterPage) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3718
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3719
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3720
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3721
ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3722
    "return the form to dither the color"
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
    ^ ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3725
!
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
graphicsDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3728
    "same as #device, for ST-80 compatibility naming.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3729
     Return the device I am associated with."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3730
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3731
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3732
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3733
    "Created: 28.5.1996 / 18:39:27 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3734
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3735
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3736
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3737
    "return the green component in percent [0..100]"
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
    (green isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3740
        device getRGBFrom:colorId into:[:r :g :b | ^ g].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3741
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3742
    ^ green * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3743
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3744
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3745
greenByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3746
    "return the green components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3747
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3748
    green isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3749
    ^ green * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3750
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3751
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3752
     Color red greenByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3753
     Color blue greenByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3754
     Color green greenByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3755
     Color black greenByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3756
     Color grey greenByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3757
     Color white greenByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3758
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3759
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3760
    "Modified: / 26.7.1998 / 12:31:33 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3761
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3762
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3763
hue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3764
    "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
  3765
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3766
    |r g b h|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3767
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3768
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3769
        device getRGBFrom:colorId into:[:xr :xg :xb |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3770
            r := xr.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3771
            g := xg.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3772
            b := xb.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3773
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3774
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3775
        r := self red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3776
        g := self green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3777
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3778
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3779
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3780
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3781
        h := xh
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3782
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3783
    ^ h
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3784
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3785
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3786
     Color yellow hue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3787
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3788
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3789
    "Modified: 11.6.1996 / 17:14:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3790
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3791
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3792
light 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3793
    "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
  3794
     This corresponds to the brightness of the color (if displayed on
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3795
     a b&w television screen)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3796
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3797
    |r g b l|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3798
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3799
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3800
        device getRGBFrom:colorId into:[:xr :xg :xb |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3801
            r := xr.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3802
            g := xg.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3803
            b := xb.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3804
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3805
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3806
        r := self red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3807
        g := self green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3808
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3809
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3810
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3811
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3812
        l := xl
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3813
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3814
    ^ l
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3815
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3816
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3817
     Color yellow light          
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3818
     Color yellow darkened light   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3819
    "
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
    "Modified: 11.6.1996 / 17:15:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3822
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3823
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3824
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3825
    "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
  3826
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3827
    ^ 100 - self green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3828
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3829
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3830
    "Created: 11.6.1996 / 18:30:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3831
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3832
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3833
privateAlpha
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3834
    "return the internal alpha value (0..255),
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3835
     where 0 is completely transparent and 255 is completely opaque"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3836
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3837
    ^ 255 
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3838
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3839
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3840
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3841
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3842
    "return the red component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3843
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3844
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3845
        device getRGBFrom:colorId into:[:r :g :b | ^ r].
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
    red isNil ifTrue:[^ 0].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3848
    ^ red * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3849
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3850
    "Modified: 11.6.1996 / 17:20:07 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3853
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3854
    "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
  3855
     table in pseudocolor devices.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3856
     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
  3857
     Color>>variableColorOn: on pseudoColor displays). 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3858
     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
  3859
     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
  3860
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3861
    ^ self scaledRed:(r * MaxValue // 100)
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3862
           scaledGreen:(g * MaxValue // 100)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3863
           scaledBlue:(b * MaxValue // 100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3864
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3865
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3866
     |c|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3867
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3868
     c := Color variableColorOn:Display.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3869
     c inspect.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3870
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3871
     c red:100 green:0 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3872
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3873
     c red:0 green:100 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3874
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3875
     c red:0 green:0 blue:100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3876
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3877
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3878
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3879
redByte
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3880
    "return the red components value mapped to 0..255;
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3881
     nil if it has no red component."
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3882
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3883
    red isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3884
    ^ red * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3885
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3886
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3887
     Color red redByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3888
     Color blue redByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3889
     Color green redByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3890
     Color black redByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3891
     Color grey redByte    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3892
     Color white redByte   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3893
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3894
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  3895
    "Modified: / 26.7.1998 / 12:31:22 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3896
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3897
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3898
rgbValue
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3899
    "return the rgb byteValues packed into a 24bit integer;
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3900
     The returned value is composed of r<<16 + g<<8 + b."
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3901
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3902
    |t "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3903
     v "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3904
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3905
    v := red * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3906
    t := green * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3907
    v := (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3908
    t := blue * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3909
    ^ (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3910
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3911
    "
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3912
     Color red rgbValue hexPrintString  
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3913
     Color blue rgbValue hexPrintString  
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3914
     Color green rgbValue hexPrintString   
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3915
     Color black rgbValue hexPrintString   
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3916
     Color grey rgbValue hexPrintString   
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3917
     Color white rgbValue hexPrintString  
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3918
    "
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3919
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3920
    "Modified: 17.10.1997 / 20:00:25 / cg"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3921
!
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3922
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3923
saturation 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3924
    "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
  3925
     This corresponds to the saturation setting of a color TV"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3926
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3927
    |r g b s|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3928
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3929
    (red isNil and:[colorId notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3930
        device getRGBFrom:colorId into:[:xr :xg :xb |
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3931
            r := xr.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3932
            g := xg.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3933
            b := xb.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3934
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3935
    ] ifFalse:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3936
        r := self red.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3937
        g := self green.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3938
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3939
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3940
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3941
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  3942
        s := xs
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3943
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3944
    ^ s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3945
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3946
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3947
     Color yellow saturation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3948
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3949
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3950
    "Modified: 11.6.1996 / 17:15:47 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3951
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3952
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3953
scaledBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3954
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3955
     return the blue components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3956
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3957
    ^ blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3958
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3959
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3960
     Color blue scaledBlue   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3961
     Color black scaledBlue  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3962
     Color grey scaledBlue   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3963
    "
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
    "Modified: 7.6.1996 / 18:32:30 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3966
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3967
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3968
scaledGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3969
    "return the grey intensity scaled to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3970
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3971
    ^ ((red * 3) + (green * 6) + blue) // 10
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3972
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
     Color blue scaledGray   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3975
     Color black scaledGray  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3976
     Color white scaledGray  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3977
     Color grey scaledGray    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3978
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3979
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3980
    "Modified: 11.6.1996 / 14:43:51 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3983
scaledGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3984
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3985
     return the green components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3986
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3987
    ^ green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3988
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3989
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3990
     Color green scaledRed    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3991
     Color black scaledRed  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3992
     Color grey scaledRed   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3993
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3994
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3995
    "Modified: 7.6.1996 / 18:32:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3996
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3997
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3998
scaledRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3999
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4000
     return the red components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4001
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4002
    ^ red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4003
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4004
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4005
     Color red scaledRed    
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4006
     Color black scaledRed  
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4007
     Color grey scaledRed   
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4008
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4009
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4010
    "Modified: 7.6.1996 / 18:32:43 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4011
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4012
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4013
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4014
    "set r/g/b components in 0..MaxValue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4015
     This method will change the color lookup table in pseudocolor devices.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4016
     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
  4017
     Color>>variableColorOn: on pseudoColor displays).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4018
     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
  4019
     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
  4020
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4021
    (colorId isNil or:[red notNil]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4022
        ^ self error:'operation is not allowed for shared colors'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4023
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4024
    device setColor:colorId scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4025
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4026
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4027
writable
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4028
    "return true, if this is a writable colorcell"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4029
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4030
    ^ writable == true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4031
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4032
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4033
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4034
    "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
  4035
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4036
    ^ 100 - self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4037
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4038
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4039
    "Created: 11.6.1996 / 18:30:20 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4040
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4041
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4042
!Color methodsFor:'binary storage'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4043
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4044
readBinaryContentsFrom: stream manager: manager
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4045
    "tell the newly restored Color about restoration"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4046
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4047
    super readBinaryContentsFrom:stream manager:manager.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4048
    self postCopy
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4049
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4050
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4051
!Color methodsFor:'comparing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4052
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4053
= aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4054
    "two colors are considered equal, if the color components are;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4055
     independent of the device, the color is on"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4056
2083
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  4057
    aColor == self ifTrue:[^ true].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4058
    aColor isColor ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4059
        (red == aColor scaledRed) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4060
            (green == aColor scaledGreen) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4061
                (blue == aColor scaledBlue) ifTrue:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4062
                    ^ true
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4063
                ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4064
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4065
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4066
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4067
    ^ false
2083
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  4068
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  4069
    "Modified: / 2.4.1998 / 10:04:39 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4070
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4071
1390
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4072
almostSameAs:aColor
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4073
    "return true, if aColor looks almost the same as the receiver
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4074
     (i.e. the components differ by a small, invisible amount).
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4075
     We assume, that the human eye can distinguish roughly 100 grey levels
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4076
     (which is optimistic ;-);
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4077
     therefore, allow a 1 percent difference in each component for the colors
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4078
     to compare as looking the same."
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4079
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4080
     (self red - aColor red) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4081
     (self green - aColor green) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4082
     (self blue - aColor blue) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4083
     ^ true
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4084
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4085
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4086
      (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
  4087
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4088
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4089
    "Modified: 28.2.1997 / 12:00:01 / cg"
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4090
!
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4091
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4092
hash
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4093
    "return an integer useful as hash key for the receiver.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4094
     Redefined since = is redefined"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4095
2318
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  4096
    red isNil ifTrue:[
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  4097
        ^ colorId
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  4098
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4099
    ^ red + green + blue
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4102
!Color methodsFor:'converting'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4103
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4104
fromLiteralArrayEncoding:encoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4105
    "read my values from an encoding.
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4106
     The encoding is supposed to be either of the form: 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4107
        (#Color redPart greenPart bluePart)
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4108
     or:
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4109
        (#Color constantColorSymbol)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4110
     This is the reverse operation to #literalArrayEncoding."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4111
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4112
    |clr|
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4113
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4114
    encoding size == 2 ifTrue:[
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4115
        clr := Color perform:(encoding at:2).
2779
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
  4116
        red := clr scaledRed.
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
  4117
        green := clr scaledGreen.
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
  4118
        blue := clr scaledBlue
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4119
    ] ifFalse:[
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4120
        red := ((encoding at:2) / 100.0 * MaxValue) rounded.
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4121
        green := ((encoding at:3) / 100.0 * MaxValue) rounded.
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4122
        blue := ((encoding at:4) / 100.0 * MaxValue) rounded.
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4123
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4124
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
      Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4127
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4128
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4129
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4130
literalArrayEncoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4131
    "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
  4132
     can be reconstructed with #decodeAsLiteralArray.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4133
     The encoding is: 
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4134
        (#Color redPart greenPart bluePart)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4135
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4136
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4137
    ^ Array
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4138
        with:self class name asSymbol
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4139
        with:(red * 100.0 / MaxValue)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4140
        with:(green * 100.0 / MaxValue)
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4141
        with:(blue * 100.0 / MaxValue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4142
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4143
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4144
      Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4145
      (Color red:25 green:30 blue:70) literalArrayEncoding 
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4148
    "Modified: 22.4.1996 / 13:00:11 / cg"
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
!Color methodsFor:'copying'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4152
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4153
postCopy
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4154
    "redefined to clear out any device handles in the copy"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4155
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4156
    device := colorId := ditherForm := replacementColor := nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4157
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4158
    "Modified: 17.1.1997 / 00:03:42 / cg"
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4159
!
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4160
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4161
skipInstvarIndexInDeepCopy:index
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4162
    index == 4 ifTrue:[
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4163
        ^ true "/ skip device
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4164
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4165
    index == 5 ifTrue:[
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4166
        ^ true "/ skip colorId
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4167
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4168
    index == 6 ifTrue:[
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4169
        ^ true "/ skip ditherForm
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4170
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4171
    index == 7 ifTrue:[
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4172
        ^ true "/ skip replacementColor
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4173
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4174
    ^ false
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4175
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4176
    "
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4177
     (Color black onDevice:Screen current) deepCopy
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4178
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4179
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4180
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4181
!Color methodsFor:'getting a device color'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4182
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4183
exactOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4184
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4185
     myself on aDevice; if one already exists, return the one.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4186
     Do not dither or otherwise approximate the color, but return
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4187
     nil, if the exact color is not available. 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4188
     Used to aquire primary colors for dithering, during startup."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4189
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4190
    |newColor id r g b|
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
    "if Iam already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4193
    (device == aDevice and:[ditherForm isNil]) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4194
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4195
    r := red.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4196
    g := green.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4197
    b := blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4198
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4199
    "first look if not already there"
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4200
    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
  4201
    (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
  4202
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4203
    r := (r bitAnd:16rFF00) bitOr:(r bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4204
    g := (g bitAnd:16rFF00) bitOr:(g bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4205
    b := (b bitAnd:16rFF00) bitOr:(b bitShift:-8).
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
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4208
    id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4209
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4210
        "/ this is a kludge: scavenge to free unused colors
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4211
        "/  and try again ...
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4212
        ObjectMemory scavenge; finalize.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4213
        id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4214
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4215
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4216
        "no such color - fail"
1023
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
"/      'COLOR: no color for ' infoPrint. self displayString infoPrintCR.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4219
        ^ nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4220
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4221
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4222
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4223
    device isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4224
        device := aDevice.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4225
        colorId := id.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4226
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4227
        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
  4228
            "/ Lobby register:self.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4229
            aDevice registerColor:self.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4230
        ].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4231
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4232
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4233
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4234
    "receiver was already associated to another device - need a new color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4235
    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
  4236
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4237
    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
  4238
        "/ Lobby register:newColor.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4239
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4240
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4241
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4242
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4243
    "Modified: 24.2.1997 / 18:23:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4244
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4245
1856
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4246
exactOrNearestOn:aDevice
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4247
    "get a device color for the receiver, which is either exact
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4248
     or the nearest, but never dithered.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4249
     This can be used for viewBackgrounds, where the exact greyLevel
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4250
     does not matter, but a dithered color is not wanted."
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4251
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4252
    |deviceColor|
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4253
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4254
    deviceColor := self exactOn:aDevice.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4255
    deviceColor isNil ifTrue:[
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4256
        deviceColor := self nearestOn:aDevice
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4257
    ].
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4258
    ^ deviceColor
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4259
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4260
    "Created: 13.8.1997 / 15:25:48 / cg"
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4261
!
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4262
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4263
nearestIn:aColorMap 
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4264
    "return the nearest color in a colorMap"
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4265
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4266
    ^ self class
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4267
        nearestColorScaledRed:(self scaledRed)
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4268
                  scaledGreen:(self scaledGreen)
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4269
                   scaledBlue:(self scaledBlue)
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4270
                           on:nil 
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4271
                           in:aColorMap
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4272
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4273
    "Created: / 28.7.1998 / 20:42:11 / cg"
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4274
!
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4275
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4276
nearestOn:aDevice 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4277
    "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
  4278
     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
  4279
     search for the nearest match"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4280
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4281
    |newColor id|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4282
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4283
    "if I'am already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4284
    (device == aDevice) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4285
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4286
    "first look if not already there"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4287
    newColor := Color nearestColorScaledRed:red scaledGreen:green scaledBlue:blue on:aDevice.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4288
    newColor notNil ifTrue:[^ newColor].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4289
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4290
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4291
    id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4292
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4293
        "this is a kludge: 
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4294
            scavenge to possuby free unused colors and try again ...
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4295
            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
  4296
            but that is too expensive.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4297
        "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4298
" "
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4299
        ObjectMemory scavenge; finalize.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4300
        id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4301
" "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4302
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4303
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4304
        "no color - fail"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4305
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4306
        ^ nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4307
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4308
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4309
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4310
    device isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4311
        device := aDevice.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4312
        colorId := id.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4313
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4314
        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
  4315
            "/ Lobby register:self.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4316
            aDevice registerColor:self.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4317
        ].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4318
        ^ self
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4321
    "receiver was already associated to another device - need a new color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4322
    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
  4323
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4324
    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
  4325
        "/ Lobby register:newColor.
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4326
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4327
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4328
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4329
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4330
    "Modified: 24.2.1997 / 18:23:26 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4331
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4332
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4333
on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4334
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4335
     myself on aDevice; if one already exists, return the one"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4336
2836
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4337
"/    self obsoleteMethodWarning:'use onDevice:'.
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4338
    ^ self onDevice:aDevice
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4339
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4340
    "Created: / 16.11.1995 / 20:16:42 / cg"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4341
    "Modified: / 8.9.1998 / 17:32:10 / cg"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4342
!
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4343
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4344
onDevice:aDevice
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4345
    "create a new Color representing the same color as
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4346
     myself on aDevice; if one already exists, return the one"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4347
1855
dc59c0c86b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1770
diff changeset
  4348
    |newColor id form 
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4349
     greyV "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4350
     rV    "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4351
     gV    "{ Class: SmallInteger }" 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4352
     bV    "{ Class: SmallInteger }"
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4353
     deviceVisual deviceFixColors deviceDepth|
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4354
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4355
    "/ the most common cases (already allocated) first 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4356
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4357
    colorId notNil ifTrue:[
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4358
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4359
        "/ is someone validating me before drawing on aDevice ?
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4360
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4361
        aDevice notNil ifTrue:[
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4362
            aDevice == device ifTrue:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4363
                ^ self
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4364
            ]
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4365
        ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4366
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4367
        "/ a special case for pseudo-colors (0 and 1 in bitmaps)
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4368
        "/ those have nil r/g/b values, but a nonNil colorId
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4369
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4370
        red isNil ifTrue:[^ self].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4371
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4372
        "/ want to release color ?
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4373
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4374
        (aDevice isNil and:[device notNil]) ifTrue:[
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4375
            "/ trueColor device-colors are not registered
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4376
            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
  4377
                device unregisterColor:newColor.
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4378
                device freeColor:colorId
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4379
            ].
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4380
            device := nil.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4381
            colorId := nil.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4382
            ^ self
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4383
        ].
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4384
    ].
2313
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4385
    aDevice isNil ifTrue:[
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4386
        ^ self
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4387
    ].
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4388
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4389
    device == aDevice ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4390
        ditherForm notNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4391
            ^ self
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4392
        ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4393
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4394
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4395
    "/ 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
  4396
    "/ especially freeing colors
2842
dcb1f8eb648f removed obsolete method
Claus Gittinger <cg@exept.de>
parents: 2836
diff changeset
  4397
    "/ (no need to register)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4398
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4399
    deviceDepth := aDevice depth.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4400
    (deviceVisual := aDevice visualType) == #TrueColor ifTrue:[
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4401
        deviceDepth >= 15 ifTrue:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4402
            id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4403
            id notNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4404
                device isNil ifTrue:[
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4405
                    "/ receiver was not associated - do it now & return mySelf
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4406
                    colorId := id.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4407
                    ditherForm := nil.
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4408
                    device := aDevice.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4409
                    ^ self
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4410
                ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4411
                newColor := (self class basicNew) 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4412
                                    setScaledRed:red 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4413
                                    scaledGreen:green 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4414
                                    scaledBlue:blue 
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4415
                                    device:aDevice.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4416
                newColor setColorId:id.
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4417
                ^ newColor
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4418
            ] 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4419
        ] 
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4420
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4421
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4422
    "/ round a bit within 1% in red & green, 2% in blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4423
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4424
    rV := red.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4425
    gV := green.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4426
    bV := blue.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4427
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4428
"/    rV := (red / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4429
"/    gV := (green / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4430
"/    bV := (blue / 50.0) rounded * 50.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4431
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4432
    "/ if I am already assigned to that device ...
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4433
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4434
"/    ((device == aDevice) and:[ditherForm notNil]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4435
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4436
"/        "/ 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
  4437
"/        "/ try again - maybe some colors were reclaimed in the meanwhile
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4438
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4439
"/        deviceFixColors := aDevice fixColors.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4440
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4441
"/        (deviceFixColors isNil
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4442
"/         and:[RetryAllocation]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4443
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4444
"/             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
  4445
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4446
"/            aDevice depth > 2 ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4447
"/                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4448
"/                id notNil ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4449
"/                    colorId := id.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4450
"/                    ditherForm := nil.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4451
"/                    device registerColor:self.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4452
"/                ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4453
"/            ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4454
"/        ].
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4455
"/        ^ self
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4456
"/    ].
1023
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
    newColor := Color existingColorScaledRed:rV scaledGreen:gV scaledBlue:bV on:aDevice.
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4459
    newColor notNil ifTrue:[
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4460
        (newColor scaledRed ~~ red
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4461
        or:[newColor scaledGreen ~~ green
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4462
        or:[newColor scaledBlue ~~ blue]]) ifTrue:[
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4463
            Transcript showCR:'oops'.
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4464
        ].
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4465
        ^ newColor
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4466
    ].
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4467
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4468
    "/ ask that device for the exact color
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4469
    id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4470
    id notNil ifTrue:[
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4471
        device isNil ifTrue:[
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4472
            "/ receiver was not associated - do it now & return mySelf
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4473
            colorId := id.
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4474
            ditherForm := nil.
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4475
            device := aDevice.
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4476
            newColor := self.
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4477
        ] ifFalse:[
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4478
            newColor := (self class basicNew) 
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4479
                                setScaledRed:red 
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4480
                                scaledGreen:green 
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4481
                                scaledBlue:blue 
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4482
                                device:aDevice.
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4483
            newColor setColorId:id.
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4484
        ].
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4485
        id notNil ifTrue:[
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4486
            deviceVisual ~~ #TrueColor ifTrue:[    
2976
3eec8a0c6747 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2975
diff changeset
  4487
                aDevice registerColor:newColor.
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4488
            ]
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4489
        ].
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4490
        ^ newColor
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4491
    ]. 
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4492
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4493
    "/
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4494
    "/ ok, we are either going to dither that color, or look for
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  4495
    "/ the nearest.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4496
    "/ 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
  4497
    "/
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4498
    greyV := (3 * red) + (6 * green) + (1 * blue).
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4499
    greyV := (greyV / 1000.0) rounded * 100.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4500
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4501
    "/ allow an error of 1% in red & green, 2% in blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4502
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4503
    ((rV - greyV) abs <= 655                    "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4504
    and:[(gV - greyV) abs <= 655                "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4505
    and:[(bV - greyV) abs <= 1310]]) ifTrue:[   "/ MaxValue // 100 * 2
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4506
        rV := gV := bV := greyV.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4507
    ] ifFalse:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4508
        rV := red. gV := green. bV := blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4509
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4510
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4511
    aDevice hasColors ifTrue:[
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4512
        deviceFixColors := aDevice fixColors.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4513
        deviceFixColors isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4514
            "/ ask that device for the exact color
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4515
            id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4516
            id isNil ifTrue:[
2967
88942aca0c7a dont loop when trying to allocate a color
ca
parents: 2962
diff changeset
  4517
                aDevice isOpen ifFalse:[
88942aca0c7a dont loop when trying to allocate a color
ca
parents: 2962
diff changeset
  4518
                    ^ nil
88942aca0c7a dont loop when trying to allocate a color
ca
parents: 2962
diff changeset
  4519
                ].
88942aca0c7a dont loop when trying to allocate a color
ca
parents: 2962
diff changeset
  4520
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4521
                "/ this is a kludge: scavenge to free unused colors
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4522
                "/ and try again ...
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4523
                ObjectMemory scavenge; finalize.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4524
                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4525
            ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4526
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4527
            id isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4528
                "/ no such color - try color dithers
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4529
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4530
                self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4531
                    ditherRed:rV green:gV blue:bV 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4532
                    on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4533
                    into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4534
                newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4535
            ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4536
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4537
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4538
        "/ none found ? -> do a hard dither using fixColors
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4539
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4540
        (id isNil and:[form isNil]) ifTrue:[
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4541
            deviceFixColors notNil ifTrue:[
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4542
                self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4543
                    fixDitherRed:rV green:gV blue:bV 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4544
                    on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4545
                    into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4546
                newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4547
            ]
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4548
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4549
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4550
        "/ still none found ? -> do a very hard dither using existing colors
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4551
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4552
        (id isNil and:[form isNil]) ifTrue:[
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4553
            self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4554
                complexDitherRed:rV green:gV blue:bV 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4555
                on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4556
                into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4557
            newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4558
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4559
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4560
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4561
    (id isNil and:[form isNil]) ifTrue:[
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4562
        "still no result - try graying"
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4563
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4564
        greyV == 0 ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4565
            id := aDevice blackpixel
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4566
        ] ifFalse:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4567
            greyV == MaxValue ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4568
                id := aDevice whitepixel
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4569
            ] ifFalse:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4570
                aDevice hasGrayscales ifTrue:[
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4571
                    self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4572
                        ditherGrayFor:(greyV / MaxValue)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4573
                        on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4574
                        into:[:c :f | newColor := c. form := f].
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4575
                    newColor notNil ifTrue:[^ newColor].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4576
                ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4577
                form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4578
                    "/ still none - dither b&w
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4579
                    self class
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4580
                        monoDitherFor:(greyV / MaxValue)
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4581
                        between:Black and:White
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4582
                        on:aDevice 
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4583
                        into:[:c :f | newColor := c. form := f].
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4584
                    newColor notNil ifTrue:[^ newColor].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4585
                    form isNil ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4586
                        "/ cannot happen
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4587
                        'Color [warning]: monoDither failed' errorPrintCR.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4588
                        ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4589
                    ]
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4590
                ]
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4591
            ]
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4592
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4593
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4594
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4595
    device isNil ifTrue:[
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4596
        "/ receiver was not associated - do it now & return mySelf
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4597
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4598
        device := aDevice.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4599
        id isNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4600
            ditherForm := form
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4601
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4602
        colorId := id.
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4603
2842
dcb1f8eb648f removed obsolete method
Claus Gittinger <cg@exept.de>
parents: 2836
diff changeset
  4604
        "/ have to register - otherwise it keeps old info around
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4605
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4606
        id notNil ifTrue:[
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4607
            deviceVisual ~~ #TrueColor ifTrue:[    
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4608
                aDevice registerColor:self.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4609
            ]
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4610
        ].
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4611
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4612
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4613
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4614
    "/ receiver was already associated to another device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4615
    "/ - need a new color and return it
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4616
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4617
    newColor := (self class basicNew) 
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4618
                        setScaledRed:red 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4619
                        scaledGreen:green 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4620
                        scaledBlue:blue 
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4621
                        device:aDevice.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4622
    id isNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4623
        newColor setDitherForm:form
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4624
    ] ifFalse:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4625
        newColor setColorId:id.
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4626
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4627
        "/ trueColor device-colors are not registered
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4628
        deviceVisual ~~ #TrueColor ifTrue:[    
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4629
            aDevice registerColor:newColor.
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  4630
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4631
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4632
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4633
2313
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4634
    "Created: / 16.11.1995 / 20:16:42 / cg"
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4635
    "Modified: / 8.9.1998 / 17:32:10 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4636
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4637
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4638
!Color methodsFor:'inspecting'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4639
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4640
inspectorClass
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4641
    "return the class of an appropriate inspector.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4642
     ST/X has a specialized ColorInspectorView for that"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4643
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4644
    ^ ColorInspectorView
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4645
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4646
    "Modified: 23.4.1996 / 13:39:50 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4647
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4648
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4649
!Color methodsFor:'instance creation'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4650
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4651
alpha:alphaValue
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4652
    "return a new color with the same color, but different alpha as the receiver"
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4653
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4654
    alphaValue = 1 ifTrue:[ ^ self].
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4655
    ^ (TranslucentColor 
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4656
           scaledRed:red 
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4657
           scaledGreen:green 
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4658
           scaledBlue:blue) alpha:alphaValue
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4659
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4660
    "
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4661
     Color red alpha:0.5
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4662
    "
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4663
!
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  4664
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4665
blendWith:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4666
    "create a new color from equally mixing the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4667
     and the argument, aColor.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4668
     Mixing is done by adding components 
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4669
     (which is different from mixing colors on paper .. which is subtractive)."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4670
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4671
    ^ self mixed:1 with:aColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4672
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4673
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4674
     (Color red) blendWith:(Color yellow)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4675
     (Color red) blendWith:(Color blue)
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4676
     (Color red) blendWith:(Color black)
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4677
     (Color red) blendWith:(Color white)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4678
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4679
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4680
    "Modified: 10.2.1997 / 22:08:14 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4681
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4682
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4683
darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4684
    "return a new color, which is slightly darker than the receiver"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4685
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4686
    ^ self blendWith:Black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4687
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4688
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4689
     (Color red) darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4690
     (Color red) darkened darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4691
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4692
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4693
    "Modified: 11.6.1996 / 18:10:37 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4694
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4695
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4696
lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4697
    "return a new color, which is slightly lighter than the receiver"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4698
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4699
    ^ self blendWith:White
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4700
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4701
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4702
     (Color red) lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4703
     (Color red) lightened lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4704
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4705
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4706
    "Modified: 11.6.1996 / 18:10:49 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4707
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4708
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4709
mixed:amount with:aColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4710
    "create a new color from mixing amount of the receiver
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4711
     with the argument, aColor.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4712
     Mixing is done by adding components (i.e. additive mixing)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4713
     (which is different from mixing colors on paper .. which is subtractive).
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4714
     With an amount of 1, this is the same as blendWith."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4715
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4716
    red isNil ifTrue:[
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4717
        ^ aColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4718
    ].
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4719
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4720
    ^ (self class)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4721
        scaledRed:((red * amount) + aColor scaledRed) // (1 + amount)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4722
        scaledGreen:((green * amount) + aColor scaledGreen) // (1 + amount)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4723
        scaledBlue:((blue * amount) + aColor scaledBlue) // (1 + amount)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4724
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4725
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4726
     (Color red) mixed:1 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4727
     (Color red) mixed:0.9 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4728
     (Color red) mixed:0.8 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4729
     (Color red) mixed:0.5 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4730
     (Color red) mixed:0.25 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4731
     (Color red) mixed:0 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4732
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4733
     (Color red) mixed:1 with:(Color white)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4734
     (Color red) mixed:0.8 with:(Color white)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4735
     (Color red) mixed:0.8 with:(Color black)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4736
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4737
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4738
    "Modified: 10.2.1997 / 22:08:14 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4739
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4740
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4741
!Color methodsFor:'instance release'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4742
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  4743
executor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4744
    "redefined, since for finalization only device and colorIndex
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4745
     are needed - thus a faster copy is possible here"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4746
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  4747
    ^ DeviceColorHandle basicNew setDevice:device colorId:colorId
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  4748
!
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  4749
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  4750
releaseFromDevice
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  4751
    "I am no longer available on the device"
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  4752
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  4753
    colorId := device := ditherForm := replacementColor := nil.
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  4754
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4755
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4756
3122
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  4757
!Color methodsFor:'misc'!
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  4758
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  4759
magnifiedTo: extent
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  4760
    "do nothing here, for compatibility with Image/Form"
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  4761
! !
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  4762
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4763
!Color methodsFor:'printing & storing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4764
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4765
printOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4766
    "append a string representing of the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4767
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4768
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4769
    self storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4770
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4771
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4772
storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4773
    "append a string representing an expression to reconstruct the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4774
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4775
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4776
    |clsName|
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4777
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4778
    clsName := self class name.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4779
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4780
    red isNil ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4781
        colorId notNil ifTrue:[
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4782
            aStream nextPutAll:'(' , clsName , ' colorId:'.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4783
            colorId storeOn:aStream.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4784
            aStream nextPut:$).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4785
            ^ self
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4786
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4787
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4788
    (red == green and:[red == blue]) ifTrue:[
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4789
        red == 0 ifTrue:[
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4790
            aStream nextPutAll:'(' , clsName , ' black)'.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4791
        ] ifFalse:[
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4792
            red == MaxValue ifTrue:[
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4793
                aStream nextPutAll:'(' , clsName , ' white)'.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4794
            ] ifFalse:[
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4795
                aStream nextPutAll:'(' , clsName , ' grey:'.
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4796
                (self red) storeOn:aStream.
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4797
                aStream nextPut:$).
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4798
            ]
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4799
        ].
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  4800
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4801
    ].
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4802
    aStream nextPutAll:'(' , clsName , ' red:'.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4803
    (self red) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4804
    aStream nextPutAll:' green:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4805
    (self green) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4806
    aStream nextPutAll:' blue:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4807
    (self blue) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4808
    aStream nextPut:$).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4809
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4810
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4811
!Color methodsFor:'private'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4812
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4813
restored
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4814
    "private: color has been restored (either from snapin or binary store);
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4815
     flush device stuff or reallocate a cell."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4816
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4817
    ditherForm := replacementColor := nil.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4818
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4819
    red notNil ifTrue:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4820
        device := nil.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4821
        colorId := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4822
    ] ifFalse:[
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4823
        "a variable color has been restored"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4824
        (colorId notNil and:[writable == true and:[device notNil]]) ifTrue:[
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4825
            colorId := device colorCell.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4826
            device setColor:colorId scaledRed:red scaledGreen:green scaledBlue:blue
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4827
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4828
    ]
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4829
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4830
    "Modified: 17.1.1997 / 00:04:14 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4831
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4832
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4833
setColorId:anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4834
    "private: set the deviceId"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4835
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4836
    colorId := anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4837
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4838
    "Created: 17.1.1997 / 00:05:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4839
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4840
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4841
setDevice:aDevice colorId:aNumber
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4842
    "private:set device and colorId"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4843
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4844
    device := aDevice.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4845
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4846
    writable := false.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4847
!
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4848
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4849
setDevice:aDevice colorId:aNumber writable:wBool
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4850
    "private:set device, colorId and writable flag"
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4851
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4852
    device := aDevice.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4853
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  4854
    writable := wBool.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4855
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4856
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4857
setDitherForm:aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4858
    "private: set the ditherForm"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4859
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4860
    ditherForm := aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4861
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4862
    "Created: 17.1.1997 / 00:04:57 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4863
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4864
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4865
setScaledRed:r scaledGreen:g scaledBlue:b device:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4866
    "private: set the components"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4867
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4868
    red notNil ifTrue:[
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4869
        "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
  4870
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4871
        self error:'Colors cannot change their components'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4872
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4873
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4874
    red := r.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4875
    green := g.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4876
    blue := b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4877
    device := aDevice
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4878
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4879
    "Modified: 16.1.1997 / 22:39:26 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4880
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4881
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4882
!Color methodsFor:'queries'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4883
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4884
averageColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4885
    "return the average color - thats myself.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4886
     This method has been added for compatibility with the image
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4887
     protocol."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4888
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4889
    ^ self 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4890
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4891
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4892
averageColorIn:aRectangle
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4893
    "return the average color - thats myself.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4894
     This method has been added for compatibility with the image
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4895
     protocol."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4896
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4897
    ^ self 
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4898
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4899
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4900
brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4901
    "ST80 compatibility: return the grey intensity in [0..1]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4902
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4903
    ^ ((3 * red) + (6 * green) + (blue)) / 10.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4904
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4905
    "Modified: 7.6.1996 / 19:42:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4906
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4907
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4908
deltaFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4909
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4910
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4911
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4912
    ^ aColor deltaFromRed:self red green:self green blue:self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4913
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  4914
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  4915
     Color red deltaFrom:(Color blue)  
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  4916
     Color red deltaFrom:(Color yellow)  
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  4917
     Color red deltaFrom:(Color red:50)  
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  4918
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  4919
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4920
    "Created: 14.6.1996 / 20:07:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4921
    "Modified: 14.6.1996 / 20:49:32 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4922
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4923
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4924
deltaFromRed:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4925
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4926
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4927
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4928
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4929
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4930
    "
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  4931
    ^ ((self red - r) abs
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4932
      + (self green - g) abs
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  4933
      + (self blue - b) abs) rounded.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4934
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4935
    "Created: 14.6.1996 / 20:03:58 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4936
    "Modified: 14.6.1996 / 20:20:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4937
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4938
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4939
deltaFromScaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4940
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4941
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4942
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4943
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4944
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4945
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4946
    ^ (red - r) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4947
      + (green - g) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4948
      + (blue - b) abs.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4949
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4950
    "Created: 11.6.1996 / 18:01:12 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4951
    "Modified: 14.6.1996 / 20:36:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4952
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4953
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4954
errorFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4955
    "return some value which can be used to compare colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4956
     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
  4957
     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
  4958
     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
  4959
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4960
    ^ (red - aColor scaledRed) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4961
       + (green - aColor scaledGreen) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4962
       + (blue - aColor scaledBlue) squared.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4963
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4964
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4965
grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4966
    "return the grey intensity in percent [0..100] (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4967
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4968
    ^ ((3 * red) + (6 * green) + (1 * blue)) * 10.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4969
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4970
    "Created: 2.5.1996 / 11:38:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4971
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4972
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4973
greyIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4974
    "return the grey intensity in percent [0..100] (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4975
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4976
    ^ self grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4977
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4978
    "Modified: 28.5.1996 / 20:45:41 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4979
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4980
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4981
isColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4982
    "return true if the receiver is a Color."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4983
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4984
    ^ true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4985
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4986
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  4987
isColorObject
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  4988
    ^ true
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  4989
!
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  4990
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4991
isDithered
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4992
    "return true, if this is a dithered Color.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4993
     Only makes sense if the receiver is a device color."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4994
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4995
    ^ ditherForm notNil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4996
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4997
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4998
isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  4999
    "same as isGrayColor - for ST80 compatibility."
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5000
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5001
    ^ self isGrayColor
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5002
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5003
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5004
     (Color grey:50) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5005
     (Color red) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5006
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5007
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5008
    "Created: 10.2.1997 / 22:10:25 / cg"
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5009
!
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5010
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5011
isGrayColor
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5012
    "return true, if this color is a gray one (US version ;-) -
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5013
     i.e. red = green = blue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5014
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5015
    red ~~ green ifTrue:[^ false].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5016
    ^ red == blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5017
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5018
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5019
     (Color grey:50) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5020
     (Color red) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5021
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5022
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5023
    "Created: 2.5.1996 / 11:38:48 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5024
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5025
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5026
isGreyColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5027
    "return true, if this color is a grey one (English version ;-) -
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5028
     i.e. red = green = blue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5029
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5030
    ^ self isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5031
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5032
    "(Color grey:50) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5033
    "(Color red) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5034
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5035
    "Modified: 28.5.1996 / 20:44:36 / cg"
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5036
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5037
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5038
isOpaque
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5039
    "return true, if I represent an opaque color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5040
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5041
    ^ true
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5042
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5043
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5044
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5045
isTranslucent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5046
    "return true, if I represent a translucent color;
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5047
     that is: not completely opaque"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5048
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5049
    ^ false
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5050
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5051
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5052
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5053
isTranslucentColor
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5054
    "return true, if I represent a translucent color, but not transparent"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5055
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5056
    ^ false
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5057
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5058
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5059
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5060
isTransparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5061
    "return true, if I represent a completely transparent color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5062
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5063
    ^ false
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5064
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5065
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5066
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5067
!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
  5068
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5069
documentation
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5070
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5071
    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
  5072
    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
  5073
    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
  5074
    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
  5075
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5076
    [see also:]
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5077
        Color
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5078
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5079
    [author:]
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5080
        Claus Gittinger
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5081
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5082
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5083
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5084
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5085
!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
  5086
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5087
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
  5088
    "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
  5089
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5090
    device := aDevice.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5091
    colorId := anId.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5092
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5093
    "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
  5094
    "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
  5095
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5096
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5097
!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
  5098
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5099
disposed
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5100
    "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
  5101
     - release system resources"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5102
2096
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5103
    |id|
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5104
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5105
    (id := colorId) notNil ifTrue:[
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5106
	colorId := nil.
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5107
        device freeColor:id.
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5108
    ].
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5109
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5110
    "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
  5111
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5112
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  5113
!Color class methodsFor:'documentation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5114
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5115
version
3264
ab71c2bd250f fixed #brightness:
Claus Gittinger <cg@exept.de>
parents: 3240
diff changeset
  5116
    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.158 2000-08-22 10:11:24 cg Exp $'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5117
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5118
Color initialize!