Color.st
author Claus Gittinger <cg@exept.de>
Tue, 23 Apr 2019 16:30:55 +0200
changeset 8674 e29a561c0fbe
parent 8660 ee175c43cba6
child 8692 665f0ed62ebe
permissions -rw-r--r--
#FEATURE by cg class: SimpleView added: #isDialogBox
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
     1
"{ Encoding: utf8 }"
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
     2
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     3
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     4
 COPYRIGHT (c) 1992 by Claus Gittinger
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
     5
	      All Rights Reserved
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     6
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     7
 This software is furnished under a license and may be used
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     8
 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
     9
 inclusion of the above copyright notice.   This software may not
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    10
 be provided or otherwise made available to, or used by, any
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    11
 other person.  No title to or ownership of the software is
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    12
 hereby transferred.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    13
"
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
    14
"{ Package: 'stx:libview' }"
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
    15
6785
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
    16
"{ NameSpace: Smalltalk }"
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
    17
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    18
Object subclass:#Color
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    19
	instanceVariableNames:'red green blue device colorId ditherForm replacementColor
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    20
		writable'
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
    21
	classVariableNames:'Black Blue Cells ColorAllocationFailSignal ColorErrorSignal
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
    22
		DarkGrey DitherBits Green Grey InvalidColorNameSignal LightGrey
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
    23
		MaxValue Orange Pseudo0 Pseudo1 PseudoAll Red RetryAllocation
8660
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
    24
		StandardColorValues Transparent White Yellow DarkGreen DarkRed'
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    25
	poolDictionaries:''
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    26
	category:'Graphics-Support'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    27
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    28
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    29
Object subclass:#DeviceColorHandle
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    30
	instanceVariableNames:'device colorId'
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    31
	classVariableNames:''
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    32
	poolDictionaries:''
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    33
	privateIn:Color
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    34
!
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    35
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    36
!Color class methodsFor:'documentation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    37
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    38
copyright
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
 COPYRIGHT (c) 1992 by Claus Gittinger
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
    41
	      All Rights Reserved
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    42
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    43
 This software is furnished under a license and may be used
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    44
 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
    45
 inclusion of the above copyright notice.   This software may not
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    46
 be provided or otherwise made available to, or used by, any
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    47
 other person.  No title to or ownership of the software is
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    48
 hereby transferred.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    49
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    50
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    51
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    52
documentation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    53
"
7782
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    54
    Color represents colors in a device independent manner.
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    55
    The main info I keep in mySelf are the red, green and blue components scaled into 0 .. MaxValue.
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    56
    
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    57
    A device specific color can be acquired by sending a color the 'onDevice:aDevice' message,
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    58
    which will return a color with the same r/g/b values as the receiver but with a specific
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    59
    colorID for that device (which may or may not imply a colormap slot allocation on that device).
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    60
    A device-specific color index (i.e. palette-ID) is then found in the newly allocated color's colorID slot.
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    61
    
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    62
    Most of the device dependent coding was to support limited graphics devices (non truecolor, eg. palette)
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
    63
    in a transparent way. This was required at that time (late 80's, early 90's),
7782
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    64
    but is now almost obsolete, as these days, virtually any graphic systems supports true colors.
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
    65
    It is arguably, if that stuff should remain here, or if we should simply give up support
7782
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    66
    for old VGA-like displays 
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    67
    (actually, there are still such limited displays around, for example in the embedded area.
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    68
     So we will leave that support in for another few years ;-) ).
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    69
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    70
    On such limited devices, colors can be pure or dithered, depending on the capabilities of the device.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    71
    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
    72
    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
    73
    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
    74
    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
    75
    colormap (as usual for bitmaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    76
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    77
    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
    78
    new colors are created. When running out of colors, dithered colors will be used,
7620
3b59f3c6764f #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    79
    using existing nearest colors and a dither pattern to approximate the color.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    80
    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
    81
    to ugly looking dither colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    82
    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
    83
    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
    84
    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
    85
    (beside 5x5x5, there are various other size combinations available).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    86
    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
    87
    preallocated table may steal colors from the image ...
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
    [Instance variables:]
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
      red             <Integer>       the red component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    92
      green           <Integer>       the green component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    93
      blue            <Integer>       the blue component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    94
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    95
      device          <Device>        the device I am on, or nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    96
      colorId         <Object>        some device dependent identifier (or nil if dithered)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    97
      ditherForm      <Form>          the Form to dither this color (if non-nil)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    98
      writable        <Boolean>       true if this is for a writable color cell
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    99
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   100
    [Class variables:]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   101
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   102
      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
   103
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   104
      Lobby           <Registry>      all colors in use - keeps track of already allocated
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   105
                                      colors for reuse and finalization.
7650
5781e05a6a1d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7642
diff changeset
   106
                                      (don't use it: this will be moved to the device)
1229
249c0d78fd34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1224
diff changeset
   107
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   108
      Cells           <Registry>      keeps track of allocated writable color cells
7650
5781e05a6a1d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7642
diff changeset
   109
                                      (don't use it: this will be moved to the device)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   110
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   111
      FixColors       <Array>         preallocated colors for dithering on Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   112
      NumRedFix       <Integer>       number of distinct red values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   113
      NumGreenFix     <Integer>       number of distinct green values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   114
      NumBlueFix      <Integer>       number of distinct blue values in FixColors
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   115
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   116
      Black           <Color>         for fast return of black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   117
      White           <Color>         for fast return of white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   118
      Grey            <Color>         for fast return of grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   119
      LightGrey       <Color>         for fast return of lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   120
      DarkGrey        <Color>         for fast return of darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   121
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   122
      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
   123
      Pseudo1         <Color>         a color with 1 as handle (for forms)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   124
      PseudoAll       <Color>         a color with allPlanes as handle (for bitblit)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   125
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   126
      Red             <Color>         red, needed for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   127
      Green           <Color>         green, for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   128
      Blue            <Color>         blue, for dithering
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
      DitherColors    <Collection>    some preallocated colors for dithering
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   131
                                      (kept, so they are available when needed)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   132
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   133
      RetryAllocation <Boolean>       this flag controls how a request for a
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   134
                                      color should be handled which failed previously.
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   135
                                      I.e. a color is asked for, which was dithered
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   136
                                      the last time. Since it could happen, that in
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   137
                                      the meantime more colors became free, the request
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   138
                                      might succeed this time - however, your screen may
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   139
                                      look a bit funny, due to having both dithered and
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   140
                                      undithered versions around.
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   141
                                      The default is true, which means: do retry
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   142
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   143
    compatibility issues:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   144
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   145
        ST-80 seems to represent colors internally with scaled smallInteger
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   146
        components (this can be guessed from uses of
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   147
        scaledRed:scaledGreen:scaledBlue:). The main instance creation method is
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   148
        via 'ColorValue red:green:blue:', passing components in 0..1.
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   149
        In ST/X, rgb components are typically represented as percent.
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   150
        For more compatibility (when subclassing color), these internals may
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   151
        change in the near future. For migration, a compatibility subclass
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   152
        called ColorValue is provided.
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   153
        After the change, Color will be renamed to ColorValue and Color
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   154
        be made a subclass of ColorValue (offering the 0..100 interface for
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   155
        backward compatibility).
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   156
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   157
    [see also:]
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   158
        DeviceWorkstation
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   159
        GraphicsContext DeviceDrawable Form Image Colormap
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   160
        Font Cursor
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
    [author:]
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   163
        Claus Gittinger
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
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   166
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   167
!Color class methodsFor:'initialization'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   168
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   169
initialize
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   170
    "setup tracker of known colors and initialize classvars with
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   171
     heavily used colors"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   172
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   173
    ColorErrorSignal isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   174
	ColorErrorSignal := Error newSignalMayProceed:true.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   175
	ColorErrorSignal nameClass:self message:#colorErrorSignal.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   176
	ColorErrorSignal notifierString:'color error'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   177
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   178
	ColorAllocationFailSignal := ColorErrorSignal newSignalMayProceed:true.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   179
	ColorAllocationFailSignal nameClass:self message:#colorAllocationFailSignal.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   180
	ColorAllocationFailSignal notifierString:'color allocation failed'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   181
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   182
	InvalidColorNameSignal := ColorErrorSignal newSignalMayProceed:true.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   183
	InvalidColorNameSignal nameClass:self message:#invalidColorNameSignal.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   184
	InvalidColorNameSignal notifierString:'invalid color name'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   185
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   186
	MaxValue := 16rFFFF.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   187
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   188
	"want to be informed when returning from snapshot"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   189
	ObjectMemory addDependent:self.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   190
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   191
	RetryAllocation := true.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   192
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   193
	DitherBits := self ditherBits.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   194
	self initializeStandardColorNames.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   195
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   196
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   197
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   198
     Color initialize
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   199
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   200
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   201
    "Modified: / 30.9.1998 / 21:56:50 / cg"
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   202
!
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   203
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   204
initializeStandardColorNames
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   205
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   206
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   207
    "setup standard colors"
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   208
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   209
    StandardColorValues := Dictionary new.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   210
    #(
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   211
		'red'     (16rFFFF 16r0000 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   212
		'green'   (16r0000 16rFFFF 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   213
		'blue'    (16r0000 16r0000 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   214
		'yellow'  (16rFFFF 16rFFFF 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   215
		'magenta' (16rFFFF 16r0000 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   216
		'cyan'    (16r0000 16rFFFF 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   217
		'white'   (16rFFFF 16rFFFF 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   218
		'black'   (16r0000 16r0000 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   219
		'olive'   (16r7FFF 16r7FFF 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   220
		'teal'    (16r0000 16r7FFF 16r7FFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   221
		'silver'  (16r6666 16r6666 16r6666)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   222
		'lime'    (16r3333 16rFFFF 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   223
		'fuchsia' (16r9999 16r07ae 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   224
		'aqua'    (16r199a 16rFFFF 16rFFFF)
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   225
    ) pairWiseDo:[:name :value |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   226
	StandardColorValues at:name put:value
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   227
    ].
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   228
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   229
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   230
     Color initializeStandardColorNames
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   231
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   232
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   233
    "Modified: 6.3.1997 / 02:28:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   234
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   235
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   236
update:something with:aParameter from:changedObject
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   237
    "handle image restarts and flush any device resource handles"
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
    (something == #returnFromSnapshot) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   240
	Display notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   241
	    Display visualType == #TrueColor ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   242
		Display releaseFixColors
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   243
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   244
		Display fixColors notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   245
		    ColorAllocationFailSignal handle:[:ex |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   246
			ex return
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   247
		    ] do:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   248
			|nR nG nB|
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   249
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   250
			nR := Display numFixRed.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   251
			nG := Display numFixGreen.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   252
			nB := Display numFixBlue.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   253
			Display releaseFixColors.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   254
			self getColorsRed:nR
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   255
				    green:nG
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   256
				     blue:nB
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   257
				       on:Display
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   258
		    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   259
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   260
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   261
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   262
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   263
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   264
    "Created: 15.6.1996 / 15:14:03 / cg"
1370
37dfdffdd4b6 getPrimaryColors now invoked from device
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   265
    "Modified: 24.2.1997 / 22:08:05 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   266
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   267
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   268
!Color class methodsFor:'instance creation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   269
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   270
allColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   271
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   272
     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
   273
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   274
    PseudoAll isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   275
	PseudoAll := self basicNew setColorId:-1
1023
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
    ^ PseudoAll
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   278
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   279
    "Modified: 17.1.1997 / 00:05:36 / cg"
1023
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
2455
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   282
bgrValue:bgr
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   283
    "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
   284
     The value is composed of b<<16 + g<<8 + r.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   285
     (this byte-order is sometimes encountered with windows systems (progs)"
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   286
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   287
    |r g b|
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   288
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   289
    b := (bgr bitShift:-16) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   290
    g := (bgr bitShift:-8) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   291
    r := (bgr) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   292
    ^ self redByte:r greenByte:g blueByte:b
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   293
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   294
!
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   295
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   296
blue: blue
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   297
    "return a color from blue value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   298
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   299
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   300
    ^ here
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   301
	scaledRed:0 scaledGreen:0 scaledBlue:(blue * MaxValue // 100)
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   302
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   303
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   304
     (Color blue:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   305
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   306
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   307
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   308
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   309
brightness:brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   310
    "create a gray color with given brightness (0..1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   311
     ST-80 compatibility."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   312
3264
ab71c2bd250f fixed #brightness:
Claus Gittinger <cg@exept.de>
parents: 3240
diff changeset
   313
    ^ self scaledGray:(brightness * MaxValue) rounded
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   314
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   315
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   316
colorId:id
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   317
    "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
   318
     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
   319
     or for bitblits if you want to manipulate a specific colorplane."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   320
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   321
    id == 0 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   322
	^ self noColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   323
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   324
    id == 1 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   325
	Pseudo1 isNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   326
	    Pseudo1 := self basicNew setColorId:1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   327
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   328
	^ Pseudo1
1023
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
    id == -1 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   331
	^ self allColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   332
    ].
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   333
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   334
    ^ self basicNew setColorId:id
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   335
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   336
    "Modified: 24.2.1997 / 18:16:30 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   337
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   338
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   339
cyan:c magenta:m yellow:y
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   340
    "return a color from cyan, magenta and yellow values.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   341
     all values are given in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   342
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   343
    ^ self
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   344
	redPercent:(100 - c)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   345
	greenPercent:(100 - m)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   346
	bluePercent:(100 - y)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   347
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   348
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   349
     Color cyan:100 magenta:0 yellow:0      - cyan
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   350
     Color cyan:100 magenta:100 yellow:0    - blue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   351
     Color cyan:100 magenta:0 yellow:100    - green
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   352
     Color cyan:100 magenta:100 yellow:100  - black
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   353
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   354
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   355
    "Modified: 11.6.1996 / 18:29:15 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   356
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   357
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   358
cyan:c magenta:m yellow:y black:k
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   359
    "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
   360
     all values are given in percent (0..100).
2889
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   361
     The value returned here is questionable.
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   362
     TODO: we loose information about one component here,
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   363
     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
   364
     information internally for later use (when saving)."
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   365
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   366
    |scale r g b|
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   367
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   368
    "/ mhmh - how should we scale black into the components ?
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   369
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   370
    r := (100 - c).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   371
    g := (100 - m).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   372
    b := (100 - y).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   373
    k ~~ 0 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   374
	"/ more black - darker
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   375
	scale := (100-k) max:0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   376
	scale := scale / 100.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   377
	r := r * scale.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   378
	g := g * scale.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   379
	b := b * scale.
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   380
    ].
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   381
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   382
    ^ self redPercent:r greenPercent:g bluePercent:b
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   383
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   384
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   385
     Color cyan:100 magenta:0 yellow:0 black:0      - cyan
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   386
     Color cyan:100 magenta:0 yellow:0 black:50     - cyan darkened
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   387
     Color cyan:100 magenta:50 yellow:50 black:0    - cyan darkened
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   388
     Color cyan:0 magenta:0 yellow:0 black:100      - black
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   389
    "
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   390
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   391
    "Modified: 11.6.1996 / 18:29:15 / cg"
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   392
!
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   393
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   394
dither:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   395
    "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
   396
     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
   397
     colors.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   398
     Useful, if you explicitely want a dithered color
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   399
     (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
   400
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   401
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   402
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   403
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   404
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   405
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   406
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   407
    (c1 isNil or:[c2 isNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   408
	'Color [warning]: monoDither failed - no real colors given' errorPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   409
	^ nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   410
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   411
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   412
    self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   413
	monoDitherFor:fraction
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   414
	between:c1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   415
	and:c2
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   416
	on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   417
	into:[:c :f | newColor := c. form := f].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   418
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   419
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   420
    form isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   421
	"/ cannot happen
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   422
	'Color [warning]: monoDither failed' errorPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   423
	^ nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   424
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   425
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   426
    newColor := self basicNew
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   427
			setScaledRed:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   428
			scaledGreen:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   429
			scaledBlue:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   430
			device:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   431
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   432
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   433
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   434
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   435
    "
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   436
     (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
   437
     (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
   438
     (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
   439
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   440
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   441
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   442
    "Modified: 3.5.1997 / 11:10:51 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   443
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   444
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   445
dithered:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   446
    "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
   447
     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
   448
     colors.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   449
     Useful, if you explicitely want a dithered color
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   450
     (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
   451
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   452
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   453
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   454
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   455
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   456
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   457
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   458
    (c1 isNil or:[c2 isNil]) ifTrue:[
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   459
        'Color [warning]: monoDither failed - no real colors given' errorPrintCR.
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   460
        ^ nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   461
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   462
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   463
    self
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   464
        monoDitherFor:fraction
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   465
        between:c1
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   466
        and:c2
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   467
        on:aDevice
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   468
        into:[:c :f | newColor := c. form := f].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   469
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   470
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   471
    form isNil ifTrue:[
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   472
        "/ cannot happen
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   473
        'Color [warning]: monoDither failed' errorPrintCR.
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   474
        ^ nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   475
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   476
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   477
    newColor := self basicNew
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   478
                        setScaledRed:nil
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   479
                        scaledGreen:nil
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   480
                        scaledBlue:nil
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   481
                        device:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   482
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   483
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   484
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   485
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   486
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   487
     |c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   488
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   489
     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
   490
     c inspect.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   491
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   492
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   493
     |v c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   494
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   495
     v := StandardSystemView new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   496
     v extent:100@100.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   497
     v openAndWait.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   498
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   499
     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
   500
     v paint:c.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   501
     v fillRectangle:(10@10 corner:90@90).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   502
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   503
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   504
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   505
    "Modified: 3.5.1997 / 11:13:12 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   506
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   507
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   508
fromUser
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   509
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   510
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   511
    "let user point on a screen pixel.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   512
     Return an instance for that pixels color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   513
4896
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   514
    ^ self fromUserWithFeedBack:nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   515
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   516
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   517
     Color fromUser
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   518
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   519
1976
fcf9afd72f0f Do not use obsolete method Color>>at:
Stefan Vogel <sv@exept.de>
parents: 1971
diff changeset
   520
    "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
   521
    "Modified: / 9.1.1998 / 20:48:58 / stefan"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   522
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   523
4896
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   524
fromUserWithFeedBack:feedbackBlockOrNil
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   525
    "{ Pragma: +optSpace }"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   526
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   527
    "let user point on a screen pixel.
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   528
     Return an instance for that pixels color"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   529
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   530
    |p screen|
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   531
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   532
    screen := Screen current.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   533
    p := screen
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   534
	    pointFromUserShowing:(Cursor crossHair)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   535
	    positionFeedback:[:p |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   536
				feedbackBlockOrNil notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   537
				    feedbackBlockOrNil value:(screen colorAt:p)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   538
				]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   539
			    ].
4896
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   540
    ^ screen colorAt:p
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   541
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   542
    "
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   543
     Color fromUserWithFeedBack:nil
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   544
    "
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   545
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   546
    "Modified: / 31.8.1995 / 01:34:22 / claus"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   547
    "Modified: / 9.1.1998 / 20:48:58 / stefan"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   548
!
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   549
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   550
green:green
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   551
    "return a color from green value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   552
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   553
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   554
    ^ here
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   555
	scaledRed:0 scaledGreen:(green * MaxValue // 100) scaledBlue:0
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   556
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   557
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   558
     (Color green:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   559
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   560
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   561
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   562
7910
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   563
htmlName:colorName
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   564
    "see https://en.wikipedia.org/wiki/Web-safe#HTML_color_names
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   565
     The web defines 16 standard color names, which are returned here. 
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   566
     Attention:
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   567
        these are not the same colors as those built into X-servers;
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   568
        eg. (Color name:'green') returns a bright green,
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   569
        whereas (Color htmlName:'green') returns a dark green, and 'lime' would be the X-green.
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   570
        Sigh"
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   571
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   572
    ^ self
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   573
        htmlName:colorName
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   574
        ifIllegal:[
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   575
            InvalidColorNameSignal
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   576
                raiseRequestWith:colorName errorString:' : ' , colorName
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   577
        ]
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   578
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   579
    "
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   580
     Color htmlName:'lime'
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   581
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   582
     Color htmlName:'green'
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   583
     Color name:'green'
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   584
    "
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   585
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   586
    "Created: / 17-02-2017 / 12:41:17 / cg"
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   587
!
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   588
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   589
htmlName:colorName ifIllegal:errorBlock
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   590
    "see https://en.wikipedia.org/wiki/Web-safe#HTML_color_names
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   591
     The web defines 16 standard color names, which are returned here. 
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   592
     If aString is not a valid color name,
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   593
     return the result from evaluating errorBlock.
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   594
     Attention:
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   595
        these are not the same colors as those built into X-servers;
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   596
        eg. (Color name:'green') returns a bright green,
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   597
        whereas (Color htmlName:'green') returns a dark green, and 'lime' would be the X-green.
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   598
        Sigh"
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   599
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   600
    |nameLowercase|
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   601
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   602
    nameLowercase := colorName asLowercase.
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   603
    ^ #(
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   604
        ('silver'  16rC0C0C0)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   605
        ('maroon'  16r800000)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   606
        ('olive'   16r808000)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   607
        ('lime'    16r00FF00)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   608
        ('green'   16r008000)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   609
        ('aqua'    16r00FFFF)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   610
        ('teal'    16r008080)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   611
        ('navy'    16r000080)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   612
        ('fuchsia' 16rFF00FF)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   613
        ('purple'  16r800080)
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   614
    ) 
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   615
        detect:[:e | e first = nameLowercase]
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   616
        thenCompute:[:e | self rgbValue:(e second)]
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   617
        ifNone:[ self name:colorName ifIllegal:errorBlock ]
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   618
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   619
    "
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   620
     Color htmlName:'lime'
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   621
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   622
     Color htmlName:'green'
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   623
     Color name:'green'
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   624
    "
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   625
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   626
    "Created: / 17-02-2017 / 12:42:01 / cg"
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   627
!
303d43b7c688 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7909
diff changeset
   628
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   629
hue:h light:l saturation:s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   630
    "return a color from hue, light and saturation values.
7569
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
   631
     Hue is in degrees (0..360); light and saturation are
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   632
     in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   633
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   634
    self withRGBFromHue:h light:l saturation:s do:[:r :g :b |
7569
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
   635
        ^ self
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
   636
            redPercent:(r clampBetween:0 and:100)
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
   637
            greenPercent:(g clampBetween:0 and:100)
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
   638
            bluePercent:(b clampBetween:0 and:100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   639
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   640
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   641
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   642
     Color hue:0 light:50 saturation:100     - red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   643
     Color hue:60 light:50 saturation:100    - yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   644
     Color hue:120 light:50 saturation:100   - green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   645
     Color hue:120 light:75 saturation:100   - bright green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   646
     Color hue:120 light:25 saturation:100   - dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   647
     Color hue:120 light:50 saturation:50    - greyish dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   648
     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
   649
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   650
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   651
    "Modified: 23.4.1996 / 13:22:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   652
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   653
8112
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   654
luma:y chromaBlue:cb chromaRed:cr
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   655
    "return a color from Y-Cb-Cr components.
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   656
     See https://en.wikipedia.org/wiki/YCbCr
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   657
     and ITU-R BT.601"
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   658
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   659
    |r g b|
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   660
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   661
    r := y + (1.400 * cr).
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   662
    g := y - (0.343 * (cb-128)) - (0.711 * (cr-128)).
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   663
    b := y + (1.765 * (cb-128)).
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   664
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   665
    ^ self redByte:r greenByte:g blueByte:b
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   666
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   667
    "
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   668
     Color luma:0 chromaBlue:128 chromaRed:128 
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   669
     Color luma:1 chromaBlue:128 chromaRed:128 
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   670
     Color luma:0.5 chromaBlue:128 chromaRed:128
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   671
    "
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   672
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   673
    "Created: / 26-08-2017 / 21:33:52 / cg"
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   674
!
0825f3c6a0cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8109
diff changeset
   675
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   676
name:colorName
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   677
    "Return a named color (either exact or dithered).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   678
     Report an error, if aString is not a valid color name.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   679
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   680
     We hereby only guarantee that the 8 basic colors are supported
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   681
     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
   682
     names - other devices use a builtIn name table containing only the
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   683
     common names)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   684
     - use with special names (such as 'mediumGoldenRod' is not recommended).
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   685
     Better use: #name:ifIllegal: and provide a fallBack."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   686
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   687
    ^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   688
	name:colorName
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   689
	ifIllegal:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   690
	    InvalidColorNameSignal
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   691
		raiseRequestWith:colorName errorString:' : ' , colorName
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   692
	]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   693
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   694
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   695
     Color name:'brown'
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   696
     Color name:'snow'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   697
     Color name:'foo'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   698
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   699
1534
73dd2c4b86c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1502
diff changeset
   700
    "Modified: 4.4.1997 / 15:32:33 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   701
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   702
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   703
name:colorName ifIllegal:errorBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   704
    "Return a named color (either exact or dithered).
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   705
     If aString is not a valid color name,
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   706
     return the result from evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   707
3399
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
   708
    |triple r g b currScreen|
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   709
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   710
    triple := StandardColorValues at:colorName asString ifAbsent:nil.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   711
    triple notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   712
	r := triple at:1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   713
	g := triple at:2.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   714
	b := triple at:3.
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   715
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   716
	"/ ask display (if there is one) ...
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   717
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   718
	(Screen notNil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   719
	and:[ (currScreen := Screen current) notNil])
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   720
	ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   721
	    currScreen
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   722
		getScaledRGBFromName:colorName
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   723
		into:[:rr :gg :bb |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   724
		    r := rr.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   725
		    g := gg.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   726
		    b := bb
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   727
		].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   728
	]
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   729
    ].
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   730
    r notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   731
	^ here scaledRed:r scaledGreen:g scaledBlue:b
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   732
    ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   733
    ^ errorBlock value
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   734
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   735
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   736
     Color name:'brown' ifIllegal:[Color black]
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   737
     Color name:'red' ifIllegal:[Color black]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   738
     Color name:'fuchsia' ifIllegal:[Color black]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   739
     Color name:'foo' ifIllegal:[Color black]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   740
     Color name:'foo' ifIllegal:[nil]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   741
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   742
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   743
    "Modified: 6.3.1997 / 02:32:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   744
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   745
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   746
noColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   747
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   748
     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
   749
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   750
     Pseudo0 isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   751
	 Pseudo0 := self basicNew setColorId:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   752
     ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   753
     ^ Pseudo0
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   754
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   755
    "Modified: 17.1.1997 / 00:06:49 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   756
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   757
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   758
red:red
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   759
    "return a color from red value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   760
     the argument r is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   761
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   762
    ^ here
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   763
	scaledRed:(red * MaxValue // 100) scaledGreen:0 scaledBlue:0
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   764
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   765
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   766
     (Color red:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   767
    "
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   768
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   769
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   770
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   771
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   772
     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
   773
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   774
    ^ self new
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   775
        setScaledRed:(r * MaxValue // 100)
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   776
        scaledGreen:(g * MaxValue // 100)
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   777
        scaledBlue:(b * MaxValue // 100)
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   778
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   779
    "
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   780
     Color red:50 green:50 blue:50
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   781
     ColorValue red:0.5 green:0.5 blue:0.5
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   782
     TranslucentColor red:50 green:50 blue:50
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   783
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   784
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   785
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   786
redByte:r greenByte:g blueByte:b
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   787
    "return a color from red, green and blue values;
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   788
     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
   789
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   790
    ^ here scaledRed:(r * MaxValue // 255)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   791
	   scaledGreen:(g * MaxValue // 255)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   792
	   scaledBlue:(b * MaxValue // 255)
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   793
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   794
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   795
     (Color redByte:255 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   796
     (Color redByte:255 greenByte:255 blueByte:255) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   797
     (Color redByte:0 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   798
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   799
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   800
    "Modified: 16.1.1997 / 23:32:43 / cg"
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   801
!
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
   802
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   803
redByte:r greenByte:g blueByte:b alphaByte:a
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   804
    "return a color from red, green, blue and alpha values;
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   805
     the arguments, r, g, b and a are interpreted as byte values (0..255)"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   806
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   807
    ^ (here scaledRed:(r * MaxValue // 255)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   808
	   scaledGreen:(g * MaxValue // 255)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   809
	   scaledBlue:(b * MaxValue // 255))
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   810
	   alpha:(a / 255)
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   811
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   812
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   813
     (Color redByte:255 greenByte:0 blueByte:0 alphaByte:127) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   814
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   815
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   816
    "Created: / 06-06-2007 / 11:15:47 / cg"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   817
!
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
   818
5144
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
   819
redFraction:r greenFraction:g blueFraction:b
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
   820
    "return a color from red, green and blue values;
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
   821
     the arguments, r, g and b are interpreted as fraction (0..1)"
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
   822
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
   823
    ^ here scaledRed:(r * MaxValue) rounded
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   824
	   scaledGreen:(g * MaxValue) rounded
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   825
	   scaledBlue:(b * MaxValue) rounded
5144
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
   826
!
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
   827
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   828
redPercent:r greenPercent:g bluePercent:b
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   829
    "return a color from red, green and blue values;
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   830
     the arguments, r, g and b are interpreted as percent (0..100)"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   831
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   832
    ^ here scaledRed:(r * MaxValue // 100)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   833
	   scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   834
	   scaledBlue:(b * MaxValue // 100)
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   835
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
   836
5127
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
   837
redPercent:r greenPercent:g bluePercent:b alphaPercent:a
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
   838
    "return a color from red, green and blue values;
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
   839
     the arguments, r, g and b are interpreted as percent (0..100)"
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
   840
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
   841
    ^ (here scaledRed:(r * MaxValue // 100)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   842
	   scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   843
	   scaledBlue:(b * MaxValue // 100))
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   844
	   alpha:(a * 255 // 100)
5127
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
   845
!
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
   846
3956
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   847
redShort:r greenShort:g blueShort:b
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   848
    "return a color from red, green and blue short values;
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   849
     the arguments, r, g and b are interpreted as unsigned short values (0..16rFFFF)"
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   850
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   851
    ^ here scaledRed:(r * MaxValue // 16rFFFF)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   852
	   scaledGreen:(g * MaxValue // 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   853
	   scaledBlue:(b * MaxValue // 16rFFFF)
3956
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   854
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   855
    "
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   856
     (Color redShort:16rFFFF greenShort:0 blueShort:0) inspect
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   857
    "
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   858
!
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
   859
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   860
rgbValue:rgb
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   861
    "return a color from a 24bit RGB value;
8109
017a2867ba53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8063
diff changeset
   862
     The value is composed of r<<16 + g<<8 + b,
017a2867ba53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8063
diff changeset
   863
     i.e. rrggbb"
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   864
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   865
    |r g b|
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   866
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   867
    "/ constant colors
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   868
    rgb == 0 ifTrue:[
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   869
        ^ self black
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   870
    ].
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   871
    rgb == 16rFFFFFF ifTrue:[
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   872
        ^ self white
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   873
    ].
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   874
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   875
    r := (rgb bitShift:-16) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   876
    g := (rgb bitShift:-8) bitAnd:16rFF.
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   877
    b := rgb bitAnd:16rFF.
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   878
    ^ self redByte:r greenByte:g blueByte:b
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   879
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   880
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   881
     (Color rgbValue:16rFF0000) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   882
     (Color rgbValue:16r00FF00) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   883
     (Color rgbValue:16r0000FF) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   884
     (Color rgbValue:16rFF00FF) inspect
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   885
     (Color rgbValue:16rFFFFFF) inspect
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   886
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   887
8109
017a2867ba53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8063
diff changeset
   888
    "Modified: / 13-08-1997 / 20:24:37 / cg"
017a2867ba53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8063
diff changeset
   889
    "Modified (comment): / 26-08-2017 / 13:02:23 / cg"
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
   890
    "Modified (format): / 11-01-2018 / 12:21:56 / stefan"
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   891
!
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
   892
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   893
scaledGray:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   894
    "return a gray color with a scaled gray value (0..MaxValue)"
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
    ^ self scaledRed:aGrayValue scaledGreen:aGrayValue scaledBlue:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   897
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   898
    "Modified: 11.6.1996 / 16:31:42 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   899
!
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
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   902
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   903
     the arguments, r, g and b are interpreted as (0..MaxValue)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   904
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   905
    |newColor|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   906
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   907
    newColor := self basicNew setScaledRed:r scaledGreen:g scaledBlue:b.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   908
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   909
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   910
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   911
     (Color red:100 green:0 blue:0) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   912
     (Color red:100 green:50 blue:50) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   913
     (Color red:50 green:0 blue:0) inspect
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
   914
     (TranslucentColor red:50 green:0 blue:0) inspect
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   915
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   916
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   917
    "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
   918
    "Modified: 24.2.1997 / 18:18:47 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   919
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   920
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   921
variableColorOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   922
    "return a variable color (i.e. allocate a writable colorcell) on
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   923
     aDevice. The returned color is not shared and its rgb components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   924
     are initially undefined. The components can be set to any value
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   925
     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
   926
     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
   927
     being a pseudocolor device using colormaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   928
     Returns nil, if no more colorCells are available, or the display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   929
     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
   930
     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
   931
     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
   932
     things in another color)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   933
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   934
    |c lutIndex|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   935
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   936
    lutIndex := aDevice colorCell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   937
    lutIndex isNil ifTrue:[^ nil].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   938
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   939
    c := self new.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   940
    c setDevice:aDevice colorId:lutIndex writable:true.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   941
    Cells isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   942
	Cells := Registry new.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   943
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   944
    Cells register:c.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   945
    ^ c
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   946
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   947
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   948
     |l cell|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   949
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   950
     l := Label new.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   951
     l label:('hello' asText allBold).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   952
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   953
     cell := Color variableColorOn:(Screen current).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   954
     l foregroundColor:cell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   955
     [
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   956
	1 to:40 do:[:i|
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   957
	    i odd ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   958
		cell red:100 green:0 blue:0
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   959
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   960
		cell red:0 green:0 blue:0
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   961
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   962
	    Display flush.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   963
	    (Delay forSeconds:0.4) wait
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   964
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   965
	l destroy.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   966
     ] fork.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   967
     l open
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   968
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   969
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   970
    "Modified: 13.5.1996 / 12:41:53 / cg"
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
3892
fb62c937c134 category
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
   973
!Color class methodsFor:'Compatibility-Squeak'!
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   974
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
   975
colorPaletteForDepth: depth extent: chartExtent
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   976
	"Squeak mimicri:
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   977
	 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."
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   978
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   979
	"Note: It is slow to build this palette, so it should be cached for quick access."
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   980
	"(Color colorPaletteForDepth: 16 extent: 190@60) display"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   981
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   982
	| basicHue x y c startHue palette transHt vSteps transCaption grayWidth hSteps |
3324
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
   983
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
   984
"/        Smalltalk isSmalltalkX ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   985
	    palette := Image extent:chartExtent depth:24.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   986
	    palette photometric:#rgb.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   987
	    palette bits:(ByteArray new:chartExtent x * chartExtent y * 3).
3324
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
   988
"/        ] ifFalse:[
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
   989
"/            palette := Form extent: chartExtent depth: depth.
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
   990
"/        ].
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   991
	transCaption := "(DisplayText text: 'no color' asText textStyle: (TextConstants at: #ComicPlain)) form storeString"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   992
		(Form extent: 34@9 depth: 1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   993
			fromArray: #(0 0 256 0 256 0 3808663859 2147483648 2491688266 2147483648 2491688266 0 2491688266 0 2466486578 0 0 0)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   994
			offset: 0@0).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   995
	transHt := transCaption height.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   996
	palette fillWhite: (0@0 extent: palette width@transHt).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   997
	palette fillBlack: (0@transHt extent: palette width@1).
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
   998
"/        transCaption displayOn: palette at: palette boundingBox topCenter - ((transCaption width // 2)@0).
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   999
	grayWidth := 10.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1000
	startHue := 338.0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1001
	vSteps := palette height - transHt // 2.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1002
	hSteps := palette width - grayWidth.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1003
	x := 0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1004
	startHue to: startHue + 360.0 by: 360.0/hSteps do: [:h |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1005
		basicHue := Color h: h asFloat s: 1.0 v: 1.0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1006
		y := transHt+1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1007
		0 to: vSteps do: [:n |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1008
			c := basicHue mixed: (n asFloat / vSteps asFloat) with: Color white.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1009
			palette fill: (x@y extent: 1@1) fillColor: c.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1010
			y := y + 1].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1011
		1 to: vSteps do: [:n |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1012
			c := Color black mixed: (n asFloat / vSteps asFloat) with: basicHue.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1013
			y < palette height ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1014
			    palette fill: (x@y extent: 1@1) fillColor: c.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1015
			].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1016
			y := y + 1].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1017
		x := x + 1].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1018
	y := transHt + 1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1019
	1 to: vSteps * 2 do: [:n |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1020
		c := Color black mixed: (n asFloat / (vSteps*2) asFloat) with: Color white.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1021
		palette fill: (x@y corner:(((x@y) +(10@1))min:palette extent)) fillColor: c.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1022
		y := y + 1].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1023
	^ palette
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1024
!
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1025
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1026
fromRgbTriplet:aTriple
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1027
    ^ self r:(aTriple at:1)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1028
	   g:(aTriple at:2)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1029
	   b:(aTriple at:3)
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1030
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1031
!
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1032
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1033
h:hue s:saturation v:brightness
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1034
    "Squeak mimicri:
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1035
     Create a color with the given hue, saturation, and brightness.
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1036
     Hue is given as the angle in degrees of the color on the color circle,
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1037
     where red is zero degrees.
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1038
     Saturation and brightness are numbers in [0.0..1.0],
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1039
     where larger values are more saturated or brighter colors.
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1040
     For example, (Color h: 0 s: 1 v: 1) is pure red."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1041
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  1042
    "Note: By convention, brightness is abbreviated 'v' to avoid confusion with blue."
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1043
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1044
    ^ self hue:hue light:(brightness*50) saturation:(saturation*100)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1045
!
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1046
4986
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1047
indexedColors
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1048
    "Build an array of colors corresponding to the fixed colormap used
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1049
     for display depths of 1, 2, 4, or 8 bits."
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1050
    "Color indexedColors"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1051
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1052
    | a index grayVal |
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1053
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1054
    a := Array new: 256.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1055
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1056
    "1-bit colors (monochrome)"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1057
    a at: 1 put: (Color r: 1.0 g: 1.0 b: 1.0).  "white or transparent"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1058
    a at: 2 put: (Color r: 0.0 g: 0.0 b: 0.0).  "black"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1059
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1060
    "additional colors for 2-bit color"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1061
    a at: 3 put: (Color r: 1.0 g: 1.0 b: 1.0).  "opaque white"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1062
    a at: 4 put: (Color r: 0.5 g: 0.5 b: 0.5).  "1/2 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1063
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1064
    "additional colors for 4-bit color"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1065
    a at:  5 put: (Color r: 1.0 g: 0.0 b: 0.0). "red"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1066
    a at:  6 put: (Color r: 0.0 g: 1.0 b: 0.0). "green"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1067
    a at:  7 put: (Color r: 0.0 g: 0.0 b: 1.0). "blue"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1068
    a at:  8 put: (Color r: 0.0 g: 1.0 b: 1.0). "cyan"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1069
    a at:  9 put: (Color r: 1.0 g: 1.0 b: 0.0). "yellow"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1070
    a at: 10 put: (Color r: 1.0 g: 0.0 b: 1.0). "magenta"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1071
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1072
    a at: 11 put: (Color r: 0.125 g: 0.125 b: 0.125).       "1/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1073
    a at: 12 put: (Color r: 0.25 g: 0.25 b: 0.25).      "2/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1074
    a at: 13 put: (Color r: 0.375 g: 0.375 b: 0.375).       "3/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1075
    a at: 14 put: (Color r: 0.625 g: 0.625 b: 0.625).       "5/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1076
    a at: 15 put: (Color r: 0.75 g: 0.75 b: 0.75).      "6/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1077
    a at: 16 put: (Color r: 0.875 g: 0.875 b: 0.875).       "7/8 gray"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1078
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1079
    "additional colors for 8-bit color"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1080
    "24 more shades of gray (1/32 increments but not repeating 1/8 increments)"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1081
    index := 17.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1082
    1 to: 31 do: [:v |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1083
	(v \\ 4) = 0 ifFalse: [
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1084
	    grayVal := v / 32.0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1085
	    a at: index put: (Color r: grayVal g: grayVal b: grayVal).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1086
	    index := index + 1]].
4986
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1087
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1088
    "The remainder of color table defines a color cube with six steps
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1089
     for each primary color. Note that the corners of this cube repeat
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1090
     previous colors, but this simplifies the mapping between RGB colors
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1091
     and color map indices. This color cube spans indices 40 through 255
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1092
     (indices 41-256 in this 1-based array)."
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1093
    0 to: 5 do: [:r |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1094
	0 to: 5 do: [:g |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1095
	    0 to: 5 do: [:b |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1096
		index := 41 + ((36 * r) + (6 * b) + g).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1097
		index > 256 ifTrue: [
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1098
		    self error: 'index out of range in color table compuation'].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1099
		a at: index put: (Color r: r g: g b: b range: 5)]]].
4986
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1100
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1101
    ^ a.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1102
!
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1103
3893
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1104
paleBlue
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1105
    ^ self r:0.75 g:0.75 b:1
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1106
!
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1107
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1108
pixelScreenForDepth: depth
3898
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1109
    "Return a 50% stipple containing alternating pixels of all-zeros and all-ones to be used as a mask at the given depth."
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1110
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1111
    | mask bits |
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1112
6584
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1113
    (Smalltalk isSmalltalkX) ifTrue:[
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1114
        depth == 1 ifTrue:[
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1115
            ^ Form mediumGreyFormOn:Screen current
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1116
        ].
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1117
        self shouldImplement.
3898
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1118
    ].
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1119
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1120
    mask := (1 bitShift: depth) - 1.
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1121
    bits := 2 * depth.
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1122
    [bits >= 32] whileFalse: [
6584
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1123
        mask := mask bitOr: (mask bitShift: bits).  "double the length of mask"
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1124
        bits := bits + bits
3898
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1125
    ].
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1126
    ^ Bitmap with: mask with: mask bitInvert32
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1127
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1128
    "
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1129
     self pixelScreenForDepth: depth
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1130
    "
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1131
!
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1132
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1133
r:redFraction g:greenFraction b:blueFraction
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1134
    "Squeak mimicri:
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1135
     return a color from red, green and blue fractional values;
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1136
     the arguments, r, g and b must be in (0..1)"
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1137
2937
4536e6de438a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  1138
    ^ here scaledRed:(redFraction * MaxValue) rounded
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1139
	   scaledGreen:(greenFraction * MaxValue) rounded
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1140
	   scaledBlue:(blueFraction * MaxValue) rounded
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1141
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1142
    "Modified: / 06-06-2007 / 11:19:53 / cg"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1143
!
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1144
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1145
r:r g:g b:b alpha:alphaValue
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1146
    "return a color from red, green and blue values;
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1147
     the arguments, r, g, b and alpha must be in 0..1"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1148
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1149
    ^ (self r:r g:g b:b) alpha:alphaValue
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1150
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1151
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1152
     (Color r:1 g:0 b:0 alpha:0) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1153
     (Color r:0 g:1 b:0 alpha:0.5) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1154
     (Color r:0 g:0 b:1 alpha:1) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1155
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1156
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1157
    "Created: / 06-06-2007 / 10:48:21 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1158
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1159
4202
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1160
r:r g:g b:b range:componentMax
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1161
    "return a color from red, green and blue values;
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1162
     the arguments, r, g and b are interpreted as values (0..componentMax)"
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1163
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1164
    ^ here scaledRed:(r * MaxValue // componentMax)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1165
	   scaledGreen:(g * MaxValue // componentMax)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1166
	   scaledBlue:(b * MaxValue // componentMax)
4202
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1167
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1168
    "
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1169
     (Color r:1023 g:0 b:0 range:1023) inspect
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1170
     (Color r:1023 g:1023 b:1023 range:1023) inspect
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1171
     (Color r:0 g:0 b:0 range:1023) inspect
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1172
    "
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1173
!
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1174
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1175
showColors: colorList
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1176
	"Display the given collection of colors across the top of the Display."
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1177
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1178
	| w r |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1179
	w := Screen current width // colorList size.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1180
	r := 0@0 extent: w@((w min: 30) max: 10).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1181
	colorList do: [:c |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1182
		Screen current fill: r fillColor: c.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1183
		r := r translateBy: w@0].
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1184
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1185
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1186
wheel: thisMany
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1187
    "Return a collection of thisMany colors evenly spaced around the color wheel."
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1188
    "Color showColors: (Color wheel: 12)"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1189
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1190
    ^ Color wheel: thisMany saturation: 0.9 brightness: 0.7
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1191
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1192
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1193
wheel: thisMany saturation: s brightness: v
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1194
    "Return a collection of thisMany colors evenly spaced around the color wheel,
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1195
     all of the given saturation and brightness."
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1196
    "Color showColors: (Color wheel: 12 saturation: 0.4 brightness: 1.0)"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1197
    "Color showColors: (Color wheel: 12 saturation: 0.8 brightness: 0.5)"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1198
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1199
    ^ (Color h: 0.0 s: s v: v) wheel: thisMany
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1200
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1201
    "Modified: / 06-06-2007 / 11:20:59 / cg"
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1202
! !
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1203
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1204
!Color class methodsFor:'Signal constants'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1205
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1206
colorAllocationFailSignal
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1207
    "return the signal raised when a color allocation failed."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1208
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1209
    ^ ColorAllocationFailSignal
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1210
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1211
    "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
  1212
!
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1213
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1214
colorErrorSignal
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1215
    "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
  1216
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1217
    ^ ColorErrorSignal
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1218
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1219
    "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
  1220
!
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1221
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1222
invalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1223
    "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
  1224
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1225
    ^ InvalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1226
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1227
    "Created: 24.1.1997 / 13:36:25 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1228
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1229
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1230
!Color class methodsFor:'accessing'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1231
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1232
allocatedColorsOn:aDevice
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1233
    "return a collection of colors which have already been allocated
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1234
     on aDevice."
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1235
4176
40b359dfc293 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4170
diff changeset
  1236
    <resource: #obsolete>
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1237
    self obsoleteMethodWarning:'use #allocatedColorsOnDevice:'.
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1238
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1239
    ^ self allocatedColorsOnDevice:aDevice
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1240
!
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1241
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1242
allocatedColorsOnDevice:aDevice
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1243
    "return a collection of colors which have already been allocated
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1244
     on aDevice."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1245
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1246
    |colors|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1247
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1248
    colors := OrderedCollection new.
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1249
    aDevice deviceColors do:[:clr |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1250
	clr colorId notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1251
	    colors add:clr
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1252
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1253
	    'Color [oops]: nil colorId in color' infoPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1254
	]
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
    ^ colors asArray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1257
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1258
    "
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1259
     Color allocatedColorsOnDevice:Display
1023
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
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1262
    "Modified: 24.2.1997 / 18:16:14 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1263
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1264
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1265
!Color class methodsFor:'color space conversions'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1266
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1267
withHLSFromRed:r green:g blue:b do:aBlock
3543
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1268
    "compute hls form rgb, evaluate aBlock with h,l and s as arguments.
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1269
     r,g,b in 0..100
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1270
     h in 0..360; l in 0..100; s in 0..100"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1271
6110
28bccabea00a class: Color
Claus Gittinger <cg@exept.de>
parents: 5965
diff changeset
  1272
    |max min r1 g1 b1 delta h l s divisor|
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1273
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1274
    r1 := r / 100.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1275
    g1 := g / 100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1276
    b1 := b / 100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1277
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1278
    max := (r1 max:g1) max:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1279
    min := (r1 min:g1) min:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1280
    l := (max + min) / 2.
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
    max = min ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1283
	"achromatic, r=g=b"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1284
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1285
	s := 0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1286
	h := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1287
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1288
	l < 0.5 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1289
	    divisor := (max + min)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1290
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1291
	    divisor := (2 - max - min)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1292
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1293
	divisor = 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1294
	    s := 1.0
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1295
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1296
	    s := (max - min) / divisor
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1297
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1298
	"calc hue"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1299
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1300
	delta := max - min.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1301
	r1 = max ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1302
	    h := (g1 - b1) / delta
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1303
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1304
	    g1 = max ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1305
		h := 2 + ((b1 - r1) / delta)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1306
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1307
		h := 4 + ((r1 - g1) / delta)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1308
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1309
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1310
	h := h * 60.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1311
	h < 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1312
	    h := h + 360
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1313
	].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1314
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1315
    aBlock value:h value:(l * 100) value:(s * 100)
6110
28bccabea00a class: Color
Claus Gittinger <cg@exept.de>
parents: 5965
diff changeset
  1316
28bccabea00a class: Color
Claus Gittinger <cg@exept.de>
parents: 5965
diff changeset
  1317
    "Modified: / 27-07-2013 / 11:48:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1318
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1319
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1320
withHLSFromScaledRed:r scaledGreen:g scaledBlue:b do:aBlock
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1321
    "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
  1322
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1323
    ^ self withHLSFromRed:(r * 100.0 / MaxValue)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1324
		    green:(g * 100.0 / MaxValue)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1325
		     blue:(b * 100.0 / MaxValue)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1326
		       do:aBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1327
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1328
    "Created: 11.6.1996 / 17:23:47 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1329
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1330
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1331
withRGBFromHue:h light:l saturation:s do:aBlock
3543
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1332
    "compute rgb form hls, evaluate aBlock with r,g and b as arguments
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1333
     r,g,b in 0..100
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1334
     h in 0..360; l in 0..100; s in 0..100"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1335
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1336
    |valueFunc s1 l1 r g b m1 m2|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1337
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1338
    valueFunc := [:n1 :n2 :hIn |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1339
	|hue|
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1340
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1341
	hue := hIn.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1342
	hue > 360 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1343
	    hue := hue - 360
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1344
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1345
	    hue < 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1346
		hue := hue + 360
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1347
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1348
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1349
	hue < 60 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1350
	    n1 + ((n2 - n1) * hue / 60)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1351
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1352
	    hue < 180 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1353
		n2
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1354
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1355
		hue < 240 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1356
		    n1 + ((n2 - n1) * (240 - hue) / 60)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1357
		] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1358
		    n1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1359
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1360
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1361
	]
1023
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
    "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
  1365
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1366
    s1 := s / 100.0.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1367
    l1 := l / 100.0.
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
    l1 <= 0.5 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1370
	m2 := l1 * (1 + s1)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1371
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1372
	m2 := l1 + s1 - (l1 * s1)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1373
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1374
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1375
    m1 := 2 * l1 - m2.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1376
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1377
    s1 = 0 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1378
	"achromatic, ignore hue"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1379
	r := g := b := l1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1380
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1381
	r := valueFunc value:m1 value:m2 value:h + 120.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1382
	g := valueFunc value:m1 value:m2 value:h.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1383
	b := valueFunc value:m1 value:m2 value:h - 120.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1384
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1385
    aBlock value:r*100 value:g*100 value:b*100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1386
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1387
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1388
!Color class methodsFor:'constant colors'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1389
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1390
black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1391
    "return the black color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1392
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1393
    Black isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1394
	Black := self red:0 green:0 blue:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1395
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1396
    ^ Black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1397
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1398
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1399
     Color black inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1400
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1401
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1402
    "Modified: 11.6.1996 / 15:55:31 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1403
!
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
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1406
    "return the blue color"
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
    Blue isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1409
	Blue := self redPercent:0 greenPercent:0 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1410
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1411
    ^ Blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1412
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1413
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1414
     Color blue inspect
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1417
    "Modified: 23.4.1996 / 13:15:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1418
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1419
2962
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1420
brown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1421
    ^ self redPercent:60 greenPercent:20 bluePercent:0
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1422
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1423
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1424
     Color brown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1425
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1426
!
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1427
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1428
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1429
    "return the cyan color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1430
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1431
    ^ self cyan:100
1023
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1434
     Color cyan inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1435
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1436
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1437
    "Modified: 23.4.1996 / 13:16:07 / cg"
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
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1440
cyan: cyan
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1441
    "return a cyan color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1442
     the argument cyan is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1443
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1444
     ^ self cyan:100 magenta:100-cyan yellow:100-cyan
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1445
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1446
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1447
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1448
darkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1449
    "return the dark grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1450
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1451
    DarkGrey isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1452
	DarkGrey := self grayPercent:33
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1453
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1454
    ^ DarkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1455
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1456
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1457
     Color darkGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1458
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1459
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1460
    "Modified: 24.2.1997 / 21:33:11 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1461
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1462
8660
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1463
darkGreen
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1464
    "return a dark green color"
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1465
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1466
    DarkGreen isNil ifTrue:[
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1467
        DarkGreen := self green darkened
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1468
    ].
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1469
    ^ DarkGreen
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1470
    
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1471
    "
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1472
     Color darkGreen
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1473
    "
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1474
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1475
    "Created: / 13-03-2019 / 21:10:09 / Claus Gittinger"
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1476
!
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1477
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1478
darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1479
    "return the darkGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1480
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1481
    ^ self darkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1482
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1483
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1484
     Color darkGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1485
    "
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
    "Modified: 28.5.1996 / 20:47:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1488
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1489
8660
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1490
darkRed
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1491
    "return a dark green color"
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1492
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1493
    DarkRed isNil ifTrue:[
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1494
        DarkRed := self red darkened
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1495
    ].
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1496
    ^ DarkRed
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1497
    
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1498
    "
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1499
     Color darkRed
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1500
    "
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1501
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1502
    "Created: / 13-03-2019 / 21:16:02 / Claus Gittinger"
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1503
!
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1504
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1505
gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1506
    "return a medium grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1507
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1508
    Grey isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1509
	Grey := self grayPercent:50
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1510
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1511
    ^ Grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1512
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1513
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1514
     Color gray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1515
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1516
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1517
    "Modified: 24.2.1997 / 21:33:19 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1518
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1519
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1520
gray:gray
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1521
    "return a gray color (US version).
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1522
     The argument, gray is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1523
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1524
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1525
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1526
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1527
     Color gray:25
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1528
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1529
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1530
    "Modified: 28.5.1996 / 20:49:51 / cg"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1531
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1532
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1533
grayPercent:gray
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1534
    "return a gray color (US version).
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1535
     The argument, gray is interpreted as percent (0..100)."
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1536
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1537
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1538
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
     Color gray:25
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1541
    "
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
    "Modified: 28.5.1996 / 20:49:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1544
!
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
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1547
    "return green"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1548
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1549
    Green isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1550
	Green := self redPercent:0 greenPercent:100 bluePercent:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1551
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1552
    ^ Green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1553
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
     Color green inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1556
    "
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
    "Modified: 23.4.1996 / 13:23:08 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1559
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1560
7832
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1561
greenCaringForColorBlindness
7833
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1562
    "return the color to use for a darkened green (showing text in that color),
7832
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1563
     possibly using anther color if the settings specifies color blindness"
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1564
     
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1565
    UserPreferences current useColorsForColorBlindness ifTrue:[
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1566
        "/ for now: later, this will also be configurable
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1567
        ^ self blue.
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1568
    ] ifFalse:[
7833
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1569
        ^ self green darkened.
7832
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1570
    ].
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1571
7833
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1572
    "
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1573
     self greenCaringForColorBlindness
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1574
    "
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1575
7832
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1576
    "Created: / 03-02-2017 / 14:02:26 / cg"
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1577
!
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1578
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1579
grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1580
    "return the grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1581
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1582
    ^ self gray
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1585
     Color grey inspect
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1588
    "Modified: 28.5.1996 / 20:48:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1589
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1590
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1591
grey:grey
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1592
    "return a grey color (English version).
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1593
     The argument, grey is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1594
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1595
    ^ self grayPercent:grey
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1596
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1597
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1598
     Color grey:25
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1599
     Color grey:12.5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1600
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1601
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1602
    "Modified: 24.2.1997 / 21:33:28 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1603
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1604
5419
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1605
greyByte:greyByte
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1606
    "return a grey color (English version).
5419
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1607
     The argument, grey is interpreted as byte-value (0..255)."
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1608
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1609
    ^ self redByte:greyByte greenByte:greyByte blueByte:greyByte
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1610
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1611
    "
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1612
     Color greyByte:127
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1613
    "
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1614
!
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1615
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1616
lightBlue
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1617
    "return a light blue color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1618
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1619
    ^ self redPercent:50 greenPercent:50 bluePercent:100
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1620
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1621
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1622
     Color lightBlue inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1623
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1624
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1625
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1626
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1627
2962
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1628
lightBrown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1629
    ^ self brown lighter
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1630
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1631
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1632
     Color lightBrown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1633
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1634
!
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1635
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1636
lightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1637
    "return the lightGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1638
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1639
    LightGrey isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1640
	LightGrey := self grayPercent:67
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1641
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1642
    ^ LightGrey
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1645
     Color lightGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1646
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1647
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1648
    "Modified: 24.2.1997 / 21:33:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1649
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1650
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1651
lightGreen
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1652
    "return a light green color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1653
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1654
    ^ self redPercent:50 greenPercent:100 bluePercent:50
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
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1657
     Color lightGreen inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1658
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1659
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1660
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1661
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1662
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1663
lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1664
    "return the lightGrey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1665
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1666
    ^ self lightGray
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 lightGrey 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: 28.5.1996 / 20:51:11 / 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
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1675
lightRed
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1676
    "return a light red color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1677
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1678
    ^ self redPercent:100 greenPercent:50 bluePercent:50
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1679
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1680
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1681
     Color lightRed inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1682
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1683
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1684
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1685
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1686
2949
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1687
lightYellow
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1688
    ^ self yellow lighter
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1689
!
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1690
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1691
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1692
    "return the magenta color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1693
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1694
    ^ self magenta:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1695
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1696
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1697
     Color magenta inspect
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1700
    "Modified: 23.4.1996 / 13:23:41 / cg"
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
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1703
magenta: magenta
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1704
    "return a magenta color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1705
     the argument magenta is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1706
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1707
     ^ self cyan:100-magenta magenta:100 yellow:100-magenta
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1708
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1709
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1710
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1711
mediumGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1712
    "return medium-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1713
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1714
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1715
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1716
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1717
     Color mediumGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1718
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1719
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1720
    "Created: 23.4.1996 / 13:24:17 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1721
    "Modified: 28.5.1996 / 20:51:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1722
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1723
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1724
mediumGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1725
    "return medium-grey color (English version ;-)"
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
    ^ self gray
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
     Color mediumGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1731
    "
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
    "Modified: 28.5.1996 / 20:51:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1734
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1735
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1736
orange
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1737
    "return the orange color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1738
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1739
    Orange isNil ifTrue:[
7909
c5f82e9429f9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7885
diff changeset
  1740
        Orange := self rgbValue:16rFFA500.
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1741
    ].
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1742
    ^ Orange
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1743
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1744
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1745
     Color orange inspect
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1746
    "
7909
c5f82e9429f9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7885
diff changeset
  1747
c5f82e9429f9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7885
diff changeset
  1748
    "Modified: / 17-02-2017 / 12:34:20 / cg"
2077
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1749
!
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1750
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1751
orange: orange
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1752
    "return a orange color;
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1753
     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
  1754
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  1755
     ^ self redPercent:orange greenPercent:orange/2 bluePercent:0
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1756
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1757
!
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1758
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1759
pink
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1760
    "return the pink color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1761
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1762
     ^ self redPercent:100 greenPercent:0 bluePercent:100
1023
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
    "Modified: 23.4.1996 / 13:29:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1765
!
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
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1768
    "return the red color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1769
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1770
    Red isNil ifTrue:[
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1771
        Red := self redPercent:100 greenPercent:0 bluePercent:0.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1772
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1773
    ^ Red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1774
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1775
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1776
     Color red inspect
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1777
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1778
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1779
    "Modified: 23.4.1996 / 13:29:44 / cg"
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
7832
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1782
redCaringForColorBlindness
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1783
    "return the color to use for green,
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1784
     possibly using anther color if the settings specifies color blindness"
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1785
     
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1786
    UserPreferences current useColorsForColorBlindness ifTrue:[
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1787
        "/ for now: later, this will also be configurable
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1788
        ^ self red.
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1789
    ] ifFalse:[
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1790
        ^ self red.
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1791
    ].
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1792
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1793
    "Created: / 03-02-2017 / 14:02:50 / cg"
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1794
!
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1795
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1796
transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1797
    "return the transparent-color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1798
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1799
    Transparent isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1800
	Transparent := TranslucentColor scaledRed:0 scaledGreen:0 scaledBlue:0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1801
	Transparent setAlphaByte:0.
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1802
    ].
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1803
    ^ Transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1804
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1805
    "
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1806
     self transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1807
    "
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1808
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  1809
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1810
veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1811
    "return a very dark-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1812
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1813
    ^ self grayPercent:13
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1814
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1815
    "Created: 23.4.1996 / 13:33:14 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1816
    "Modified: 24.2.1997 / 21:33:52 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1817
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1818
8660
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1819
veryDarkGreen
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1820
    "return a very dark green color"
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1821
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1822
    ^ self darkGreen darkened
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1823
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1824
    "
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1825
     Color veryDarkGreen
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1826
    "
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1827
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1828
    "Created: / 13-03-2019 / 21:15:31 / Claus Gittinger"
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1829
!
ee175c43cba6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8456
diff changeset
  1830
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1831
veryDarkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1832
    "return a very dark-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1833
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1834
    ^ self veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1835
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1836
    "Modified: 28.5.1996 / 20:52:49 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1837
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1838
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1839
veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1840
    "return a very light-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1841
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1842
    ^ self grayPercent:87
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1843
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1844
    "Created: 23.4.1996 / 13:33:46 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1845
    "Modified: 24.2.1997 / 21:33:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1846
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1847
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1848
veryLightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1849
    "return a very light-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1850
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1851
    ^ self veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1852
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1853
    "Modified: 28.5.1996 / 20:52:03 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1854
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1855
3030
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1856
veryVeryLightGray
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1857
    "return a very very light-grey color (US version ;-)"
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1858
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1859
    ^ self grayPercent:93
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1860
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1861
!
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  1862
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1863
white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1864
    "return the white-color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1865
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1866
    White isNil ifTrue:[
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1867
        White := self redPercent:100 greenPercent:100 bluePercent:100.
1023
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
    ^ White
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1870
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1871
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1872
     Color white inspect
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1873
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1874
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1875
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1876
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1877
    "return the yellow color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1878
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1879
    Yellow isNil ifTrue:[
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1880
        Yellow := self redPercent:100 greenPercent:100 bluePercent:0.
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1881
    ].
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1882
    ^ Yellow
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1883
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1884
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1885
     Color yellow inspect
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  1886
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1887
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1888
    "Modified: 23.4.1996 / 13:33:56 / cg"
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1889
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1890
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1891
yellow: yellow
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1892
    "return a yellow color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1893
     the argument yellow is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1894
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1895
     ^ self cyan:100-yellow magenta:100-yellow yellow:100
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1896
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
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1899
!Color class methodsFor:'obsolete'!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1900
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1901
nameOrDither:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1902
    "return a named color - if the exact color is not available,
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1903
     return a dithered color. Report an error, if the colorname is
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1904
     illegal."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1905
3427
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  1906
    <resource:#obsolete>
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  1907
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1908
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1909
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1910
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1911
    "Modified: 16.1.1997 / 23:01:03 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1912
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1913
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1914
nameOrDither:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1915
    "return a named color - if the exact color is not available,
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1916
     return a dithered color. If the colorname is illegal, return
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1917
     the value of evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1918
3427
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  1919
    <resource:#obsolete>
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  1920
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1921
    self obsoleteMethodWarning:'use #name:ifIllegal:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1922
    ^ self name:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1923
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1924
    "Modified: 16.1.1997 / 23:01:32 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1925
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1926
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1927
nameOrNearest:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1928
    "return a named color - or its nearest match"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1929
3427
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  1930
    <resource:#obsolete>
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  1931
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1932
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1933
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1934
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1935
    "Modified: 16.1.1997 / 23:02:18 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1936
! !
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1937
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1938
!Color class methodsFor:'private'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1939
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1940
colorNearRed:r green:g blue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1941
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1942
     almost matching. If there is one, nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1943
     This is tried as a last chance before dithering.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1944
     The algorithm needs rework, the color components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1945
     should be weighted according some theory :-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1946
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1947
    |bestColor minDelta diff rr rg rb dRed|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1948
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1949
"/    rr := (r * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1950
"/    rg := (g * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1951
"/    rb := (b * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1952
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1953
    rr := r rounded.                "round to 1%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1954
    rg := (g * 2.0) rounded / 2.0.  "round to 0.5%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1955
    rb := (b / 2) rounded * 2.      "round to 2%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1956
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1957
    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
  1958
    aDevice deviceColors do:[:aColor |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1959
	dRed := rr - aColor red.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1960
	dRed < 10 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1961
	    diff := dRed asInteger squared
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1962
		    + (rg - aColor green) asInteger squared
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1963
		    + (rb - aColor blue) asInteger squared.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1964
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1965
	    diff < minDelta ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1966
		diff = 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1967
		    "got it"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1968
		    ^ aColor
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1969
		].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1970
		bestColor := aColor.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1971
		minDelta := diff
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1972
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1973
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1974
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1975
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1976
    "allow an error of 10% per component"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1977
    minDelta < (100+100+100) ifTrue:[ ^ bestColor ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1978
    ^ nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1979
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1980
    "Modified: 24.2.1997 / 18:17:24 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1981
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1982
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1983
existingColorRed:r green:g blue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1984
    "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
  1985
     if there is one, nil otherwise."
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
    ^ self existingColorScaledRed:(r * MaxValue // 100)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1988
			scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1989
			scaledBlue:(b * MaxValue // 100)
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1990
!
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
existingColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1993
    "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
  1994
     if there is one, nil otherwise."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1995
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  1996
    aDevice deviceColors do:[:aColor |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1997
	(r == aColor scaledRed) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1998
	    (g == aColor scaledGreen) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1999
		(b == aColor scaledBlue) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2000
		    ^ aColor
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2001
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2002
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2003
	]
1707
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
    ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2006
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2007
    "Modified: 24.2.1997 / 18:17:35 / cg"
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
3878
28052cae1ad3 method category rename
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
  2010
!Color class methodsFor:'private-dithering'!
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2011
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2012
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
  2013
    "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
  2014
     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
  2015
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2016
    |errR errG errB f wantR wantG wantB clr
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2017
     dir   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2018
     start "{ Class: SmallInteger }"
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2019
     end   "{ Class: SmallInteger }"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2020
     map
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2021
     w     "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2022
     h     "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2023
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2024
"/    w := h := 32.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2025
"/    w := h := 4.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2026
    w := h := 2.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2027
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2028
    errR := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2029
    errG := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2030
    errB := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2031
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2032
    "get a form and clear it"
4785
ffb3b0caceb8 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4772
diff changeset
  2033
    f := Form width:w height:h depth:(aDevice depth) onDevice:aDevice.
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2034
    f isNil ifTrue:[^ nil].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2035
    map := IdentityDictionary new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2036
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2037
    0 to:(w-1) do:[:x |
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2038
        x even ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2039
            dir := 1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2040
            start := 0.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2041
            end := (h-1).
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2042
        ] ifFalse:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2043
            dir := -1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2044
            start := (h-1).
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2045
            end := 0.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2046
        ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2047
        start to:end by:dir do:[:y |
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2048
            wantR := red + errR.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2049
            wantR > MaxValue ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2050
                wantR := MaxValue
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2051
            ] ifFalse:[ wantR < 0 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2052
                wantR := 0
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2053
            ]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2054
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2055
            wantG := green + errG.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2056
            wantG > MaxValue ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2057
                wantG := MaxValue
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2058
            ] ifFalse:[ wantG < 0 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2059
                wantG := 0
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2060
            ]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2061
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2062
            wantB := blue + errB.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2063
            wantB > MaxValue ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2064
                wantB := MaxValue
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2065
            ] ifFalse:[ wantB < 0 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2066
                wantB := 0
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2067
            ]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2068
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2069
            "find the nearest color"
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2070
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2071
            clr := Color quickNearestColorScaledRed:wantR scaledGreen:wantG scaledBlue:wantB on:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2072
"
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2073
            clr := Color nearestColorScaledRed:wantR green:wantG blue:wantB on:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2074
"
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2075
            clr isNil ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2076
                clr := Color scaledRed:wantR scaledGreen:wantG scaledBlue:wantB.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2077
                clr brightness > 0.5 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2078
                    clr := Color white
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2079
                ] ifFalse:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2080
                    clr := Color black
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2081
                ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2082
                clr := clr onDevice:aDevice
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2083
"
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2084
                ^ aBlock value:nil value:nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2085
"
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2086
            ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2087
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2088
            f paint:clr.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2089
            f displayPointX:x y:y.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2090
            map at:clr colorId + 1 put:clr.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2091
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2092
            "compute the new error"
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2093
            errR := wantR - clr scaledRed.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2094
            errG := wantG - clr scaledGreen.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2095
            errB := wantB - clr scaledBlue.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2096
        ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2097
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2098
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2099
    f colorMap:map.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2100
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2101
'hard dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2102
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2103
    ^ aBlock value:nil value:f
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2104
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2105
    "Created: 3.5.1997 / 11:02:47 / cg"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2106
    "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
  2107
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2108
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2109
ditherBits
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2110
    "return a dither pattern for x/64; x in 1..63"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2111
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2112
    ^ #(
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2113
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2114
	"/ 1in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2115
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2116
	  #[2r10000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2117
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2118
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2119
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2120
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2121
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2122
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2123
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2124
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2125
	"/ 2in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2126
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2127
	  #[2r10000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2128
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2129
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2130
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2131
	    2r00001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2132
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2133
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2134
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2135
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2136
	"/ 3in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2137
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2138
	  #[2r10000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2139
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2140
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2141
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2142
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2143
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2144
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2145
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2146
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2147
	"/ 4in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2148
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2149
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2150
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2151
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2152
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2153
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2154
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2155
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2156
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2157
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2158
	"/ 5in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2159
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2160
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2161
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2162
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2163
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2164
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2165
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2166
	    2r00000010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2167
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2168
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2169
	"/ 6in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2170
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2171
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2172
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2173
	    2r00100000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2174
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2175
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2176
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2177
	    2r00000010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2178
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2179
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2180
	"/ 7in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2181
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2182
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2183
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2184
	    2r00100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2185
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2186
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2187
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2188
	    2r00000010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2189
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2190
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2191
	"/ 8in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2192
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2193
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2194
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2195
	    2r00100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2196
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2197
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2198
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2199
	    2r00100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2200
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2201
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2202
	"/ 9in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2203
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2204
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2205
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2206
	    2r00100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2207
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2208
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2209
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2210
	    2r10100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2211
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2212
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2213
	"/ 10in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2214
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2215
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2216
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2217
	    2r00101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2218
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2219
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2220
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2221
	    2r10100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2222
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2223
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2224
	"/ 11in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2225
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2226
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2227
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2228
	    2r00101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2229
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2230
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2231
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2232
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2233
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2234
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2235
	"/ 12in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2236
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2237
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2238
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2239
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2240
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2241
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2242
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2243
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2244
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2245
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2246
	"/ 13in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2247
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2248
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2249
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2250
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2251
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2252
	    2r10101000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2253
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2254
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2255
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2256
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2257
	"/ 14in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2258
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2259
	  #[2r10001010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2260
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2261
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2262
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2263
	    2r10101000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2264
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2265
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2266
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2267
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2268
	"/ 15in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2269
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2270
	  #[2r10001010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2271
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2272
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2273
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2274
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2275
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2276
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2277
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2278
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2279
	"/ 16in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2280
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2281
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2282
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2283
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2284
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2285
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2286
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2287
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2288
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2289
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2290
	"/ 17in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2291
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2292
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2293
	    2r01000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2294
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2295
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2296
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2297
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2298
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2299
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2300
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2301
	"/ 18in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2302
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2303
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2304
	    2r01000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2305
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2306
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2307
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2308
	    2r00000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2309
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2310
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2311
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2312
	"/ 19in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2313
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2314
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2315
	    2r01000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2316
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2317
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2318
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2319
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2320
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2321
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2322
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2323
	"/ 20in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2324
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2325
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2326
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2327
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2328
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2329
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2330
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2331
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2332
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2333
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2334
	"/ 21in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2335
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2336
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2337
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2338
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2339
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2340
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2341
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2342
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2343
	    2r00000001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2344
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2345
	"/ 22in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2346
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2347
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2348
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2349
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2350
	    2r00010000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2351
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2352
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2353
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2354
	    2r00000001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2355
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2356
	"/ 23in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2357
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2358
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2359
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2360
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2361
	    2r00010001
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2362
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2363
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2364
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2365
	    2r00000001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2366
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2367
	"/ 24in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2368
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2369
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2370
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2371
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2372
	    2r00010001
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2373
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2374
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2375
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2376
	    2r00010001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2377
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2378
	"/ 25in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2379
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2380
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2381
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2382
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2383
	    2r00010001
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2384
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2385
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2386
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2387
	    2r01010001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2388
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2389
	"/ 26in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2390
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2391
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2392
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2393
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2394
	    2r00010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2395
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2396
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2397
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2398
	    2r01010001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2399
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2400
	"/ 27in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2401
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2402
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2403
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2404
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2405
	    2r00010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2406
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2407
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2408
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2409
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2410
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2411
	"/ 28in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2412
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2413
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2414
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2415
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2416
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2417
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2418
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2419
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2420
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2421
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2422
	"/ 29in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2423
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2424
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2425
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2426
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2427
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2428
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2429
	    2r01010100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2430
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2431
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2432
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2433
	"/ 30in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2434
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2435
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2436
	    2r01000101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2437
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2438
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2439
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2440
	    2r01010100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2441
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2442
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2443
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2444
	"/ 31in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2445
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2446
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2447
	    2r01000101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2448
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2449
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2450
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2451
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2452
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2453
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2454
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2455
	"/ 32in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2456
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2457
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2458
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2459
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2460
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2461
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2462
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2463
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2464
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2465
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2466
	"/ 33in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2467
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2468
	  #[2r11101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2469
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2470
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2471
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2472
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2473
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2474
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2475
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2476
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2477
	"/ 34in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2478
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2479
	  #[2r11101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2480
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2481
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2482
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2483
	    2r10101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2484
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2485
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2486
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2487
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2488
	"/ 35in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2489
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2490
	  #[2r11101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2491
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2492
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2493
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2494
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2495
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2496
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2497
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2498
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2499
	"/ 36in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2500
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2501
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2502
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2503
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2504
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2505
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2506
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2507
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2508
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2509
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2510
	"/ 37in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2511
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2512
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2513
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2514
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2515
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2516
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2517
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2518
	    2r10101011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2519
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2520
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2521
	"/ 38in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2522
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2523
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2524
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2525
	    2r10111010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2526
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2527
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2528
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2529
	    2r10101011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2530
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2531
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2532
	"/ 39in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2533
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2534
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2535
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2536
	    2r10111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2537
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2538
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2539
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2540
	    2r10101011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2541
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2542
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2543
	"/ 40in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2544
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2545
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2546
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2547
	    2r10111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2548
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2549
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2550
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2551
	    2r10111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2552
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2553
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2554
	"/ 41in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2555
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2556
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2557
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2558
	    2r10111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2559
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2560
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2561
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2562
	    2r11111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2563
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2564
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2565
	"/ 42in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2566
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2567
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2568
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2569
	    2r10111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2570
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2571
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2572
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2573
	    2r11111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2574
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2575
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2576
	"/ 43in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2577
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2578
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2579
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2580
	    2r10111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2581
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2582
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2583
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2584
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2585
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2586
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2587
	"/ 44in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2588
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2589
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2590
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2591
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2592
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2593
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2594
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2595
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2596
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2597
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2598
	"/ 45in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2599
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2600
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2601
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2602
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2603
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2604
	    2r11111110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2605
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2606
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2607
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2608
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2609
	"/ 46in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2610
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2611
	  #[2r11101111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2612
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2613
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2614
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2615
	    2r11111110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2616
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2617
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2618
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2619
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2620
	"/ 47in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2621
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2622
	  #[2r11101111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2623
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2624
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2625
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2626
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2627
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2628
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2629
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2630
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2631
	"/ 48in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2632
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2633
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2634
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2635
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2636
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2637
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2638
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2639
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2640
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2641
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2642
	"/ 49in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2643
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2644
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2645
	    2r01110101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2646
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2647
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2648
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2649
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2650
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2651
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2652
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2653
	"/ 50in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2654
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2655
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2656
	    2r01110101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2657
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2658
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2659
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2660
	    2r01010111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2661
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2662
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2663
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2664
	"/ 51in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2665
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2666
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2667
	    2r01110101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2668
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2669
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2670
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2671
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2672
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2673
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2674
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2675
	"/ 52in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2676
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2677
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2678
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2679
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2680
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2681
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2682
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2683
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2684
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2685
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2686
	"/ 53in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2687
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2688
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2689
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2690
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2691
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2692
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2693
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2694
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2695
	    2r11010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2696
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2697
	"/ 54in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2698
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2699
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2700
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2701
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2702
	    2r01011101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2703
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2704
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2705
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2706
	    2r11010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2707
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2708
	"/ 55in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2709
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2710
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2711
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2712
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2713
	    2r11011101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2714
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2715
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2716
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2717
	    2r11010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2718
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2719
	"/ 56in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2720
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2721
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2722
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2723
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2724
	    2r11011101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2725
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2726
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2727
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2728
	    2r11011101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2729
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2730
	"/ 57in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2731
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2732
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2733
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2734
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2735
	    2r11011101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2736
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2737
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2738
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2739
	    2r11111101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2740
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2741
	"/ 58in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2742
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2743
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2744
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2745
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2746
	    2r11011111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2747
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2748
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2749
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2750
	    2r11111101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2751
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2752
	"/ 59in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2753
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2754
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2755
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2756
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2757
	    2r11011111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2758
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2759
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2760
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2761
	    2r11111111]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2762
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2763
	"/ 60in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2764
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2765
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2766
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2767
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2768
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2769
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2770
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2771
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2772
	    2r11111111]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2773
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2774
	"/ 61in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2775
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2776
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2777
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2778
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2779
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2780
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2781
	    2r01111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2782
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2783
	    2r11111111]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2784
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2785
	"/ 62in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2786
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2787
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2788
	    2r11110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2789
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2790
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2791
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2792
	    2r01111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2793
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2794
	    2r11111111]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2795
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2796
	"/ 63in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2797
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2798
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2799
	    2r11110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2800
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2801
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2802
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2803
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2804
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2805
	    2r11111111]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2806
     )
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2807
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2808
    "Modified: 23.4.1996 / 13:31:50 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2809
    "Created: 11.6.1996 / 15:34:29 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2810
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2811
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2812
ditherGrayFor:fraction on:aDevice into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2813
    "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
  2814
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2815
     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
  2816
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2817
    |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
  2818
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2819
    d := aDevice depth.
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
    "/ special code for b&w displays
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2822
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2823
    d == 1 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2824
	aDevice blackpixel == 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2825
	    clr1 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2826
	    clr2 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2827
	    newFraction := fraction.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2828
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2829
	    clr1 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2830
	    clr2 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2831
	    newFraction := 1 - fraction
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2832
	]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2833
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2834
	"/ special code for 2-plane displays (NeXT)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2835
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2836
	d == 2 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2837
	    fraction <= 0.01 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2838
		clr1 := Black exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2839
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2840
		(fraction between:0.32 and:0.34) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2841
		    clr1 := (Color gray:33) exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2842
		] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2843
		    (fraction between:0.66 and:0.68) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2844
			clr1 := (Color gray:67) exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2845
		    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2846
			fraction >= 0.99 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2847
			    clr1 := White exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2848
			]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2849
		    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2850
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2851
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2852
	    clr1 notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2853
		^ aBlock value:clr1 value:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2854
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2855
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2856
	    (fraction between:0 and:0.33) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2857
		clr1 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2858
		clr2 := Color gray:33.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2859
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2860
		(fraction between:0.34 and:0.66) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2861
		    clr1 := Color gray:33.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2862
		    clr2 := Color gray:67.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2863
		] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2864
		    clr1 := Color gray:67.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2865
		    clr2 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2866
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2867
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2868
	    scaledGray1 := clr1 scaledRed.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2869
	    scaledGray2 := clr2 scaledRed.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2870
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2871
	    scaledGrey := (MaxValue * fraction) rounded.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2872
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2873
	    nGray := (1 bitShift:d) - 1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2874
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2875
	    "/ scale greyValue into grey levels
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2876
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2877
	    grayBelow := (fraction * nGray) truncated.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2878
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2879
	    grayBelow < 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2880
		^ Color black exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2881
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2882
	    grayBelow >= nGray ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2883
		^ Color white exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2884
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2885
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2886
	    scaledGrey := (MaxValue * fraction) rounded.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2887
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2888
	    step := MaxValue // nGray.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2889
	    scaledGray1 := grayBelow * step.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2890
	    scaledGray2 := scaledGray1 + step.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2891
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2892
	    clr1 := Color scaledGray:scaledGray1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2893
	    clr2 := Color scaledGray:scaledGray2.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2894
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2895
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2896
	"/ scale remainder in between low..high
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2897
	newFraction := (scaledGrey - scaledGray1) asFloat / (scaledGray2 - scaledGray1).
1707
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
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2900
    clr1 := clr1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2901
    clr2 := clr2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2902
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2903
    (clr1 isNil or:[clr2 isNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2904
	"/ fall back to b&w dither
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2905
	aDevice blackpixel == 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2906
	    clr1 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2907
	    clr2 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2908
	    newFraction := fraction.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2909
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2910
	    clr1 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2911
	    clr2 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2912
	    newFraction := 1 - fraction
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2913
	]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2914
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2915
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2916
    ^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2917
	monoDitherFor:newFraction
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2918
	between:clr1 and:clr2
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2919
	on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2920
	into:aBlock
1707
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
     Color basicNew
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2924
	ditherGrayFor:0.5
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2925
	on:Display
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2926
	into:[:clr :form | clr notNil ifTrue:[clr inspect].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2927
			   form notNil ifTrue:[(form magnifiedBy:16) inspect].]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2928
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2929
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2930
     Color basicNew
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2931
	ditherGrayFor:0.25
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2932
	on:Display
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2933
	into:[:clr :form | clr notNil ifTrue:[clr inspect].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2934
			   form notNil ifTrue:[(form magnifiedBy:16) inspect].]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2935
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2936
5779
def9764b9b8a changed: #ditherGrayFor:on:into:
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  2937
    "Created: / 03-05-1997 / 10:59:57 / cg"
def9764b9b8a changed: #ditherGrayFor:on:into:
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  2938
    "Modified: / 24-07-2011 / 07:18:00 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2939
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2940
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2941
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
  2942
    "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
  2943
     Returns 2 values (either color or ditherForm) through
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2944
     aBlock.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2945
     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
  2946
     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
  2947
     are handled"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2948
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2949
    |rh rl rs
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2950
     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
  2951
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2952
    "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
  2953
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2954
    Color withHLSFromScaledRed:rV scaledGreen:gV scaledBlue:bV do:[:hue :light :saturation |
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2955
        hue notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2956
            rh := (hue * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2957
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2958
        rl := (light * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2959
        rs := (saturation * 3.0) rounded / 3.0.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2960
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2961
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2962
    rh isNil ifTrue:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2963
        "achromatic,  dither between achromatic colors"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2964
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2965
        lowL := nil.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2966
        hiL := nil.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2967
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2968
        "find the 2 bounding colors"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2969
        aDevice deviceColors do:[:aColor |
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2970
            aColor colorId notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2971
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2972
                Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:hue :light :saturation |
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2973
                    | cl |
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2974
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2975
                    hue isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2976
                        cl := (light * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2977
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2978
                        cl > rl ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2979
                            hiL isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2980
                                hiL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2981
                                hiValL := cl.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2982
                            ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2983
                                cl < hiValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2984
                                    hiL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2985
                                    hiValL := cl.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2986
                                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2987
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2988
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2989
                            lowL isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2990
                                lowL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2991
                                lowValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2992
                            ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2993
                                cl > lowValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2994
                                    lowL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2995
                                    lowValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2996
                                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2997
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2998
                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  2999
                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3000
                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3001
            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3002
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3003
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3004
        (lowL notNil and:[hiL notNil]) ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3005
            ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3006
                monoDitherFor:1.0 / (hiValL - lowValL) * (rl - lowValL)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3007
                between:lowL and:hiL
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3008
                on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3009
                into:aBlock
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3010
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3011
        "cannot happen, should always find at least black and white"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3012
        'Color [info]: oops - color to dither is not bound by b&w' infoPrintCR.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3013
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3014
        ^ aBlock value:nil value:nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3015
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3016
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3017
    "chromatic case"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3018
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3019
    aDevice hasColors ifFalse:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3020
        "no chance, return nil values"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3021
        ^ aBlock value:nil value:nil
1707
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
    (Red isNil or:[Green isNil or:[Blue isNil]]) ifTrue:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3024
        "if we where not able to get primary colors: no chance"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3025
        ^ aBlock value:nil value:nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3026
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3027
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3028
    "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
  3029
     dither on light between those"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3030
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3031
    lowL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3032
    hiL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3033
    lowS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3034
    hiS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3035
    lowH := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3036
    hiH := nil.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3037
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3038
    aDevice deviceColors do:[:aColor |
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3039
        aColor colorId notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3040
            Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:hue :light :saturation |
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3041
                | cl ch cs|
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3042
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3043
                hue notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3044
                   ch := (hue * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3045
                ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3046
                   ch := nil
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3047
                ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3048
                cl := (light * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3049
                cs := (saturation * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3050
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3051
                ((ch = rh) and:[cs = rs]) ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3052
                    "found a color with same saturation and same hue, keep for light"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3053
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3054
                    cl > rl ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3055
                        hiL isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3056
                            hiL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3057
                            hiValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3058
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3059
                            cl < hiValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3060
                                hiL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3061
                                hiValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3062
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3063
                        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3064
                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3065
                        lowL isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3066
                            lowL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3067
                            lowValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3068
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3069
                            cl > lowValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3070
                                lowL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3071
                                lowValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3072
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3073
                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3074
                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3075
                ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3076
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3077
                (((ch = rh) or:[ch isNil]) and:[cl = rl]) ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3078
                    "found a color with same light and same hue, keep for saturation"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3079
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3080
                    cs > rs ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3081
                        hiS isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3082
                            hiS := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3083
                            hiValS := cs
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3084
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3085
                            cs < hiValS ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3086
                                hiS := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3087
                                hiValS := cs
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3088
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3089
                        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3090
                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3091
                        lowS isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3092
                            lowS := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3093
                            lowValS := cs
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3094
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3095
                            cs > lowValS ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3096
                                lowS := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3097
                                lowValS := cs
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3098
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3099
                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3100
                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3101
                ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3102
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3103
                rh notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3104
                    cl = rl ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3105
                        cs = rs ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3106
                            ch notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3107
                                d := (ch - rh) abs.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3108
                                d > 300 ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3109
                                    rh > 180 ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3110
                                        ch := ch + 360
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3111
                                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3112
                                        ch := ch - 360
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3113
                                    ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3114
                                ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3115
                                ch > rh ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3116
                                    hiH isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3117
                                        hiH := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3118
                                        hiValH := ch
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3119
                                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3120
                                        ch < hiValH ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3121
                                            hiH := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3122
                                            hiValH := ch
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3123
                                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3124
                                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3125
                                ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3126
                                    lowH isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3127
                                        lowH := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3128
                                        lowValH := ch
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3129
                                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3130
                                        ch > lowValH ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3131
                                            lowH := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3132
                                            lowValH := ch
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3133
                                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3134
                                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3135
                                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3136
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3137
                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3138
                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3139
                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3140
            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3141
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3142
    ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3143
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3144
    "found bounds for light ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3145
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3146
    lowL notNil ifTrue:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3147
        rl = lowValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3148
            ^ aBlock value:lowL value:nil
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3149
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3150
        hiL notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3151
            ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3152
                monoDitherFor:1.0 / (hiValL - lowValL) / (rl - lowValL)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3153
                between:lowL and:hiL
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3154
                on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3155
                into:aBlock
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3156
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3157
        "found bound for light - dither with white"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3158
        ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3159
            monoDitherFor:1.0 / (100 - lowValL) / (rl - lowValL)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3160
            between:lowL and:White
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3161
            on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3162
            into:aBlock
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3163
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3164
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3165
    "found bound for light - dither with black"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3166
    hiL notNil ifTrue:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3167
        ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3168
            monoDitherFor:1.0 / (hiValL) / (rl)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3169
            between:Black and:hiL
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3170
            on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3171
            into:aBlock
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3172
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3173
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3174
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3175
    "found bounds for saturation?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3176
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3177
    (lowS notNil and:[hiS notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3178
"
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3179
        'saturation dither' printNewline.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3180
"
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3181
        ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3182
            monoDitherFor:1.0 / (hiValS - lowValS) / (rs - lowValS)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3183
            between:lowS and:hiS
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3184
            on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3185
            into:aBlock
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3186
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3187
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3188
    "found bounds for hue ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3189
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3190
    (lowH notNil and:[hiH notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3191
"
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3192
        'hue dither' printNewline.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3193
"
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3194
        hiValH < lowValH ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3195
            hiValH := hiValH + 360
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3196
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3197
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3198
        d := hiValH - lowValH.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3199
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3200
        ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3201
            monoDitherFor:1.0 / (d / (rh - lowValH))
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3202
            between:lowH and:hiH
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3203
            on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3204
            into:aBlock
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3205
    ].
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
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3208
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3209
    "Modified: 3.5.1997 / 10:58:54 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3210
    "Created: 3.5.1997 / 11:02:03 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3211
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3212
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3213
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
  3214
    "get a dither form for an rgb value.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3215
     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
  3216
     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
  3217
     dither colors."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3218
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3219
    |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3220
     nR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3221
     nG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3222
     nB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3223
     hR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3224
     hG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3225
     hB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3226
     eR eG eB
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3227
     rI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3228
     gI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3229
     bI  "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3230
     idx "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3231
     f clr
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3232
     r    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3233
     g    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3234
     b    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3235
     x1   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3236
     x2   "{ Class: SmallInteger }"
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3237
     step "{ Class: SmallInteger }"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3238
     lastIdx mx
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3239
     dS   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3240
     cube|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3241
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3242
    (cube := aDevice fixColors) notNil ifTrue:[
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3243
        dS := 4.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3244
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3245
        f := Form width:dS height:dS depth:(aDevice depth) onDevice:aDevice.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3246
        f isNil ifTrue:[^ nil].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3247
        f initGC.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3248
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3249
        mx := MaxValue asFloat.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3250
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3251
        nR := aDevice numFixRed.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3252
        nG := aDevice numFixGreen.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3253
        nB := aDevice numFixBlue.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3254
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3255
        hR := nR // 2.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3256
        hG := nG // 2.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3257
        hB := nB // 2.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3258
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3259
        eR := eG := eB := 0.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3260
        r := redVal.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3261
        g := greenVal.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3262
        b := blueVal.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3263
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3264
        step := -1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3265
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3266
        0 to:dS-1 do:[:y |
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3267
            step == -1 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3268
                x1 := 0. x2 := dS-1. step := 1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3269
            ] ifFalse:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3270
                x1 := dS-1. x2 := 0. step := -1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3271
            ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3272
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3273
            x1 to:x2 by:step do:[:x |
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3274
                "/ the nearest along the grid
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3275
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3276
                r := redVal + eR.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3277
                r > MaxValue ifTrue:[r := MaxValue]
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3278
                             ifFalse:[r < 0 ifTrue:[r := 0]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3279
                g := greenVal + eG.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3280
                g > MaxValue ifTrue:[g := MaxValue]
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3281
                             ifFalse:[g < 0 ifTrue:[g := 0]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3282
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3283
                b := blueVal + eB.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3284
                b > MaxValue ifTrue:[b := MaxValue]
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3285
                             ifFalse:[b < 0 ifTrue:[b := 0]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3286
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3287
                rI := (r * (nR-1) + hR / mx) rounded.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3288
                gI := (g * (nG-1) + hG / mx) rounded .
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3289
                bI := (b * (nB-1) + hB / mx) rounded .
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3290
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3291
                idx := (((rI * nG) + gI) * nB + bI) + 1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3292
                clr := (cube at:idx) exactOn:aDevice.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3293
                lastIdx isNil ifTrue:[lastIdx := idx]
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3294
                ifFalse:[lastIdx ~~ idx ifTrue:[lastIdx := -1]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3295
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3296
                f foreground:clr.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3297
                f displayPointX:x y:y.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3298
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3299
                eR := r  - clr scaledRed.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3300
                eG := g  - clr scaledGreen.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3301
                eB := b  - clr scaledBlue.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3302
            ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3303
        ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3304
        f releaseGC.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3305
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3306
        lastIdx ~~ -1 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3307
            ^ aBlock value:clr value:nil
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3308
        ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3309
        ^ aBlock value:nil value:f
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3310
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3311
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3312
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3313
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3314
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3315
    "Modified: 11.7.1996 / 18:30:28 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3316
    "Created: 3.5.1997 / 11:03:18 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3317
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3318
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3319
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
  3320
    "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
  3321
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3322
     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
  3323
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3324
    |form c1 c2
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3325
     index "{ Class:SmallInteger }"|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3326
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3327
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3328
    "/ 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
  3329
    "/ 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
  3330
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3331
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3332
    index := (fraction * 64) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3333
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3334
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3335
    index < 1 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3336
	^ aBlock value:c1 value:nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3337
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3338
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3339
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3340
    index >= 64 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3341
	^ aBlock value:c2 value:nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3342
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3343
4772
be4524221fa7 Use Form class>>#width:height:fromArray:onDevice: instead of obsolete
Stefan Vogel <sv@exept.de>
parents: 4749
diff changeset
  3344
    form := Form width:8 height:8 fromArray:(DitherBits at:index) onDevice:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3345
    form colorMap:(Array with:c1 with:c2).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3346
    ^ aBlock value:nil value:form
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3347
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3348
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3349
     Color basicNew
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3350
	monoDitherFor:(MaxValue // 2)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3351
	between:Color black
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3352
	and:Color white
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3353
	on:Display
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3354
	into:[:clr :dither | clr inspect. dither inspect]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3355
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3356
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3357
    "Created: 3.5.1997 / 10:55:06 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3358
    "Modified: 3.5.1997 / 11:05:20 / cg"
1023
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
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3361
!Color class methodsFor:'queries'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3362
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3363
constantNames
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3364
    "return names known as instance creation messages"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3365
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3366
    ^ #(white black
6534
876e009486be class: Color
Claus Gittinger <cg@exept.de>
parents: 6385
diff changeset
  3367
        grey mediumGray veryLightGray lightGray darkGray veryDarkGray
876e009486be class: Color
Claus Gittinger <cg@exept.de>
parents: 6385
diff changeset
  3368
        red green blue cyan yellow pink orange magenta)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3369
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3370
    "Modified: 2.5.1996 / 11:34:05 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3371
!
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
scalingValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3374
    "ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3375
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3376
    ^ MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3377
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3378
    "Created: 2.5.1996 / 11:30:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3379
    "Modified: 11.7.1996 / 21:42:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3380
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3381
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3382
!Color class methodsFor:'special instance creation'!
1023
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
nearestColorRed:r green:g blue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3385
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3386
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3387
     If there is one, return it; nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3388
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3389
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3390
     vector distance (which may not be the best possible solution)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3391
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3392
    ^ self
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3393
	nearestColorScaledRed:(r * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3394
		  scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3395
		   scaledBlue:(b * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3396
			   on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3397
			   in:colors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3398
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3399
    "Modified: 11.6.1996 / 18:04:55 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3400
    "Created: 14.6.1996 / 20:05:13 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3401
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3402
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3403
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
  3404
    "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
  3405
     collection, containing colors from a colorCube.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3406
     This is used with preallocated fixColors and is quite fast
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3407
     (no need to search)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3408
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3409
    |sR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3410
     sG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3411
     sB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3412
     idx "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3413
     nR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3414
     nG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3415
     nB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3416
     rI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3417
     gI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3418
     bI  "{ Class: SmallInteger }"|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3419
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3420
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3421
     round to the step given by FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3422
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3423
    nR := nRed.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3424
    nG := nGreen.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3425
    nB := nBlue.
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
    sR := MaxValue // (nR - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3428
    sG := MaxValue // (nG - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3429
    sB := MaxValue // (nB - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3430
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3431
    rI := (r + (sR // 2)) // sR.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3432
    gI := (g + (sG // 2)) // sG.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3433
    bI := (b + (sB // 2)) // sB.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3434
    idx := (((rI * nG) + gI) * nB + bI) + 1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3435
    ^ aColorCube at:idx
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3436
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3437
    "Modified: 11.7.1996 / 17:52:46 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3438
    "Created: 11.7.1996 / 18:20:13 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3441
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3442
    "return a device color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3443
     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
  3444
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3445
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3446
     vector distance (which may not be the best possible solution)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3447
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3448
    |cube|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3449
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3450
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3451
     if there are preallocated colors, things are much easier ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3452
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3453
    (cube := aDevice fixColors) notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3454
	^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3455
	    nearestColorScaledRed:r
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3456
	    scaledGreen:g
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3457
	    scaledBlue:b
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3458
	    inCube:cube
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3459
	    numRed:(aDevice numFixRed)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3460
	    numGreen:(aDevice numFixGreen)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3461
	    numBlue:(aDevice numFixBlue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3462
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3463
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
     search in existing colors ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3466
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3467
    ^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3468
	nearestColorScaledRed:r
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3469
	scaledGreen:g
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3470
	scaledBlue:b
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3471
	on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3472
	in:aDevice deviceColors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3473
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3474
    "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
  3475
    "Modified: 24.2.1997 / 18:17:51 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3476
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3477
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3478
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3479
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3480
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3481
     If there is one, return it; nil otherwise."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3482
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3483
    |delta minDelta bestSoFar|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3484
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3485
    minDelta := 9999999.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3486
1619
4a7dbd25c588 handle the case where not even r/g/b primaries can be allocated
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3487
    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
  3488
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3489
    colors do:[:aColor |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3490
	|cr cg cb|
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3491
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3492
	(aDevice isNil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3493
	or:[(aColor graphicsDevice == aDevice)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3494
	    and:[aColor colorId notNil]]) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3495
		delta := aColor deltaFromScaledRed:r scaledGreen:g scaledBlue:b.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3496
		delta < minDelta ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3497
		    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3498
		     an exact fit - no need to continue search
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3499
		    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3500
		    delta == 0 ifTrue:[^ aColor].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3501
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3502
		    bestSoFar := aColor.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3503
		    minDelta := delta
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3504
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3505
	    ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3506
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3507
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3508
    ^ bestSoFar
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3509
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3510
    "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
  3511
    "Modified: / 28.7.1998 / 20:40:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3512
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3513
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3514
quickNearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3515
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3516
     same or near r/g/b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3517
     This looks for primary colors only and is thus faster
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3518
     than the general nearestColor search (slightly uglier though)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3519
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3520
    |cube|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3521
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3522
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3523
     if there are preallocated colors, things are much easier ...
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3524
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3525
    (cube := aDevice fixColors) notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3526
	^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3527
	    nearestColorScaledRed:r
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3528
	    scaledGreen:g
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3529
	    scaledBlue:b
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3530
	    inCube:cube
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3531
	    numRed:(aDevice numFixRed)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3532
	    numGreen:(aDevice numFixGreen)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3533
	    numBlue:(aDevice numFixBlue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3534
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3535
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3536
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3537
     search in existing colors ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3538
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3539
    ^ self nearestColorScaledRed:r
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3540
		     scaledGreen:g
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3541
		      scaledBlue:b
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3542
			on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3543
			in:(aDevice availableDitherColors)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3544
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3545
    "Created: 14.6.1996 / 20:13:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3546
    "Modified: 11.7.1996 / 18:20:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3547
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3548
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3549
!Color class methodsFor:'utilities'!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3550
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3551
allocateColorsIn:aColorVector on:aDevice
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3552
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3553
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3554
    "preallocates a nR x nG x nB colorMap for later use in dithering.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3555
     Doing so has the advantage that the system will never run out of colors,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3556
     however, colors may be either inexact or dithered."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3557
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3558
    |clr round devClr|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3559
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3560
    round := 0.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3561
    1 to:aColorVector size do:[:dstIndex |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3562
        clr := aColorVector at:dstIndex.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3563
        devClr := clr exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3564
        devClr isNil ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3565
            round == 0 ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3566
                Logger info:'scavenge to reclaim colors'.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3567
                ObjectMemory scavenge.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3568
                round := 1.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3569
                devClr := clr exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3570
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3571
            devClr isNil ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3572
                round == 1 ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3573
                    Logger info:'collect garbage to reclaim colors'.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3574
                    ObjectMemory 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3575
                        garbageCollect; finalize.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3576
                    round := 2.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3577
                    devClr := clr exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3578
                ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3579
                devClr isNil ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3580
                    round == 2 ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3581
                        Logger info:'lowSpaceCleanup and collect garbage to reclaim colors'.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3582
                        ObjectMemory 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3583
                            performLowSpaceCleanup;
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3584
                            garbageCollect; finalize.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3585
                        round := 3.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3586
                        devClr := clr exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3587
                    ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3588
                    devClr isNil ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3589
                        ColorAllocationFailSignal raiseErrorString:'failed to allocate fix color'.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3590
                        ^ self
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3591
                    ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3592
                ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3593
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3594
        ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3595
        aColorVector at:dstIndex put:devClr.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3596
    ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3597
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3598
    "Modified: / 02-03-2017 / 17:43:36 / stefan"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3599
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3600
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3601
best:numColors ditherColorsForImage:anImage 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3602
    "work in progress"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3603
    
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3604
    |cube boxMaxR boxMaxG boxMaxB numBitsR numBitsG numBitsB numGray usedColors 
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3605
     minRed maxRed minGreen maxGreen minBlue maxBlue
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3606
     boundaryColors boxesAlreadySegmented segments boxesToDo enumerateNeighbors
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3607
     firstTry segmentColors|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3608
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3609
    ((anImage photometric == #blackIs0) or:[anImage photometric == #whiteIs0]) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3610
        numGray := (1 bitShift:anImage depth) min:numColors. 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3611
        ^ self grayColorVector:numGray
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3612
    ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3613
    (anImage photometric == #palette) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3614
        "/ all gray?
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3615
        (anImage colorMap conform:[:clr | clr isGrayColor]) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3616
            numGray := ((1 bitShift:anImage depth) min:anImage colorMap size) min:numColors. 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3617
            ^ self grayColorVector:numGray
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3618
        ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3619
    ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3620
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3621
    numBitsR := 7.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3622
    numBitsG := 8.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3623
    numBitsB := 5.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3624
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3625
    firstTry := true.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3626
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3627
    [
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3628
        boxMaxR := (1 << numBitsR) - 1.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3629
        boxMaxG := (1 << numBitsG) - 1.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3630
        boxMaxB := (1 << numBitsB) - 1.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3631
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3632
        cube := IntegerArray new:(boxMaxR+1)*(boxMaxG+1)*(boxMaxB+1).
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3633
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3634
        firstTry ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3635
            usedColors := Set new.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3636
            minRed := minGreen := minBlue := 255.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3637
            maxRed := maxGreen := maxBlue := 0.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3638
        ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3639
        
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3640
        anImage 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3641
            rgbValuesFromX:0 y:0 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3642
            toX:(anImage width-1) y:(anImage height-1)
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3643
            do:[:x :y :rgb |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3644
                |redByte greenByte blueByte r g b idx oldCount|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3645
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3646
                redByte := (rgb rightShift:16) bitAnd:16rFF.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3647
                greenByte := (rgb rightShift:8) bitAnd:16rFF.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3648
                blueByte := (rgb) bitAnd:16rFF.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3649
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3650
                r := redByte rightShift:(8-numBitsR).
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3651
                g := greenByte rightShift:(8-numBitsG).
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3652
                b := blueByte rightShift:(8-numBitsB).
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3653
                idx := (((r * (boxMaxG+1))+g)*(boxMaxB+1))+b+1.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3654
                oldCount := cube at:idx.
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3655
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3656
                firstTry ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3657
                    redByte < minRed ifTrue:[minRed := redByte] ifFalse:[redByte > maxRed ifTrue:[maxRed := redByte]].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3658
                    greenByte < minGreen ifTrue:[minGreen := greenByte] ifFalse:[greenByte > maxGreen ifTrue:[maxGreen := greenByte]].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3659
                    blueByte < minBlue ifTrue:[minBlue := blueByte] ifFalse:[blueByte > maxBlue ifTrue:[maxBlue := blueByte]].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3660
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3661
                    oldCount == 0 ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3662
                        usedColors add:rgb.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3663
                    ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3664
                ].    
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3665
                cube at:idx put:oldCount+1.
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3666
            ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3667
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3668
        firstTry ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3669
            usedColors size <= numColors ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3670
                "/ huh - that will be easy!!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3671
                ^ usedColors asArray.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3672
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3673
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3674
            "/ if not even the basic colors fit, dither to b&w
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3675
            numColors == 2 ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3676
                ^ { Color black . Color white }
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3677
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3678
            "/ if not even the basic colors fit, dither to b&w
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3679
            numColors == 4 ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3680
                ^ { Color black . Color red . Color green . Color blue. }
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3681
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3682
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3683
            "/ we need the at least the 8 corners for dithering, at least...
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3684
            boundaryColors := OrderedCollection new.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3685
            { minRed . maxRed } do:[:r |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3686
                { minGreen . maxGreen } do:[:g |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3687
                    { minBlue . maxBlue } do:[:b |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3688
                        boundaryColors add:(Color redByte:r greenByte:g blueByte:b)
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3689
                    ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3690
                ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3691
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3692
            numColors == 8 ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3693
                ^ boundaryColors
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3694
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3695
        ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3696
        firstTry := false.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3697
        
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3698
        "/
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3699
        "/ find and generate connected subarea box sets
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3700
        "/
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3701
        boxesAlreadySegmented := Set new.
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3702
        segments := OrderedCollection new.    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3703
        boxesToDo := OrderedCollection new.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3704
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3705
        "/ each box has 9+9+3+3+1+1 neighbors
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3706
        "/ 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3707
        enumerateNeighbors :=
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3708
            [:rgb :aBlock|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3709
                |r g b|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3710
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3711
                r := (rgb rightShift:(numBitsG+numBitsB)) bitAnd:boxMaxR.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3712
                g := (rgb rightShift:numBitsB) bitAnd:boxMaxG.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3713
                b := (rgb) bitAnd:boxMaxB.
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3714
                r-1 to:r+1 do:[:n_r |
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3715
                    (n_r between:0 and:boxMaxR) ifTrue:[
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3716
                        g-1 to:g+1 do:[:n_g |
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3717
                            (n_g between:0 and:boxMaxG) ifTrue:[
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3718
                                b-1 to:b+1 do:[:n_b |
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3719
                                    (n_b between:0 and:boxMaxB) ifTrue:[
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3720
                                        ((n_r == r) and:[n_g == g and:[n_b == b]]) ifFalse:[
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3721
                                            aBlock value:((((n_r * (boxMaxG+1))+n_g)*(boxMaxB+1))+n_b).
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3722
                                        ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3723
                                    ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3724
                                ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3725
                            ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3726
                        ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3727
                    ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3728
                ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3729
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3730
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3731
        0 to:boxMaxR do:[:r |
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3732
            0 to:boxMaxG do:[:g |
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3733
                0 to:boxMaxB do:[:b |
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3734
                    |rgb|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3735
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3736
                    rgb := (((r * (boxMaxG+1))+g)*(boxMaxB+1))+b.
8137
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3737
                    ((cube at:rgb+1) ~~ 0 
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3738
                     and:[(boxesAlreadySegmented includes:rgb) not]) ifTrue:[
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3739
                        |currentSegment|
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3740
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3741
                        "/ start a segment
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3742
                        currentSegment := OrderedCollection new.
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3743
                        segments add:currentSegment.
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3744
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3745
                        boxesToDo add:rgb.
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3746
                        boxesAlreadySegmented add:rgb.
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3747
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3748
                        [boxesToDo notEmpty] whileTrue:[
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3749
                            |lastRgb|
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3750
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3751
                            lastRgb := boxesToDo removeLast.
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3752
                            currentSegment add:lastRgb.
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3753
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3754
                            enumerateNeighbors
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3755
                                    value:lastRgb 
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3756
                                    value:[:n_rgb |
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3757
                                        (cube at:n_rgb+1) ~~ 0 ifTrue:[
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3758
                                            "/ neighbor has used pixels as well...
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3759
                                            (boxesAlreadySegmented includes:n_rgb) ifFalse:[
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3760
                                                "/ neighbor was not processed...
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3761
                                                boxesAlreadySegmented add:lastRgb.
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3762
                                                boxesToDo add:n_rgb.
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3763
                                            ].
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3764
                                        ].    
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3765
                                    ].
4d18d8b42894 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8126
diff changeset
  3766
                        ].
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3767
                    ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3768
                ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3769
            ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3770
        ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3771
        
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3772
        (segments size < numColors) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3773
            segmentColors := segments 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3774
                                collect:[:eachSegment |
8125
4deac40e67b0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8123
diff changeset
  3775
                                    |sumWeight sumRed sumGreen sumBlue centerRed centerGreen centerBlue|
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3776
                                    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3777
                                    "/ compute central point
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3778
                                    "/ as center of mass (taking count per box as weight)
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3779
                                    "/ this central point will be placed into the colormap.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3780
                                    sumRed := sumGreen := sumBlue := 0.
8125
4deac40e67b0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8123
diff changeset
  3781
4deac40e67b0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8123
diff changeset
  3782
                                    sumWeight := 0.
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3783
                                    eachSegment do:[:rgbOfBoxInSegment |
8125
4deac40e67b0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8123
diff changeset
  3784
                                        |r g b idx count|
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3785
                                        
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3786
                                        r := (rgbOfBoxInSegment rightShift:(numBitsG+numBitsB)) bitAnd:boxMaxR.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3787
                                        g := (rgbOfBoxInSegment rightShift:numBitsB) bitAnd:boxMaxG.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3788
                                        b := (rgbOfBoxInSegment) bitAnd:boxMaxB.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3789
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3790
                                        idx := (((r * (boxMaxG+1))+g)*(boxMaxB+1))+b+1.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3791
                                        count := cube at:idx.
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3792
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3793
                                        sumRed := sumRed + (r * count).
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3794
                                        sumGreen := sumGreen + (g * count).
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3795
                                        sumBlue := sumBlue + (b * count).
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3796
                                        
8125
4deac40e67b0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8123
diff changeset
  3797
                                        sumWeight := sumWeight + count. 
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3798
                                    ].
8125
4deac40e67b0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8123
diff changeset
  3799
                                    centerRed := (sumRed / sumWeight) rounded.
4deac40e67b0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8123
diff changeset
  3800
                                    centerGreen := (sumGreen / sumWeight) rounded.
4deac40e67b0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8123
diff changeset
  3801
                                    centerBlue := (sumBlue / sumWeight) rounded.
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3802
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3803
                                    centerRed := (centerRed bitShift:(8-numBitsR))
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3804
                                                 bitOr:(centerRed bitShift:(8-numBitsR-numBitsR)). 
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3805
                                    centerGreen := (centerGreen bitShift:(8-numBitsG))
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3806
                                                 bitOr:(centerGreen bitShift:(8-numBitsG-numBitsG)). 
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3807
                                    centerBlue := (centerBlue bitShift:(8-numBitsB))
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3808
                                                 bitOr:(centerBlue bitShift:(8-numBitsB-numBitsB)). 
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3809
                                    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3810
                                    Color redByte:centerRed greenByte:centerGreen blueByte:centerBlue.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3811
                                ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3812
                                as:OrderedCollection.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3813
            "/ can we add black & white?
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3814
            (segmentColors includes:Color white) ifFalse:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3815
                segmentColors add:Color white.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3816
            ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3817
            (segmentColors includes:Color black) ifFalse:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3818
                segmentColors add:Color black.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3819
            ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3820
            "/ can we add the boundary colors?
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3821
            boundaryColors do:[:each |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3822
                (segmentColors size < numColors) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3823
                    (segmentColors includes:each) ifFalse:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3824
                        segmentColors add:each.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3825
                    ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3826
                ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3827
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3828
            ^ segmentColors.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3829
        ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3830
        
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3831
        numBitsR > 2 ifTrue:[ numBitsR := numBitsR - 1 ].
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3832
        numBitsG > 2 ifTrue:[ numBitsG := numBitsG - 1 ].
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3833
        numBitsB > 2 ifTrue:[ numBitsB := numBitsB - 1 ].
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3834
        
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3835
        ((numBitsR == 0) or:[numBitsG == 0 or:[numBitsB == 0]]) ifTrue:[
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3836
            self error.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3837
        ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3838
    ] loop.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3839
    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3840
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3841
     Color
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3842
        best:16 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3843
        ditherColorsForImage:(Image fromFile:'../../goodies/bitmaps/pcxImages/lena_depth8_palette.pcx')
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3844
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3845
     Color
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3846
        best:16 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3847
        ditherColorsForImage:(Image fromFile:'../../goodies/bitmaps/pcxImages/lena_depth24_rgb.pcx')
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3848
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3849
     Color
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3850
        best:16 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3851
        ditherColorsForImage:((Image fromFile:'../../goodies/bitmaps/pcxImages/lena_depth8_palette.pcx') asGrayImageDepth:8)
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3852
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3853
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3854
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3855
    "Created: / 29-08-2017 / 14:31:19 / cg"
8126
10c304b0f4db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8125
diff changeset
  3856
    "Modified: / 29-08-2017 / 21:53:47 / cg"
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3857
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3858
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3859
browserColors
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3860
    "return the palette, known as 'the color cube', 'the Netscape palette',
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3861
     or 'the Browser-Safe palette'.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3862
     This is familiar to all seasoned Web designers and graphics production specialists;
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3863
     Use this map for low-color-res depth 8 (gif-) images, if old pseudo displays are to be
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3864
     supported."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3865
     
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3866
    ^ self colorCubeWithRed:6 green:6 blue:6.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3867
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3868
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3869
     |img|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3870
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3871
     img := Image width:(8*6*6)+1 height:(8*6)+1 depth:8.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3872
     img colorMap:(Color browserColors). 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3873
     img pixelFunction:
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3874
         [:x :y |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3875
            |r g b|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3876
            
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3877
            (y \\ 8 == 0 ) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3878
                86
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3879
            ] ifFalse:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3880
                x \\ 8 == 0 ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3881
                    86
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3882
                ] ifFalse:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3883
                    r := g := b := 0.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3884
                    'y is green component'.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3885
                    g := 5-(y // 8).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3886
                    'x inside subsquare is blue component'.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3887
                    b := (x \\ (8*6)) // 8.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3888
                    'subsquare is red component'.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3889
                    r := (x // (8*6)).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3890
                    ((r*6)+g)*6+b
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3891
                ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3892
            ].    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3893
         ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3894
     img inspect. 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3895
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3896
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3897
    "Created: / 29-08-2017 / 17:01:23 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3898
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3899
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3900
colorCubeWithRed:nRed green:nGreen blue:nBlue
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3901
    "given a number of red, green and blue shades,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3902
     return a color cube (map) containing those colors.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3903
     Eg, return a map containing any combination of the
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3904
     nRed, nGreen and nBlue shades.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3905
     This is used for dithering of deep images onto limited-depth canvases
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3906
     for example: with nRed,nGreen,nBlue == 2,3,2
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3907
      you will get a cube of 2*3*2 = 12 colors, with two shades of red (0 and 255),
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3908
      threed shades of green (0, 127 and 255) and two shades of blue (0 and 255)."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3909
    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3910
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3911
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3912
    |nR "{Class: SmallInteger }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3913
     nG "{Class: SmallInteger }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3914
     nB "{Class: SmallInteger }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3915
     dR dG dB red green blue dstIndex clr round
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3916
     colorCube|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3917
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3918
    nR := nRed.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3919
    nG := nGreen.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3920
    nB := nBlue.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3921
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3922
    dR := 100.0 / (nR - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3923
    dG := 100.0 / (nG - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3924
    dB := 100.0 / (nB - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3925
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3926
    colorCube := Array new:(nR * nG * nB).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3927
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3928
    round := 0.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3929
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3930
    dstIndex := 1.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3931
    1 to:nR do:[:sR |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3932
        red := dR * (sR - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3933
        1 to:nG do:[:sG |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3934
            green := dG * (sG - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3935
            1 to:nB do:[:sB |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3936
                blue := dB * (sB - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3937
                clr := self red:red green:green blue:blue.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3938
                colorCube at:dstIndex put:clr.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3939
                dstIndex := dstIndex + 1
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3940
            ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3941
        ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3942
    ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3943
    ^ colorCube
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3944
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3945
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3946
     Color colorCubeWithRed:2 green:2 blue:2
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3947
     Color colorCubeWithRed:2 green:3 blue:2
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3948
     Color colorCubeWithRed:3 green:4 blue:3
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3949
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3950
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3951
    "Created: / 11-07-1996 / 17:55:32 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3952
    "Modified: / 10-01-1997 / 15:37:13 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3953
    "Modified (comment): / 29-08-2017 / 14:27:58 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3954
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3955
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3956
flushDeviceColors
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3957
    "unassign all colors from their device"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3958
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3959
    self allInstances do:[:aColor |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3960
	aColor restored
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3961
    ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3962
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3963
    "Modified: 24.2.1997 / 18:27:06 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3964
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3965
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3966
flushDeviceColorsFor:aDevice
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3967
    self allInstancesDo:[:aColor |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3968
	aColor device == aDevice ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3969
	    aColor restored
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3970
	]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3971
    ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3972
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3973
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3974
getColors6x6x4
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3975
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3976
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3977
    "preallocates a 6x6x4 (144) colorMap and later uses those colors only
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3978
     on a palette display (pseudoColor visual).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3979
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3980
     Doing so has the advantage that the system will never run out of colors,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3981
     however, colors may be either inexact or dithered."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3982
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3983
    self getColorsRed:6 green:6 blue:4
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3984
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3985
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3986
     Color getColors6x6x4
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3987
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3988
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3989
    "Modified (comment): / 29-08-2017 / 17:22:22 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3990
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3991
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3992
getColors6x6x5
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3993
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3994
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3995
    "preallocates a 6x6x5 (180) colorMap and later uses those colors only
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3996
     on a palette display (pseudoColor visual).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3997
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3998
     Doing so has the advantage that the system will never run out of colors,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  3999
     however, colors may be either inexact or dithered."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4000
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4001
    self getColorsRed:6 green:6 blue:5
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4002
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4003
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4004
     Color getColors6x6x5
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4005
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4006
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4007
    "Modified (comment): / 29-08-2017 / 17:22:17 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4008
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4009
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4010
getColors6x6x6
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4011
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4012
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4013
    "preallocates a 6x6x6 (196) colorMap and later uses those colors only
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4014
     on a palette display (pseudoColor visual).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4015
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4016
     Doing so has the advantage that the system will never run out of colors,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4017
     however, colors may be either inexact or dithered."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4018
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4019
    self getColorsRed:6 green:6 blue:6
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4020
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4021
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4022
     Color getColors6x6x6
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4023
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4024
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4025
    "Modified (comment): / 29-08-2017 / 17:22:10 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4026
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4027
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4028
getColors6x7x4
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4029
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4030
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4031
    "preallocates a 6x7x4 (168) colorMap and later uses those colors only
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4032
     on a palette display (pseudoColor visual).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4033
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4034
     Doing so has the advantage that the system will never run out of colors,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4035
     however, colors may be either inexact or dithered."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4036
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4037
    self getColorsRed:6 green:7 blue:4
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4038
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4039
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4040
     Color getColors6x7x4
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4041
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4042
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4043
    "Created: / 12-06-1996 / 17:41:57 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4044
    "Modified (comment): / 29-08-2017 / 17:22:04 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4045
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4046
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4047
getColors7x8x4
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4048
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4049
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4050
    "preallocates a 7x8x4 (224) colorMap and later uses those colors only
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4051
     on a palette display (pseudoColor visual).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4052
     
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4053
     Doing so has the advantage that the system will never run out of colors,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4054
     however, colors may be either inexact or dithered."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4055
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4056
    self getColorsRed:7 green:8 blue:4
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4057
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4058
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4059
     Color getColors7x8x4
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4060
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4061
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4062
    "Modified (comment): / 29-08-2017 / 17:21:56 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4063
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4064
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4065
getColorsRed:nRed green:nGreen blue:nBlue
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4066
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4067
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4068
    "preallocates a nR x nG x nB colorMap for later use in dithering
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4069
     on a palette display (pseudoColor visual).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4070
     
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4071
     Doing so has the advantage that the system will never run out of colors,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4072
     however, colors may be either inexact or dithered."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4073
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4074
    self getColorsRed:nRed green:nGreen blue:nBlue on:Screen current
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4075
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4076
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4077
     Color getColorsRed:2 green:2 blue:2
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4078
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4079
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4080
    "Modified: / 11-07-1996 / 17:58:09 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4081
    "Modified (comment): / 29-08-2017 / 16:47:34 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4082
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4083
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4084
getColorsRed:nRed green:nGreen blue:nBlue on:aDevice
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4085
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4086
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4087
    "preallocates a nR x nG x nB colorMap for later use in dithering
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4088
     on a palette display (pseudoColor visual).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4089
     
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4090
     Doing so has the advantage that the system will never run out of colors,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4091
     however, colors may be either inexact or dithered."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4092
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4093
    |nR "{Class: SmallInteger }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4094
     nG "{Class: SmallInteger }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4095
     nB "{Class: SmallInteger }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4096
     dR dG dB fixColors|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4097
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4098
    aDevice visualType == #TrueColor ifTrue:[^ self].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4099
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4100
    nR := nRed.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4101
    nG := nGreen.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4102
    nB := nBlue.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4103
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4104
    dR := 100.0 / (nR - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4105
    dG := 100.0 / (nG - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4106
    dB := 100.0 / (nB - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4107
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4108
    fixColors := self colorCubeWithRed:nRed green:nGreen blue:nBlue.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4109
    self allocateColorsIn:fixColors on:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4110
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4111
    aDevice setFixColors:fixColors numRed:nR numGreen:nG numBlue:nB
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4112
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4113
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4114
     Color getColorsRed:2 green:2 blue:2 on:Display
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4115
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4116
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4117
    "Created: / 11-07-1996 / 17:55:32 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4118
    "Modified: / 10-01-1997 / 15:37:13 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4119
    "Modified (comment): / 29-08-2017 / 16:47:38 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4120
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4121
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4122
getGrayColors:nGray on:aDevice
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4123
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4124
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4125
    "preallocates nGray gray colors for later use in dithering
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4126
     on a palette display (pseudoColor visual).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4127
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4128
     Doing so has the advantage that the system will never run out of colors,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4129
     however, colors may be either inexact or dithered."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4130
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4131
    |nG "{Class: SmallInteger }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4132
     d fixGrayColors|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4133
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4134
    aDevice visualType == #TrueColor ifTrue:[^ self].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4135
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4136
    nG := nGray.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4137
    d := 100.0 / (nG - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4138
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4139
    fixGrayColors := self grayColorVector:nGray.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4140
    self allocateColorsIn:fixGrayColors on:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4141
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4142
    aDevice setFixGrayColors:fixGrayColors
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4143
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4144
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4145
     Color getGrayColors:16 on:Display
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4146
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4147
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4148
    "Created: / 23-06-1997 / 15:29:50 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4149
    "Modified (comment): / 29-08-2017 / 17:23:18 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4150
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4151
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4152
getPrimaryColorsOn:aDevice
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4153
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4154
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4155
    "preallocate the primary colors on a palette display (pseudoColor visual).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4156
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4157
     Doing so during early startup prevents us from running out
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4158
     of (at least those required) colors later.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4159
     This guarantees, that at least some colors are available
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4160
     for dithering (although, with only black, white, red, green and blue,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4161
     dithered images look very poor)."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4162
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4163
    |colors white black red green blue clr dDepth
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4164
     lastPix "{ Class: SmallInteger }" |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4165
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4166
    (aDevice notNil and:[aDevice ditherColors isNil]) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4167
        white := (self red:100 green:100 blue:100) exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4168
        white colorId isNil ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4169
            'Color [warning]: cannot allocate white color' errorPrintCR.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4170
        ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4171
        black := (self red:0 green:0 blue:0) exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4172
        black colorId isNil ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4173
            'Color [warning]: cannot allocate black color' errorPrintCR.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4174
        ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4175
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4176
        aDevice hasColors ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4177
            red := (self red:100 green:0 blue:0) exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4178
            green := (self red:0 green:100 blue:0) exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4179
            blue := (self red:0 green:0 blue:100) exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4180
            (red isNil
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4181
            or:[green isNil
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4182
            or:[blue isNil
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4183
            or:[red colorId isNil
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4184
            or:[green colorId isNil
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4185
            or:[blue colorId isNil]]]]]) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4186
                'Color [warning]: cannot allocate primary color(s)' errorPrintCR.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4187
                dDepth := aDevice depth.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4188
                ((dDepth >= 4) and:[dDepth <= 8]) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4189
                    "/
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4190
                    "/ see what we have ...
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4191
                    "/
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4192
                    lastPix := (1 bitShift:dDepth) - 1.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4193
                    0 to:lastPix do:[:pixel |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4194
                        colors := OrderedCollection new.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4195
                        aDevice getRGBFrom:pixel into:[:r :g :b |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4196
                            colors add:((Color red:r green:g blue:b) exactOn:aDevice).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4197
                        ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4198
                    ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4199
                    red := (self red:100 green:0 blue:0) nearestOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4200
                    green := (self red:0 green:100 blue:0) nearestOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4201
                    blue := (self red:0 green:0 blue:100) nearestOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4202
                ] ifFalse:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4203
                    aDevice hasColors:false.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4204
                    aDevice hasGrayscales:false.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4205
                    red := green := blue := nil.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4206
                ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4207
            ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4208
        ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4209
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4210
        aDevice == Display ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4211
            "/ keep those around for the main display
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4212
            White := white.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4213
            Black := black.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4214
            Red := red.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4215
            Green := green.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4216
            Blue := blue
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4217
        ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4218
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4219
        aDevice visualType ~~ #TrueColor ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4220
            aDevice hasColors ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4221
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4222
                "preallocate some colors for dithering
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4223
                 - otherwise, they may not be available when we need them ...
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4224
                 these are: black, white, grey50,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4225
                            red, green, blue, yellow, cyan and magenta.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4226
                "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4227
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4228
                colors := OrderedCollection new.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4229
                clr := (self gray:50) exactOn:aDevice.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4230
                (clr notNil and:[clr colorId notNil]) ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4231
                    colors add:clr
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4232
                ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4233
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4234
                colors add:white; add:black; add:red; add:green; add:blue.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4235
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4236
                colors add:((self red:100 green:100 blue:0) exactOn:aDevice).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4237
                colors add:((self red:100 green:0 blue:100) exactOn:aDevice).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4238
                colors add:((self red:0 green:100 blue:100) exactOn:aDevice).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4239
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4240
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4241
            aDevice hasGrayscales ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4242
                aDevice hasColors ifFalse:[
8285
fcec3749083e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8277
diff changeset
  4243
                    colors := 
fcec3749083e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8277
diff changeset
  4244
                        OrderedCollection 
fcec3749083e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8277
diff changeset
  4245
                            with:((self gray:50) exactOn:aDevice)
fcec3749083e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8277
diff changeset
  4246
                            with:white
fcec3749083e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8277
diff changeset
  4247
                            with:black.
8123
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4248
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4249
                ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4250
                colors add:((self gray:25) exactOn:aDevice).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4251
                colors add:((self gray:33) exactOn:aDevice).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4252
                colors add:((self gray:67) exactOn:aDevice).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4253
                colors add:((self gray:75) exactOn:aDevice).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4254
            ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4255
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4256
            colors notNil ifTrue:[
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4257
                colors := colors select:[:clr | clr notNil and:[clr colorId notNil]].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4258
                aDevice setDitherColors:(colors asArray).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4259
            ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4260
        ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4261
    ]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4262
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4263
    "Created: / 11-07-1996 / 18:09:28 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4264
    "Modified: / 21-10-1997 / 02:42:28 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4265
    "Modified (comment): / 29-08-2017 / 17:23:36 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4266
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4267
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4268
grayColorVector:nGray
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4269
    |nG "{Class: SmallInteger }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4270
     d gray dstIndex clr round
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4271
     grayColors|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4272
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4273
    nG := nGray.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4274
    d := 100.0 / (nG - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4275
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4276
    grayColors := Array new:nG.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4277
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4278
    round := 0.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4279
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4280
    dstIndex := 1.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4281
    1 to:nG do:[:sG |
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4282
	gray := d * (sG - 1).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4283
	clr := self red:gray green:gray blue:gray.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4284
	grayColors at:dstIndex put:clr.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4285
	dstIndex := dstIndex + 1
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4286
    ].
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4287
    ^ grayColors
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4288
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4289
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4290
     Color getGrayColors:16 on:Display
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4291
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4292
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4293
    "Created: 23.6.1997 / 15:29:50 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4294
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4295
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4296
standardDitherColorsForDepth8
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4297
    "return a set of colors useful for dithering (roughly 200 colors);
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4298
     This includes a color cube and the main grayScale colors."
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4299
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4300
    |ditherColors|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4301
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4302
    ditherColors := self colorCubeWithRed:6 green:8 blue:4.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4303
    ditherColors := ditherColors ,
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4304
                        ( #(10 20 25 30 40 50 60 70 75 80 90) 
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4305
                            collect:[:grayPercent | Color gray:grayPercent]
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4306
                            thenSelect:[:grey | (ditherColors includes:grey) not] )
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4307
                        asArray.    
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4308
    ^ ditherColors
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4309
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4310
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4311
     self standardDitherColorsForDepth8
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4312
    "
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4313
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4314
    "Modified: / 29-08-2017 / 17:29:58 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4315
!
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4316
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4317
vgaColors
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4318
    "{ Pragma: +optSpace }"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4319
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4320
    |colors|
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4321
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4322
    colors := Array new:16.
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4323
    colors at:1 put:(Color rgbValue:16rFFFFFF).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4324
    colors at:2 put:(Color rgbValue:16rC0C0C0).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4325
    colors at:3 put:(Color rgbValue:16r808080).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4326
    colors at:4 put:(Color rgbValue:16r000000).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4327
    colors at:5 put:(Color rgbValue:16rFF0000).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4328
    colors at:6 put:(Color rgbValue:16r800000).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4329
    colors at:7 put:(Color rgbValue:16r008000).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4330
    colors at:8 put:(Color rgbValue:16r00FF00).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4331
    colors at:9 put:(Color rgbValue:16r0000FF).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4332
    colors at:10 put:(Color rgbValue:16r000080).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4333
    colors at:11 put:(Color rgbValue:16rFF00FF).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4334
    colors at:12 put:(Color rgbValue:16r800080).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4335
    colors at:13 put:(Color rgbValue:16rFFFF00).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4336
    colors at:14 put:(Color rgbValue:16r808000).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4337
    colors at:15 put:(Color rgbValue:16r00FFFF).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4338
    colors at:16 put:(Color rgbValue:16r008080).
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4339
    ^ colors
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4340
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4341
    "Created: / 07-07-2006 / 13:36:15 / cg"
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4342
! !
099bb6b94798 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8112
diff changeset
  4343
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3878
diff changeset
  4344
!Color methodsFor:'Compatibility-ST80'!
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4345
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4346
asDevicePaintOn:aDevice
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4347
    "ST-80 compatibility: an alias for on:.
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4348
     create a new Color representing the same color as
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4349
     myself on aDevice; if one already exists, return the one"
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4350
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  4351
    ^ self onDevice:aDevice
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4352
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4353
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4354
asHiliteColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4355
    "same as lightened - for ST-80 compatibility"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4356
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4357
    ^ self lightened
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4358
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4359
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4360
asShadowColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4361
    "same as darkened - for ST-80 compatibility"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4362
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4363
    ^ self darkened
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4364
! !
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4365
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3878
diff changeset
  4366
!Color methodsFor:'Compatibility-Squeak'!
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4367
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4368
alphaMixed: proportion with: aColor
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4369
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4370
     Answer this color mixed with the given color. The proportion, a number
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4371
     between 0.0 and 1.0, determines what what fraction of the receiver to
8165
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  4372
     use in the mix. 
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  4373
     For example, 1.0 yields the receiver, 0.0 yields aColor
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  4374
     and 0.9 would yield a color close to the receiver. 
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  4375
     This method uses RGB interpolation; 
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  4376
     HSV interpolation can lead to surprises.  
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  4377
     Mixes the alphas (for transparency) also."
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4378
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4379
    | frac1 frac2 |
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4380
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4381
    frac1 := proportion asFloat min: 1.0 max: 0.0.
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4382
    frac2 := 1.0 - frac1.
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4383
    ^ self class
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4384
        r: ((red * frac1) + (aColor scaledRed * frac2)) / MaxValue
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4385
        g: ((green * frac1) + (aColor scaledGreen * frac2)) / MaxValue
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4386
        b: ((blue * frac1) + (aColor scaledBlue * frac2)) / MaxValue
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4387
        alpha: (self alpha * frac1) + (aColor alpha * frac2)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4388
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4389
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4390
     (Color r:1 g:0 b:0 alpha:1) alphaMixed:0.5 with:(Color r:1 g:0 b:0 alpha:1)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4391
     (Color r:1 g:0 b:0 alpha:0.5) alphaMixed:0.5 with:(Color r:0 g:1 b:0 alpha:0.5)
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4392
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4393
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4394
    "Created: / 06-06-2007 / 10:53:25 / cg"
8165
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  4395
    "Modified (comment): / 05-09-2017 / 14:38:23 / cg"
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4396
!
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4397
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4398
bitPatternForDepth: depth
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4399
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4400
     Return a Bitmap, possibly containing a stipple pattern,
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4401
     that best represents this color at the given depth.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4402
     BitBlt calls this method to convert colors into Bitmaps.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4403
     The resulting Bitmap may be multiple words to represent a stipple
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4404
     pattern of several lines.  "
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4405
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4406
    "See also:
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4407
        pixelValueAtDepth:      -- value for single pixel
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4408
        pixelWordAtDepth:       -- a 32-bit word filled with the pixel value"
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4409
    "Details: The pattern for the most recently requested depth is cached."
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4410
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4411
^ self.
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4412
"/    depth == cachedDepth ifTrue: [^ cachedBitPattern].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4413
"/    cachedDepth _ depth.
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4414
"/
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4415
"/    depth > 2 ifTrue: [^ cachedBitPattern _ Bitmap with: (self pixelWordForDepth: depth)].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4416
"/    depth = 1 ifTrue: [^ cachedBitPattern _ self halfTonePattern1].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4417
"/    depth = 2 ifTrue: [^ cachedBitPattern _ self halfTonePattern2].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4418
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4419
    "Modified (comment): / 03-02-2017 / 11:38:04 / cg"
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4420
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4421
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4422
colorForInsets
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4423
    "Squeak compatibility - dummy"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4424
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4425
    ^ self
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4426
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4427
    "Modified (comment): / 03-02-2017 / 11:38:24 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4428
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4429
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4430
darker
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4431
    "Squeak compatibility;
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4432
     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
  4433
     Almost the same as darkened for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4434
8047
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4435
    ^ self mixed:1 with:Black
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4436
    "/ ^ self mixed:0.8333 with:Black
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4437
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4438
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4439
     (Color red) darker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4440
     (Color red) muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4441
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4442
8047
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4443
    "Modified: / 05-07-2017 / 09:28:40 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4444
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4445
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4446
lighter
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4447
    "Squeak compatibility;
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4448
     return a new color, which is slightly lighter than the receiver.
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4449
     Almost the same as lightened for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4450
8047
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4451
    ^ self mixed:1 with:White
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4452
    "/ ^ self mixed:0.8333 with:White
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4453
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4454
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4455
     (Color red)
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4456
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4457
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4458
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4459
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4460
8047
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4461
    "Modified: / 05-07-2017 / 09:29:18 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4462
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4463
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4464
muchDarker
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4465
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4466
     return a new color, which is much darker than the receiver"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4467
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4468
    ^ self mixed:0.233 with:Black
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4469
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4470
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4471
     (Color red) darker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4472
     (Color red) muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4473
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4474
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4475
    "Modified: / 11-06-1996 / 18:10:49 / cg"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4476
    "Modified (comment): / 03-02-2017 / 11:37:46 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4477
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4478
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4479
muchLighter
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4480
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4481
     return a new color, which is much lighter than the receiver"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4482
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4483
    ^ self mixed:0.233 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4484
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4485
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4486
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4487
     (Color red) mixed:0.833 with:Color white
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4488
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4489
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4490
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4491
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4492
    "Modified: / 11-06-1996 / 18:10:49 / cg"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4493
    "Modified (comment): / 03-02-2017 / 11:39:05 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4494
!
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  4495
4203
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4496
privateBlue
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4497
    "Squeak compatibility:
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4498
     return the blue components value mapped to 0..MaxValue"
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4499
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4500
    ^ self scaledBlue
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4501
!
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4502
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4503
privateGreen
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4504
    "Squeak compatibility:
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4505
     return the green components value mapped to 0..MaxValue"
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4506
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4507
    ^ self scaledGreen
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4508
!
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4509
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4510
privateRed
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4511
    "Squeak compatibility:
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4512
     return the red components value mapped to 0..MaxValue"
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4513
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4514
    ^ self scaledRed
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4515
!
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4516
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4517
scaledPixelValue32
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4518
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4519
     return the argb byteValues packed into a 32bit integer;
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4520
     The returned value is composed of a<<24 + r<<16 + g<<8 + b.
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4521
     This is similar to rgbValue, but has an additional alpha byte value
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4522
     in its high bits (which is 0 for fully transparent, 255 for fully opaque colors)"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4523
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4524
    ^ (self redByte bitShift:16)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4525
      + (self greenByte bitShift:8)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4526
      + (self blueByte)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4527
      + (self alphaByte bitShift:24)
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4528
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4529
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4530
    "
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4531
     Color yellow scaledPixelValue
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4532
     Color yellow rgbValue
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4533
     Color yellow alpha
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4534
     Color yellow alphaByte
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4535
    "
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4536
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4537
    "Modified (comment): / 03-02-2017 / 11:40:03 / cg"
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4538
!
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4539
8047
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4540
twiceDarker
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4541
    "Squeak compatibility:
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4542
     return a new color, which is twice as dark as the receiver"
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4543
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4544
    ^ self darker darker
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4545
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4546
    "
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4547
     (Color red) 
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4548
     (Color red) darker
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4549
     (Color red) twiceDarker
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4550
     (Color red) muchDarker
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4551
    "
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4552
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4553
    "Created: / 05-07-2017 / 09:27:16 / cg"
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4554
!
84d3591c4da0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7964
diff changeset
  4555
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4556
veryMuchLighter
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4557
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4558
     return a new color, which is very much lighter than the receiver"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4559
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4560
    ^ self mixed:0.1165 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4561
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4562
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4563
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4564
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4565
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4566
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4567
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4568
    "Modified: / 11-06-1996 / 18:10:49 / cg"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4569
    "Modified (comment): / 03-02-2017 / 11:40:13 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4570
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4571
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4572
wheel:thisMany
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4573
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4574
     An array of thisMany colors around the color wheel,
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4575
     starting at self and ending all the way around the hue space just before self.  
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4576
     Array is of length thisMany.  
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4577
     Very useful for displaying color based on a variable in your program.  "
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4578
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4579
    | sat l hue step c |
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4580
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4581
    thisMany = 1 ifTrue: [^ Array with: self].
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4582
    
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4583
    sat := self saturation.
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4584
    l := self light.
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4585
    hue := self hue.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4586
    step := 360.0 / thisMany.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4587
    ^ (1 to: thisMany) collect: [:num |
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4588
        c := self class hue: hue light:l saturation: sat.  "hue is taken mod 360"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4589
        hue := hue + step.
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4590
        c
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4591
    ].
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4592
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4593
    "
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4594
     Color red wheel:20
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4595
     Color red wheel:40
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4596
    "
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4597
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4598
    "Modified (comment): / 03-02-2017 / 11:50:59 / cg"
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4599
! !
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4600
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4601
!Color methodsFor:'accessing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4602
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4603
alpha
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4604
    "return the alpha value (0..1),
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4605
     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
  4606
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4607
    ^ 1.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4608
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4609
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4610
alphaByte
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4611
    "return the alpha byte-value (0..255),
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4612
     where 0 is completely transparent and 255 is completely opaque"
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4613
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4614
    ^ 255.
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4615
!
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4616
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4617
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4618
    "return the blue component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4619
8163
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4620
    blue notNil ifTrue:[
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4621
        ^ blue * 100.0 / MaxValue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4622
    ].
8163
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4623
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4624
    (colorId notNil) ifTrue:[
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4625
        device notNil ifTrue:[
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4626
            device getRGBFrom:colorId into:[:r :g :b | ^ b].
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4627
        ].
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4628
    ].
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4629
    ^ 0
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4630
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4631
    "Modified: / 05-09-2017 / 12:15:57 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4632
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4633
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4634
blueByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4635
    "return the blue components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4636
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4637
    blue isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4638
    ^ blue * 255 // MaxValue
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
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4641
     Color red blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4642
     Color blue blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4643
     Color green blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4644
     Color black blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4645
     Color grey blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4646
     Color white blueByte
1023
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
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4649
    "Created: / 7.6.1996 / 18:30:25 / cg"
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4650
    "Modified: / 26.7.1998 / 12:31:44 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4651
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4652
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4653
colorId
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4654
    "return the device-dependent color-id"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4655
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4656
    colorId notNil ifTrue:[^ colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4657
    replacementColor notNil ifTrue:[^ replacementColor colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4658
    ^ nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4659
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4660
    "Modified: 17.1.1997 / 00:03:18 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4661
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4662
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4663
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4664
    "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
  4665
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4666
    ^ 100 - self red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4667
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4668
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4669
    "Created: 11.6.1996 / 18:30:00 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4670
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4671
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4672
device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4673
    "return the device I am associated to"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4674
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4675
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4676
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4677
    "Modified: 23.4.1996 / 13:36:42 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4680
deviceBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4681
    "return the actual value of the blue component in percent."
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
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4684
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4685
    device getRGBFrom:colorId into:[:r :g :b | v := b].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4686
    ^ v
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
deviceGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4690
    "return the actual value of the green component in percent.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4691
     (usually 16bit in X; but could be different on other systems)"
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
    |v|
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
    device getRGBFrom:colorId into:[:r :g :b | v := g].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4696
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4697
!
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
deviceRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4700
    "return the actual value of the red component in percent."
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
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4703
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4704
    device getRGBFrom:colorId into:[:r :g :b | v := r].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4705
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4706
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4707
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4708
     (Color yellow on:Display) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4709
     (Color yellow on:aPrinterPage) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4710
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4711
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4712
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4713
ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4714
    "return the form to dither the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4715
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4716
    ^ ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4717
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4718
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4719
graphicsDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4720
    "same as #device, for ST-80 compatibility naming.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4721
     Return the device I am associated with."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4722
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4723
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4724
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4725
    "Created: 28.5.1996 / 18:39:27 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4726
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4727
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4728
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4729
    "return the green component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4730
8163
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4731
    green notNil ifTrue:[
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4732
        ^ green * 100.0 / MaxValue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4733
    ].
8163
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4734
    
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4735
    colorId notNil ifTrue:[
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4736
        device notNil ifTrue:[
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4737
            device getRGBFrom:colorId into:[:r :g :b | ^ g].
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4738
        ].
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4739
    ].
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4740
    ^ 0
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4741
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4742
    "Modified: / 05-09-2017 / 12:15:10 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4743
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4744
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4745
greenByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4746
    "return the green components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4747
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4748
    green isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4749
    ^ green * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4750
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4751
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4752
     Color red greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4753
     Color blue greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4754
     Color green greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4755
     Color black greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4756
     Color grey greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4757
     Color white greenByte
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4758
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4759
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4760
    "Modified: / 26.7.1998 / 12:31:33 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4761
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4762
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4763
hue
6654
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4764
    "return the hue (in hue/light/saturation model) in degrees [0..360].
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4765
     The hue value is the position on the color wheel.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4766
     0 is red, 120 green, 240 blue"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4767
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4768
    |r g b h|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4769
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4770
    (red isNil and:[colorId notNil]) ifTrue:[
6654
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4771
        device getRGBFrom:colorId into:[:xr :xg :xb |
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4772
            r := xr.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4773
            g := xg.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4774
            b := xb.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4775
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4776
    ] ifFalse:[
6654
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4777
        r := self red.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4778
        g := self green.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4779
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4780
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4781
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4782
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
6654
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4783
        h := xh
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4784
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4785
    ^ h
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4786
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4787
    "
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4788
     Color red hue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4789
     Color yellow hue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4790
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4791
6654
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4792
    "
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4793
     color wheel:
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4794
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4795
     |v|
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4796
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4797
     v := View new extent:200@200.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4798
     v openAndWait.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4799
     0 to:360 do:[:hue |
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4800
        100 downTo:0 do:[:sat |
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4801
            |p|
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4802
            v paint:(Color hue:hue light:50 saturation:sat).
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4803
            p := Point r:sat degrees:hue.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4804
            v displayLineFrom:100@100 to:p+(100@100).
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4805
        ].
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4806
     ].
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4807
    "
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4808
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4809
    "Modified: 11.6.1996 / 17:14:51 / cg"
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
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4812
light
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4813
    "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
  4814
     This corresponds to the brightness of the color (if displayed on
6170
8b03d05c720d class: Color
Claus Gittinger <cg@exept.de>
parents: 6110
diff changeset
  4815
     a b&w television screen).
8b03d05c720d class: Color
Claus Gittinger <cg@exept.de>
parents: 6110
diff changeset
  4816
     Old; please use #brightness (which is 0..1) for compatibility with other smalltalks"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4817
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4818
    |r g b l|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4819
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4820
    (red isNil and:[colorId notNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4821
	device getRGBFrom:colorId into:[:xr :xg :xb |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4822
	    r := xr.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4823
	    g := xg.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4824
	    b := xb.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4825
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4826
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4827
	r := self red.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4828
	g := self green.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4829
	b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4830
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4831
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4832
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4833
	l := xl
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4834
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4835
    ^ l
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4836
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4837
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4838
     Color yellow light
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4839
     Color yellow darkened light
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4842
    "Modified: 11.6.1996 / 17:15:24 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4845
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4846
    "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
  4847
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4848
    ^ 100 - self green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4849
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4850
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4851
    "Created: 11.6.1996 / 18:30:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4852
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4853
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4854
privateAlpha
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4855
    "return the internal alpha value (0..255),
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4856
     where 0 is completely transparent and 255 is completely opaque"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4857
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4858
    ^ 255
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4859
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4860
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4861
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4862
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4863
    "return the red component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4864
8163
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4865
    red notNil ifTrue:[
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4866
        ^ red * 100.0 / MaxValue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4867
    ].
8163
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4868
    
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4869
    (colorId notNil) ifTrue:[
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4870
        device notNil ifTrue:[
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4871
            device getRGBFrom:colorId into:[:r :g :b | ^ r].
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4872
        ].
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4873
    ].
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4874
    ^ 0
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4875
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  4876
    "Modified (format): / 05-09-2017 / 12:15:34 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4877
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4878
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4879
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4880
    "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
  4881
     table in pseudocolor devices.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4882
     This is only allowed for writable colors (i.e. those allocated with
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4883
     Color>>variableColorOn: on pseudoColor displays).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4884
     Using this may make your code unportable, since it depends on a display
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4885
     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
  4886
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4887
    ^ self scaledRed:(r * MaxValue // 100)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4888
	   scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4889
	   scaledBlue:(b * MaxValue // 100)
1023
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
     |c|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4893
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4894
     c := Color variableColorOn:Display.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4895
     c inspect.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4896
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4897
     c red:100 green:0 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4898
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4899
     c red:0 green:100 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4900
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4901
     c red:0 green:0 blue:100.
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
!
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
redByte
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4906
    "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
  4907
     nil if it has no red component."
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4908
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4909
    red isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4910
    ^ red * 255 // MaxValue
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
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4913
     Color red redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4914
     Color blue redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4915
     Color green redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4916
     Color black redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4917
     Color grey redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4918
     Color white redByte
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4919
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4920
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4921
    "Modified: / 26.7.1998 / 12:31:22 / cg"
1023
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
7830
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4924
rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4925
    "return the rgb byteValues as a 3-byte byteArray #[red green blue]"
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4926
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4927
    |r "{ Class: SmallInteger }"
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4928
     g "{ Class: SmallInteger }"
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4929
     b "{ Class: SmallInteger }"|
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4930
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4931
    r := red * 255 // MaxValue.
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4932
    g := green * 255 // MaxValue.
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4933
    b := blue * 255 // MaxValue.
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4934
    ^ ByteArray with:r with:g with:b
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4935
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4936
    "
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4937
     Color red rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4938
     Color blue rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4939
     Color green rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4940
     Color black rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4941
     Color grey rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4942
     Color white rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4943
    "
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4944
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4945
    "Created: / 03-02-2017 / 11:31:24 / cg"
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4946
!
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4947
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4948
rgbValue
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4949
    "return the rgb byteValues packed into a 24bit integer;
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4950
     The returned value is composed of r<<16 + g<<8 + b."
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4951
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4952
    |t "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4953
     v "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4954
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4955
    v := red * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4956
    t := green * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4957
    v := (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4958
    t := blue * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4959
    ^ (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4960
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4961
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4962
     Color red rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4963
     Color blue rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4964
     Color green rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4965
     Color black rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4966
     Color grey rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4967
     Color white rgbValue hexPrintString
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4968
    "
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4969
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4970
    "Modified: 17.10.1997 / 20:00:25 / cg"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4971
!
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4972
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4973
saturation
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4974
    "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
  4975
     This corresponds to the saturation setting of a color TV"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4976
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4977
    |r g b s|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4978
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4979
    (red isNil and:[colorId notNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4980
	device getRGBFrom:colorId into:[:xr :xg :xb |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4981
	    r := xr.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4982
	    g := xg.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4983
	    b := xb.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4984
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4985
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4986
	r := self red.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4987
	g := self green.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4988
	b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4989
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4990
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4991
    self class withHLSFromRed:r green:g blue:b do:[:xh :xl :xs |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4992
	s := xs
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4993
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4994
    ^ s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4995
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
     Color yellow saturation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4998
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4999
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5000
    "Modified: 11.6.1996 / 17:15:47 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5001
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5002
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5003
scaledAlpha
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5004
    "ST-80 compatibility:
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5005
     return the alpha components value mapped to 0..MaxValue"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5006
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5007
    ^ MaxValue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5008
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5009
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5010
     Color blue scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5011
     Color black scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5012
     Color grey scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5013
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5014
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5015
    "Modified: 7.6.1996 / 18:32:30 / cg"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5016
!
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5017
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5018
scaledBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5019
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5020
     return the blue components value mapped to 0..MaxValue"
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
    ^ blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5024
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5025
     Color blue scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5026
     Color black scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5027
     Color grey scaledBlue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5028
    "
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
    "Modified: 7.6.1996 / 18:32:30 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5033
scaledGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5034
    "return the grey intensity scaled to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5035
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5036
    ^ ((red * 3) + (green * 6) + blue) // 10
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5037
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5038
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5039
     Color blue scaledGray
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5040
     Color black scaledGray
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5041
     Color white scaledGray
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5042
     Color grey scaledGray
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5043
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5044
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5045
    "Modified: 11.6.1996 / 14:43:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5046
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5047
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5048
scaledGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5049
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5050
     return the green components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5051
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5052
    ^ green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5053
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5054
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5055
     Color green scaledRed
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5056
     Color black scaledRed
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5057
     Color grey scaledRed
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5058
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5059
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5060
    "Modified: 7.6.1996 / 18:32:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5061
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5062
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5063
scaledRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5064
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5065
     return the red components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5066
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5067
    ^ red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5068
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5069
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5070
     Color red scaledRed
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5071
     Color black scaledRed
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5072
     Color grey scaledRed
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5073
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5074
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5075
    "Modified: 7.6.1996 / 18:32:43 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5076
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5077
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5078
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5079
    "set r/g/b components in 0..MaxValue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5080
     This method will change the color lookup table in pseudocolor devices.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5081
     This is only allowed for writable colors (i.e. those allocated with
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5082
     Color>>variableColorOn: on pseudoColor displays).
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5083
     Using this may make your code unportable, since it depends on a display
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5084
     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
  5085
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5086
    (colorId isNil or:[red notNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5087
	^ self error:'operation is not allowed for shared colors'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5088
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5089
    device setColor:colorId scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5090
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5091
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5092
writable
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5093
    "return true, if this is a writable colorcell"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5094
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5095
    ^ writable == true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5096
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5097
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5098
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5099
    "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
  5100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5101
    ^ 100 - self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5102
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5103
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5104
    "Created: 11.6.1996 / 18:30:20 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5105
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5106
5131
95d91d6d649c care for invalid hue/light/saturation
Claus Gittinger <cg@exept.de>
parents: 5127
diff changeset
  5107
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5108
!Color methodsFor:'comparing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5109
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5110
= aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5111
    "two colors are considered equal, if the color components are;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5112
     independent of the device, the color is on"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5113
2083
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  5114
    aColor == self ifTrue:[^ true].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5115
    aColor isColor ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5116
	(red == aColor scaledRed) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5117
	    (green == aColor scaledGreen) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5118
		(blue == aColor scaledBlue) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5119
		    ^ true
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5120
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5121
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5122
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5123
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5124
    ^ false
2083
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  5125
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  5126
    "Modified: / 2.4.1998 / 10:04:39 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5127
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5128
1390
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5129
almostSameAs:aColor
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5130
    "return true, if aColor looks almost the same as the receiver
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5131
     (i.e. the components differ by a small, invisible amount).
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5132
     We assume, that the human eye can distinguish roughly 100 grey levels
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5133
     (which is optimistic ;-);
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5134
     therefore, allow a 1 percent difference in each component for the colors
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5135
     to compare as looking the same."
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5136
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5137
     (self red - aColor red) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5138
     (self green - aColor green) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5139
     (self blue - aColor blue) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5140
     ^ true
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5141
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5142
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5143
      (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
  5144
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5145
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5146
    "Modified: 28.2.1997 / 12:00:01 / cg"
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5147
!
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  5148
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5149
hash
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5150
    "return an integer useful as hash key for the receiver.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5151
     Redefined since = is redefined"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5152
2318
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  5153
    red isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5154
	^ colorId
2318
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  5155
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5156
    ^ red + green + blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5157
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5158
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5159
!Color methodsFor:'converting'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5160
6830
4b029193d399 class: Color
Claus Gittinger <cg@exept.de>
parents: 6793
diff changeset
  5161
asByteArray
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  5162
    "return the rgb byteValues as a 3-byte byteArray #[red green blue]"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  5163
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  5164
    ^ self rgbBytes.
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  5165
"/    ^ByteArray
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  5166
"/            with: self redByte
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  5167
"/            with: self greenByte
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  5168
"/            with: self blueByte
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  5169
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  5170
    "Modified: / 03-02-2017 / 11:33:23 / cg"
6830
4b029193d399 class: Color
Claus Gittinger <cg@exept.de>
parents: 6793
diff changeset
  5171
!
4b029193d399 class: Color
Claus Gittinger <cg@exept.de>
parents: 6793
diff changeset
  5172
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5173
fromLiteralArrayEncoding:encoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5174
    "read my values from an encoding.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5175
     The encoding is supposed to be either of the form:
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5176
        (#Color redPart greenPart bluePart)
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  5177
     or:
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5178
        (#Color constantColorSymbol)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5179
     This is the reverse operation to #literalArrayEncoding."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5180
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5181
    |clr nameOrRGB|
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  5182
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5183
    red notNil ifTrue:[
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5184
        "oops cannot change an existing color (you want to make red be green - or what)"
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5185
        self error:'Colors cannot change their components'.
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5186
        ^ self
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5187
    ].
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5188
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  5189
    encoding size == 2 ifTrue:[
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5190
        nameOrRGB := encoding at:2.
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  5191
        nameOrRGB isSymbol ifTrue:[
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5192
            clr := self class name:nameOrRGB
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  5193
        ] ifFalse:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5194
            clr := self class rgbValue:nameOrRGB.
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5195
        ].
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5196
        red := clr scaledRed.
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5197
        green := clr scaledGreen.
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5198
        blue := clr scaledBlue
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  5199
    ] ifFalse:[
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5200
        red := ((encoding at:2) / 100.0 * MaxValue) rounded.
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5201
        green := ((encoding at:3) / 100.0 * MaxValue) rounded.
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5202
        blue := ((encoding at:4) / 100.0 * MaxValue) rounded.
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  5203
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5204
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5205
    "
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5206
      Color new fromLiteralArrayEncoding:#(Color 50 25 25)
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5207
      Color new fromLiteralArrayEncoding:#(Color 16rFF00FF)
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5208
      Color new fromLiteralArrayEncoding:#(Color blue)
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5209
    "
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5210
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  5211
    "Modified (comment): / 11-01-2018 / 12:42:56 / stefan"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5212
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5213
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5214
literalArrayEncoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5215
    "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
  5216
     can be reconstructed with #decodeAsLiteralArray.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5217
     The encoding is:
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5218
        (#Color redPart greenPart bluePart)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5219
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5220
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5221
    ^ Array
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  5222
        with:self class name
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  5223
        with:((red * 100.0 / MaxValue) roundTo:0.25)
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  5224
        with:((green * 100.0 / MaxValue) roundTo:0.25)
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  5225
        with:((blue * 100.0 / MaxValue) roundTo:0.25)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5226
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5227
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5228
      Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5229
      (Color red:25 green:30 blue:70) literalArrayEncoding
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5230
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5231
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5232
    "Modified: 22.4.1996 / 13:00:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5233
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5234
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5235
!Color methodsFor:'copying'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5236
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5237
postCopy
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5238
    "redefined to clear out any device handles in the copy"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5239
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5240
    device := colorId := ditherForm := replacementColor := nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5241
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5242
    "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
  5243
!
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5244
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5245
skipInstvarIndexInDeepCopy:index
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5246
    index == 4 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5247
	^ true "/ skip device
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5248
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5249
    index == 5 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5250
	^ true "/ skip colorId
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5251
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5252
    index == 6 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5253
	^ true "/ skip ditherForm
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5254
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5255
    index == 7 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5256
	^ true "/ skip replacementColor
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5257
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5258
    ^ false
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5259
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5260
    "
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5261
     (Color black onDevice:Screen current) deepCopy
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  5262
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5263
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5264
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5265
!Color methodsFor:'getting a device color'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5266
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5267
exactOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5268
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5269
     myself on aDevice; if one already exists, return the one.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5270
     Do not dither or otherwise approximate the color, but return
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5271
     nil, if the exact color is not available.
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5272
     Used to acquire primary colors for dithering, during startup."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5273
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5274
    |newColor id r g b|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5275
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5276
    "if Iam already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5277
    (device == aDevice and:[ditherForm isNil]) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5278
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5279
    r := red.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5280
    g := green.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5281
    b := blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5282
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  5283
    "first look if not already there"
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5284
    newColor := self class existingColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice.
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  5285
    (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
  5286
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5287
    r := (r bitAnd:16rFF00) bitOr:(r bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5288
    g := (g bitAnd:16rFF00) bitOr:(g bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5289
    b := (b bitAnd:16rFF00) bitOr:(b bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5290
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5291
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5292
    id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5293
    id isNil ifTrue:[
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5294
        "/ this is a kludge: scavenge to free unused colors
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5295
        "/  and try again ...
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5296
        ObjectMemory scavenge; finalize.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5297
        id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5298
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5299
    id isNil ifTrue:[
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5300
        "no such color - fail"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5301
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5302
"/      'COLOR: no color for ' infoPrint. self displayString infoPrintCR.
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5303
        ^ nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5304
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5305
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5306
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5307
    device isNil ifTrue:[
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5308
        device := aDevice.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5309
        colorId := id.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5310
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5311
        aDevice visualType ~~ #TrueColor ifTrue:[
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5312
            "/ Lobby register:self.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5313
            aDevice registerColor:self.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5314
        ].
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5315
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5316
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5317
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5318
    "receiver was already associated to another device - need a new color"
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  5319
    newColor := (self class basicNew) 
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  5320
                    setScaledRed:r scaledGreen:g scaledBlue:b 
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  5321
                    device:aDevice.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5322
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5323
    aDevice visualType ~~ #TrueColor ifTrue:[
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5324
        "/ Lobby register:newColor.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  5325
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5326
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5327
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5328
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  5329
    "Modified: 24.2.1997 / 18:23:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5330
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5331
1856
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5332
exactOrNearestOn:aDevice
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5333
    "get a device color for the receiver, which is either exact
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5334
     or the nearest, but never dithered.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5335
     This can be used for viewBackgrounds, where the exact greyLevel
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5336
     does not matter, but a dithered color is not wanted."
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5337
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5338
    |deviceColor|
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5339
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5340
    deviceColor := self exactOn:aDevice.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5341
    deviceColor isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5342
	deviceColor := self nearestOn:aDevice
1856
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5343
    ].
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5344
    ^ deviceColor
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5345
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5346
    "Created: 13.8.1997 / 15:25:48 / cg"
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5347
!
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  5348
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5349
nearestIn:aColorMap
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  5350
    "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
  5351
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  5352
    ^ self class
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5353
	nearestColorScaledRed:(self scaledRed)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5354
		  scaledGreen:(self scaledGreen)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5355
		   scaledBlue:(self scaledBlue)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5356
			   on:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5357
			   in:aColorMap
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  5358
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  5359
    "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
  5360
!
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  5361
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5362
nearestOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5363
    "create a new Color representing the same color as myself on aDevice;
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5364
     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
  5365
     search for the nearest match"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5366
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5367
    |newColor id|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5368
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5369
    "if I'am already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5370
    (device == aDevice) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5371
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5372
    "first look if not already there"
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5373
    newColor := self class nearestColorScaledRed:red scaledGreen:green scaledBlue:blue on:aDevice.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5374
    newColor notNil ifTrue:[^ newColor].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5375
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5376
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5377
    id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5378
    id isNil ifTrue:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5379
        "this is a kludge:
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5380
            scavenge to possuby free unused colors and try again ...
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5381
            this is a compromise: actually a full GC is required here,
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5382
            but that is too expensive.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5383
        "
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5384
        ObjectMemory scavenge; finalize.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5385
        id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5386
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5387
    id isNil ifTrue:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5388
        "no color - fail"
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5389
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5390
        ^ nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5391
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5392
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5393
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5394
    device isNil ifTrue:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5395
        device := aDevice.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5396
        colorId := id.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5397
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5398
        aDevice visualType ~~ #TrueColor ifTrue:[
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5399
            "/ Lobby register:self.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5400
            aDevice registerColor:self.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5401
        ].
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5402
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5403
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5404
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5405
    "receiver was already associated to another device - need a new color"
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  5406
    newColor := (self class basicNew) 
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  5407
                    setScaledRed:red scaledGreen:green scaledBlue:blue 
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  5408
                    device:aDevice.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5409
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5410
    aDevice visualType ~~ #TrueColor ifTrue:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5411
        "/ Lobby register:newColor.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5412
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5413
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5414
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5415
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  5416
    "Modified: 24.2.1997 / 18:23:26 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5417
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5418
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5419
on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5420
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5421
     myself on aDevice; if one already exists, return the one"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5422
3623
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  5423
    "/ send out a warning: #on: is typically used to create views
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  5424
    "/ operating on a model.
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  5425
    "/ Please use #onDevice: to avoid confusion.
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  5426
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  5427
    <resource:#obsolete>
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  5428
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  5429
    self obsoleteMethodWarning:'use #onDevice:'.
2836
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5430
    ^ self onDevice:aDevice
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5431
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5432
    "Created: / 16.11.1995 / 20:16:42 / cg"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5433
    "Modified: / 8.9.1998 / 17:32:10 / cg"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5434
!
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5435
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5436
onDevice:aDevice
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5437
    "create a new Color representing the same color as
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5438
     myself on aDevice; if one already exists, return the one"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  5439
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5440
    |newColor id form
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5441
     greyV "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5442
     rV    "{ Class: SmallInteger }"
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5443
     gV    "{ Class: SmallInteger }"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5444
     bV    "{ Class: SmallInteger }"
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  5445
     deviceVisual deviceFixColors deviceDepth|
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5446
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5447
    "/ the most common cases (already allocated) first
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5448
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5449
    colorId notNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5450
        "/ is someone validating me before drawing on aDevice ?
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5451
        (aDevice notNil and:[aDevice == device]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5452
            ^ self
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5453
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5454
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5455
        "/ a special case for pseudo-colors (0 and 1 in bitmaps)
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5456
        "/ those have nil r/g/b values, but a nonNil colorId
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5457
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5458
        red isNil ifTrue:[^ self].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5459
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5460
        "/ want to release color ?
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5461
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5462
        (aDevice isNil and:[device notNil]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5463
            "/ trueColor device-colors are not registered
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5464
            device visualType ~~ #TrueColor ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5465
                device unregisterColor:newColor.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5466
                device freeColor:colorId
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5467
            ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5468
            device := nil.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5469
            colorId := nil.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5470
            ^ self
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5471
        ].
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  5472
    ].
2313
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  5473
    aDevice isNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5474
        ^ self
2313
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  5475
    ].
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  5476
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  5477
    device == aDevice ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5478
        ditherForm notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5479
            ^ self
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5480
        ]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  5481
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  5482
7650
5781e05a6a1d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7642
diff changeset
  5483
    "/ on high-resolution true-color systems, don't care for dithering and
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5484
    "/ especially freeing colors
2842
dcb1f8eb648f removed obsolete method
Claus Gittinger <cg@exept.de>
parents: 2836
diff changeset
  5485
    "/ (no need to register)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5486
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  5487
    deviceDepth := aDevice depth.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5488
    (deviceVisual := aDevice visualType) == #TrueColor ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5489
        deviceDepth >= 15 ifTrue:[
8165
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5490
            id := aDevice colorScaledRed:(red ? 0) scaledGreen:(green ? 0) scaledBlue:(blue ? 0).
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5491
            id notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5492
                device isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5493
                    "/ receiver was not associated - do it now & return mySelf
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5494
                    colorId := id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5495
                    ditherForm := nil.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5496
                    device := aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5497
                    ^ self
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5498
                ].
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  5499
                newColor := (self class basicNew)
8165
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5500
                                    setScaledRed:(red ? 0)
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5501
                                    scaledGreen:(green ? 0)
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5502
                                    scaledBlue:(blue ? 0)
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5503
                                    device:aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5504
                newColor setColorId:id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5505
                ^ newColor
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5506
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5507
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5508
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5509
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  5510
    rV := red.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  5511
    gV := green.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  5512
    bV := blue.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  5513
7782
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
  5514
"/    "/ round a bit within 1% in red & green, 2% in blue
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  5515
"/    rV := (red / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  5516
"/    gV := (green / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  5517
"/    bV := (blue / 50.0) rounded * 50.
7782
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
  5518
"/
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
  5519
"/    "/ if I am already assigned to that device ...
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
  5520
"/
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5521
"/    ((device == aDevice) and:[ditherForm notNil]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5522
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5523
"/        "/ 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
  5524
"/        "/ try again - maybe some colors were reclaimed in the meanwhile
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5525
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5526
"/        deviceFixColors := aDevice fixColors.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5527
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5528
"/        (deviceFixColors isNil
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5529
"/         and:[RetryAllocation]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5530
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5531
"/             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
  5532
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5533
"/            aDevice depth > 2 ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5534
"/                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5535
"/                id notNil ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5536
"/                    colorId := id.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5537
"/                    ditherForm := nil.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5538
"/                    device registerColor:self.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5539
"/                ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5540
"/            ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5541
"/        ].
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5542
"/        ^ self
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  5543
"/    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5544
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5545
    newColor := self class existingColorScaledRed:rV scaledGreen:gV scaledBlue:bV on:aDevice.
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5546
    newColor notNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5547
        (newColor scaledRed ~~ red
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5548
        or:[newColor scaledGreen ~~ green
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5549
        or:[newColor scaledBlue ~~ blue]]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5550
            Transcript showCR:'Color>>#onDevice: got different color'.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5551
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5552
        ^ newColor
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5553
    ].
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5554
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5555
    "/ ask that device for the exact color
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5556
    id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5557
    id notNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5558
        device isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5559
            "/ receiver was not associated - do it now & return mySelf
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5560
            colorId := id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5561
            ditherForm := nil.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5562
            device := aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5563
            newColor := self.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5564
        ] ifFalse:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5565
            newColor := self class basicNew
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5566
                                setScaledRed:red
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5567
                                scaledGreen:green
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5568
                                scaledBlue:blue
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5569
                                device:aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5570
            newColor setColorId:id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5571
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5572
        id notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5573
            deviceVisual ~~ #TrueColor ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5574
                aDevice registerColor:newColor.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5575
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5576
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5577
        ^ newColor
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5578
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5579
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5580
    "/
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5581
    "/ 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
  5582
    "/ the nearest.
7885
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5583
    "/ if it's 'almost' grey, make it grey and round it a bit (1%)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5584
    "/
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5585
    greyV := (3 * red) + (6 * green) + (1 * blue).
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  5586
    greyV := (greyV / 1000.0) rounded * 100.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5587
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5588
    "/ allow an error of 1% in red & green, 2% in blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5589
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5590
    ((rV - greyV) abs <= 655                    "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5591
    and:[(gV - greyV) abs <= 655                "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5592
    and:[(bV - greyV) abs <= 1310]]) ifTrue:[   "/ MaxValue // 100 * 2
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5593
        rV := gV := bV := greyV.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5594
    ] ifFalse:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5595
        rV := red. gV := green. bV := blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5596
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5597
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5598
    aDevice hasColors ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5599
        deviceFixColors := aDevice fixColors.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5600
        deviceFixColors isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5601
            "/ ask that device for the exact color
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5602
            id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5603
            id isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5604
                aDevice isOpen ifFalse:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5605
                    ^ nil
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5606
                ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5607
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5608
                "/ this is a kludge: scavenge to free unused colors
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5609
                "/ and try again ...
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5610
                ObjectMemory scavenge; finalize.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5611
                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5612
            ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5613
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5614
            id isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5615
                "/ no such color - try color dithers
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5616
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5617
                self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5618
                    ditherRed:rV green:gV blue:bV
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5619
                    on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5620
                    into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5621
                newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5622
            ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5623
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5624
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5625
        "/ none found ? -> do a hard dither using fixColors
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5626
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5627
        (id isNil and:[form isNil]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5628
            deviceFixColors notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5629
                self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5630
                    fixDitherRed:rV green:gV blue:bV
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5631
                    on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5632
                    into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5633
                newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5634
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5635
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5636
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5637
        "/ still none found ? -> do a very hard dither using existing colors
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5638
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5639
        (id isNil and:[form isNil]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5640
            self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5641
                complexDitherRed:rV green:gV blue:bV
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5642
                on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5643
                into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5644
            newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5645
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5646
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5647
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5648
    (id isNil and:[form isNil]) ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5649
        "still no result - try graying"
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5650
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5651
        greyV == 0 ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5652
            id := aDevice blackpixel
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5653
        ] ifFalse:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5654
            greyV == MaxValue ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5655
                id := aDevice whitepixel
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5656
            ] ifFalse:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5657
                aDevice hasGrayscales ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5658
                    self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5659
                        ditherGrayFor:(greyV / MaxValue)
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5660
                        on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5661
                        into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5662
                    newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5663
                ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5664
                form isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5665
                    "/ still none - dither b&w
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5666
                    self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5667
                        monoDitherFor:(greyV / MaxValue)
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5668
                        between:Black and:White
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5669
                        on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5670
                        into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5671
                    newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5672
                    form isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5673
                        "/ cannot happen
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5674
                        'Color [warning]: monoDither failed' errorPrintCR.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5675
                        ^ nil
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5676
                    ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5677
                ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5678
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5679
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5680
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5681
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5682
    device isNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5683
        "/ receiver was not associated - do it now & return mySelf
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5684
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5685
        device := aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5686
        id isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5687
            ditherForm := form
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5688
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5689
        colorId := id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5690
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5691
        "/ have to register - otherwise it keeps old info around
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5692
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5693
        id notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5694
            deviceVisual ~~ #TrueColor ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5695
                aDevice registerColor:self.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5696
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5697
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5698
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5699
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5700
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5701
    "/ receiver was already associated to another device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5702
    "/ - need a new color and return it
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5703
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5704
    newColor := self class basicNew
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5705
                        setScaledRed:red
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5706
                        scaledGreen:green
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5707
                        scaledBlue:blue
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5708
                        device:aDevice.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5709
    id isNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5710
        newColor setDitherForm:form
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5711
    ] ifFalse:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5712
        newColor setColorId:id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5713
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5714
        "/ trueColor device-colors are not registered
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5715
        deviceVisual ~~ #TrueColor ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5716
            aDevice registerColor:newColor.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5717
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5718
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5719
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5720
7885
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5721
    "Created: / 16-11-1995 / 20:16:42 / cg"
8165
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5722
    "Modified: / 05-09-2017 / 12:20:54 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5723
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5724
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5725
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5726
!Color methodsFor:'instance creation'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5727
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5728
alpha:alphaValue
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5729
    "return a new color with the same color, but different alpha as the receiver.
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5730
     The alpha arguments range is 0..1 (0=completely transparent; 1=completely opaque)"
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5731
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5732
    alphaValue = 1 ifTrue:[ ^ self].
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5733
    ^ (TranslucentColor
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5734
	   scaledRed:red
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5735
	   scaledGreen:green
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5736
	   scaledBlue:blue) alpha:alphaValue
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5737
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5738
    "
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5739
     (Color red alpha:0.5) alpha
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5740
     Color red alpha
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5741
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5742
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5743
    "Modified: / 06-06-2007 / 11:17:55 / cg"
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5744
!
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5745
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5746
blendWith:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5747
    "create a new color from equally mixing the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5748
     and the argument, aColor.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5749
     Mixing is done by adding components
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5750
     (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
  5751
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5752
    ^ self mixed:1 with:aColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5753
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5754
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5755
     (Color red) blendWith:(Color yellow)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5756
     (Color red) blendWith:(Color blue)
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5757
     (Color red) blendWith:(Color black)
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5758
     (Color red) blendWith:(Color white)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5759
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5760
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5761
    "Modified: 10.2.1997 / 22:08:14 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5762
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5763
5965
4f8e9e2ec50b class: Color
Stefan Vogel <sv@exept.de>
parents: 5957
diff changeset
  5764
contrastingBlackOrWhite
7639
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5765
    "answer either black or white, whichever gives a better contrast
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5766
     for drawing text on a background with my color.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5767
     (i.e. if I am dark, return white; if I am bright, return black"
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5768
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5769
    ^ self brightness < 0.55 
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5770
        ifTrue:[self class white] 
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5771
        ifFalse:[self class black]
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5772
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5773
    "
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5774
     (Color blue) contrastingBlackOrWhite
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5775
     (Color red) contrastingBlackOrWhite
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5776
     (Color green) contrastingBlackOrWhite
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5777
     (Color yellow) contrastingBlackOrWhite
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5778
    "
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5779
!
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5780
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5781
contrastingColorFor:aBackgroundColor
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5782
    "answer a slightly brightened or darkened variant of myself,
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5783
     to ensure a good contrast when showing text on a background color.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5784
     i.e. when drawing read on grey, it might be better to darken or brighten 
7885
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5785
     the red, if it's brightness is too near to the grey's brightness.
7639
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5786
     Use this for alert strings shown on a color background."
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5787
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5788
    |colorUsed bgBrightness|
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5789
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5790
    colorUsed := self.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5791
    bgBrightness := aBackgroundColor brightness.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5792
    
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5793
    (bgBrightness dist:colorUsed brightness) < 0.5 ifTrue:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5794
        bgBrightness > 0.5 ifTrue:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5795
            colorUsed := self slightlyDarkened.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5796
            (bgBrightness dist:colorUsed brightness) < 0.5 ifTrue:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5797
                colorUsed := self darkened.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5798
            ].
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5799
        ] ifFalse:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5800
            colorUsed := self slightlyLightened.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5801
            (bgBrightness dist:colorUsed brightness) < 0.5 ifTrue:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5802
                colorUsed := self lightened.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5803
            ].
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5804
        ].    
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5805
    ].
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5806
    ^ colorUsed.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5807
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5808
    "
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5809
     (Color blue) contrastingColorFor:Color white.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5810
     (Color blue) contrastingColorFor:Color blue.
8456
e9e1d8fb7e65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8437
diff changeset
  5811
     (Color blue) contrastingColorFor:View defaultBackgroundColor.
7639
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5812
     (Color red) contrastingColorFor:Color grey
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5813
     (Color blue) contrastingColorFor:Color black
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5814
    "
7885
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5815
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5816
    "Modified (comment): / 13-02-2017 / 19:58:34 / cg"
8456
e9e1d8fb7e65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8437
diff changeset
  5817
    "Modified (comment): / 29-08-2018 / 13:28:53 / Claus Gittinger"
5965
4f8e9e2ec50b class: Color
Stefan Vogel <sv@exept.de>
parents: 5957
diff changeset
  5818
!
4f8e9e2ec50b class: Color
Stefan Vogel <sv@exept.de>
parents: 5957
diff changeset
  5819
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5820
darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5821
    "return a new color, which is slightly darker than the receiver"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5822
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5823
    ^ self blendWith:Black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5824
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5825
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5826
     (Color red) darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5827
     (Color red) darkened darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5828
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5829
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5830
    "Modified: 11.6.1996 / 18:10:37 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5831
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5832
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5833
lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5834
    "return a new color, which is slightly lighter than the receiver"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5835
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5836
    ^ self blendWith:White
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5837
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5838
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5839
     (Color red) lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5840
     (Color red) lightened lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5841
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5842
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5843
    "Modified: 11.6.1996 / 18:10:49 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5844
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5845
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5846
mixed:amount with:aColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5847
    "create a new color from mixing amount of the receiver
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5848
     with the argument, aColor.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5849
     Mixing is done by adding components (i.e. additive mixing)
8165
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5850
     (which is different from mixing colors on paper, which is subtractive).
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5851
     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
  5852
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5853
    red isNil ifTrue:[
8165
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5854
        ^ aColor
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5855
    ].
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5856
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5857
    ^ (self class)
8165
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5858
        scaledRed:((red * amount) + aColor scaledRed) // (1 + amount)
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5859
        scaledGreen:((green * amount) + aColor scaledGreen) // (1 + amount)
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5860
        scaledBlue:((blue * amount) + aColor scaledBlue) // (1 + amount)
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5861
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5862
    "
8437
936e15ec91dd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8285
diff changeset
  5863
     (Color red) mixed:1 with:(Color yellow)    - 1 part red, 1 part yellow
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5864
     (Color red) mixed:0.9 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5865
     (Color red) mixed:0.8 with:(Color yellow)
8437
936e15ec91dd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8285
diff changeset
  5866
     (Color red) mixed:0.5 with:(Color yellow)  - 1 part red, 2 parts yellow
936e15ec91dd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8285
diff changeset
  5867
     (Color red) mixed:0.25 with:(Color yellow) - 1 part red, 4 parts yellow  
936e15ec91dd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8285
diff changeset
  5868
     (Color red) mixed:0 with:(Color yellow)    - 0 parts red, 1 part yellow
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5869
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5870
     (Color red) mixed:1 with:(Color white)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5871
     (Color red) mixed:0.8 with:(Color white)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5872
     (Color red) mixed:0.8 with:(Color black)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5873
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5874
8165
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5875
    "Modified: / 10-02-1997 / 22:08:14 / cg"
dec0d9176839 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8163
diff changeset
  5876
    "Modified (comment): / 05-09-2017 / 14:35:40 / cg"
8437
936e15ec91dd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8285
diff changeset
  5877
    "Modified (comment): / 31-07-2018 / 21:32:52 / Claus Gittinger"
3724
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5878
!
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5879
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5880
slightlyDarkened
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5881
    "return a new color, which is a bit darker than the receiver"
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5882
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5883
    ^ self blendWith:(self blendWith:Black)
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5884
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5885
    "
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5886
     (Color green) inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5887
     (Color green) darkened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5888
     (Color green) slightlyDarkened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5889
    "
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5890
!
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5891
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5892
slightlyLightened
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5893
    "return a new color, which is a bit lighter than the receiver"
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5894
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5895
    ^ self blendWith:(self blendWith:White)
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5896
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5897
    "
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5898
     (Color red) inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5899
     (Color red) lightened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5900
     (Color red) slightlyLightened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5901
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5902
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5903
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5904
!Color methodsFor:'instance release'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5905
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5906
executor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5907
    "redefined, since for finalization only device and colorIndex
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5908
     are needed - thus a faster copy is possible here"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5909
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5910
    ^ DeviceColorHandle basicNew setDevice:device colorId:colorId
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5911
!
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5912
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5913
releaseFromDevice
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5914
    "I am no longer available on the device"
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5915
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  5916
    colorId := device := ditherForm := replacementColor := nil.
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5917
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5918
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5919
3122
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5920
!Color methodsFor:'misc'!
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5921
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5922
magnifiedTo: extent
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5923
    "do nothing here, for compatibility with Image/Form"
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5924
! !
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5925
6967
bd2a3899b4f9 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
  5926
4851
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5927
!Color methodsFor:'object persistency'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5928
4207
9e70f7998f66 elementDescriptorFor: instead of encodingVectorFor:
penk
parents: 4203
diff changeset
  5929
elementDescriptorFor:aspect
4851
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5930
    "support for persistency:
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5931
     answer the elements to be made persistent with an ObjectCoder"
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5932
3935
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5933
    red isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5934
	^ Array with:(#colorId->colorId)
3935
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5935
    ].
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5936
    ^ Array with:(#red->self red) with:(#green->self green) with:(#blue->self blue)
4851
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5937
! !
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5938
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5939
!Color methodsFor:'printing & storing'!
3935
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5940
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5941
hex
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5942
    <resource: #obsolete>
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5943
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5944
    self obsoleteMethodWarning:'use #hexPrintString'.
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5945
    ^ self hexPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5946
!
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5947
8063
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5948
hexPrintOn:aStream
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5949
    "print a base16 representation on aStream as rrggbb"
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5950
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5951
    red isNil ifTrue:[
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5952
        colorId notNil ifTrue:[
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5953
            colorId printOn:aStream base:16 size:6 fill:$0.
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5954
        ]
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5955
    ] ifFalse:[
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5956
        self redByte   printOn:aStream base:16 size:2 fill:$0.
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5957
        self greenByte printOn:aStream base:16 size:2 fill:$0.
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5958
        self blueByte  printOn:aStream base:16 size:2 fill:$0.
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5959
    ].
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5960
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5961
    "Created: / 08-08-2017 / 15:58:52 / stefan"
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5962
!
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5963
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5964
hexPrintString
4908
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5965
    "return a hex-printString as rrggbb"
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5966
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5967
    |s|
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5968
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5969
    s := WriteStream on:(String new:6).
8063
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5970
    self hexPrintOn:s.
4908
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5971
    ^ s contents.
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5972
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5973
    "
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5974
     Color red hexPrintString
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5975
     Color green hexPrintString
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5976
     Color blue hexPrintString
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5977
     Color yellow hexPrintString
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5978
    "
8063
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5979
e335948608ed #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8047
diff changeset
  5980
    "Modified: / 08-08-2017 / 15:59:38 / stefan"
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5981
!
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5982
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5983
htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5984
    "return a hex-printString for html as #rrggbb;"
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5985
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5986
    ^ '#',(self hexPrintString)
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5987
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5988
    "
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5989
     Color red htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5990
     Color green htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5991
     Color blue htmlPrintString
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5992
     Color yellow htmlPrintString
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5993
    "
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5994
!
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5995
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5996
printOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5997
    "append a string representing of the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5998
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5999
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6000
    self storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6001
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6002
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6003
storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6004
    "append a string representing an expression to reconstruct the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6005
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6006
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6007
    |clsName|
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6008
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6009
    clsName := self class name.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6010
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6011
    red isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6012
	colorId notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6013
	    aStream nextPutAll:'(' , clsName , ' colorId:'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6014
	    colorId storeOn:aStream.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6015
	    aStream nextPut:$).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6016
	    ^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6017
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6018
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6019
    (red == green and:[red == blue]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6020
	red == 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6021
	    aStream nextPutAll:'(' , clsName , ' black)'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6022
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6023
	    red == MaxValue ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6024
		aStream nextPutAll:'(' , clsName , ' white)'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6025
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6026
		aStream nextPutAll:'(' , clsName , ' grey:'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6027
		(self red) storeOn:aStream.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6028
		aStream nextPut:$).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6029
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6030
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6031
	^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6032
    ].
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6033
    aStream nextPutAll:'(' , clsName , ' red:'.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6034
    (self red) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6035
    aStream nextPutAll:' green:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6036
    (self green) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6037
    aStream nextPutAll:' blue:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6038
    (self blue) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6039
    aStream nextPut:$).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6040
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6041
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6042
!Color methodsFor:'private'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6043
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6044
restored
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6045
    "private: color has been restored (either from snapin or binary store);
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6046
     flush device stuff or reallocate a cell."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6047
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6048
    ditherForm := replacementColor := nil.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6049
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6050
    red notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6051
	device := nil.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6052
	colorId := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6053
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6054
	"a variable color has been restored"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6055
	(colorId notNil and:[writable == true and:[device notNil]]) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6056
	    colorId := device colorCell.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6057
	    device setColor:colorId scaledRed:red scaledGreen:green scaledBlue:blue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6058
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6059
    ]
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6060
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6061
    "Modified: 17.1.1997 / 00:04:14 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6062
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6063
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6064
setColorId:anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6065
    "private: set the deviceId"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6066
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6067
    colorId := anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6068
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6069
    "Created: 17.1.1997 / 00:05:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6070
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6071
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6072
setDevice:aDevice colorId:aNumber
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6073
    "private:set device and colorId"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6074
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6075
    device := aDevice.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6076
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6077
    writable := false.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6078
!
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6079
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6080
setDevice:aDevice colorId:aNumber writable:wBool
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6081
    "private:set device, colorId and writable flag"
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6082
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6083
    device := aDevice.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6084
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  6085
    writable := wBool.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6086
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6087
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6088
setDitherForm:aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6089
    "private: set the ditherForm"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6090
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6091
    ditherForm := aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6092
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6093
    "Created: 17.1.1997 / 00:04:57 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6094
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  6095
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  6096
setScaledRed:r scaledGreen:g scaledBlue:b
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6097
    "private: set the components"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6098
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6099
    red notNil ifTrue:[
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  6100
        "oops cannot change an existing color (you want to make red be green - or what)"
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  6101
        self error:'Colors cannot change their components'.
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  6102
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6103
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6104
    red := r.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6105
    green := g.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6106
    blue := b.
8277
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  6107
!
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  6108
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  6109
setScaledRed:r scaledGreen:g scaledBlue:b device:aDevice
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  6110
    "private: set the components"
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  6111
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  6112
    self setScaledRed:r scaledGreen:g scaledBlue:b.
942b74deecfe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8243
diff changeset
  6113
    device := aDevice.
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  6114
8243
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  6115
    "Modified: / 16-01-1997 / 22:39:26 / cg"
c16d146a30e1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8171
diff changeset
  6116
    "Modified (format): / 11-01-2018 / 12:25:46 / stefan"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6117
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6118
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6119
!Color methodsFor:'queries'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6120
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6121
averageColor
6793
4eb2c49db190 class: Color
Claus Gittinger <cg@exept.de>
parents: 6785
diff changeset
  6122
    "return the average color - that's myself.
4eb2c49db190 class: Color
Claus Gittinger <cg@exept.de>
parents: 6785
diff changeset
  6123
     This method has been added for compatibility with the image protocol."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6124
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6125
    ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6126
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6127
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6128
averageColorIn:aRectangle
7580
1c51d1d76b32 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7569
diff changeset
  6129
    "return the average color - that's myself.
6793
4eb2c49db190 class: Color
Claus Gittinger <cg@exept.de>
parents: 6785
diff changeset
  6130
     This method has been added for compatibility with the image protocol."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6131
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6132
    ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6133
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6134
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6135
brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6136
    "ST80 compatibility: return the grey intensity in [0..1]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6137
6384
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  6138
    red isNil ifTrue:[
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  6139
        "/ a hack for colorId:0 and colorId:1 pseudo mask colors.
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  6140
        colorId == 0 ifTrue:[^ 0].
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  6141
        ^ 1
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  6142
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6143
    ^ ((3 * red) + (6 * green) + (blue)) / 10.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6144
8171
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6145
    "
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6146
     Color black brightness -> 0.0
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6147
     Color white brightness -> 1.0
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6148
     Color red brightness   -> 0.3
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6149
     Color green brightness -> 0.6
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6150
     Color blue brightness  -> 0.1
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6151
    "
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6152
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6153
    "Modified: / 07-06-1996 / 19:42:21 / cg"
17c30710ed4a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
  6154
    "Modified (comment): / 10-09-2017 / 12:02:29 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6155
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6156
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6157
deltaFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6158
    "return the distance of the receiver from some color specified
6785
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
  6159
     by r/g/b values.
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
  6160
     A very questionable value;
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  6161
     basing the distance on rgb values is very bad
6785
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
  6162
     - better do a distance in a cie color cone"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6163
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6164
    ^ aColor deltaFromRed:self red green:self green blue:self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6165
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  6166
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6167
     Color red deltaFrom:(Color blue)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6168
     Color red deltaFrom:(Color yellow)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6169
     Color red deltaFrom:(Color red:50)
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  6170
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  6171
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6172
    "Created: 14.6.1996 / 20:07:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6173
    "Modified: 14.6.1996 / 20:49:32 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6174
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6175
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6176
deltaFromRed:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6177
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6178
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6179
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6180
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6181
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6182
    "
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  6183
    ^ ((self red - r) abs
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6184
      + (self green - g) abs
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  6185
      + (self blue - b) abs) rounded.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6186
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6187
    "Created: 14.6.1996 / 20:03:58 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6188
    "Modified: 14.6.1996 / 20:20:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6189
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6190
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6191
deltaFromScaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6192
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6193
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6194
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6195
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6196
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6197
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6198
    ^ (red - r) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6199
      + (green - g) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6200
      + (blue - b) abs.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6201
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6202
    "Created: 11.6.1996 / 18:01:12 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6203
    "Modified: 14.6.1996 / 20:36:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6204
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6205
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6206
errorFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6207
    "return some value which can be used to compare colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6208
     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
  6209
     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
  6210
     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
  6211
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6212
    ^ (red - aColor scaledRed) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6213
       + (green - aColor scaledGreen) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6214
       + (blue - aColor scaledBlue) squared.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6215
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6216
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6217
grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6218
    "return the grey intensity in percent [0..100] (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6219
6385
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  6220
    red isNil ifTrue:[
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  6221
        "/ a hack for colorId:0 and colorId:1 pseudo mask colors.
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  6222
        colorId == 0 ifTrue:[^ 0].
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  6223
        ^ 100
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  6224
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6225
    ^ ((3 * red) + (6 * green) + (1 * blue)) * 10.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6226
7758
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  6227
    "
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  6228
     Color red brightness
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  6229
     Color red grayIntensity
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  6230
    "
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  6231
    
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6232
    "Created: 2.5.1996 / 11:38:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6233
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6234
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6235
greyIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6236
    "return the grey intensity in percent [0..100] (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6237
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6238
    ^ self grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6239
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6240
    "Modified: 28.5.1996 / 20:45:41 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6241
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6242
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6243
isColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6244
    "return true if the receiver is a Color."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6245
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6246
    ^ true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6247
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6248
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  6249
isColorObject
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  6250
    ^ true
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  6251
!
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  6252
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6253
isDithered
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6254
    "return true, if this is a dithered Color.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6255
     Only makes sense if the receiver is a device color."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6256
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6257
    ^ ditherForm notNil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6258
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6259
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6260
isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6261
    "same as isGrayColor - for ST80 compatibility."
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6262
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6263
    ^ self isGrayColor
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6264
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6265
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6266
     (Color grey:50) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6267
     (Color red) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6268
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6269
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6270
    "Created: 10.2.1997 / 22:10:25 / cg"
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6271
!
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  6272
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6273
isGrayColor
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  6274
    "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
  6275
     i.e. red = green = blue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6276
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6277
    red ~~ green ifTrue:[^ false].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6278
    ^ red == blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6279
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6280
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6281
     (Color grey:50) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6282
     (Color red) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6283
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6284
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6285
    "Created: 2.5.1996 / 11:38:48 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6286
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6287
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6288
isGreyColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6289
    "return true, if this color is a grey one (English version ;-) -
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6290
     i.e. red = green = blue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6291
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6292
    ^ self isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6293
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6294
    "(Color grey:50) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6295
    "(Color red) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6296
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6297
    "Modified: 28.5.1996 / 20:44:36 / cg"
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6298
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6299
3598
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  6300
isOnDevice:aGraphicsDevice
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  6301
    "return true if i am allocated on aGraphicsDevice"
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  6302
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6303
    ^ device == aGraphicsDevice
3598
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  6304
      and:[colorId notNil or:[replacementColor notNil and:[replacementColor colorId notNil]]]
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  6305
!
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  6306
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6307
isOpaque
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6308
    "return true, if I represent an opaque color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6309
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6310
    ^ true
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6311
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6312
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6313
8163
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6314
isPseudoColor
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6315
    "for special uses only: 
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6316
        colors which ONLY hold alpha values or
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6317
        colorIDs (for example, for bit-blt operaions) 
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6318
        are called 'pseudo colors'"
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6319
     
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6320
    ^ red isNil
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6321
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6322
    "Created: / 05-09-2017 / 12:16:19 / cg"
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6323
!
55b4897a908f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8137
diff changeset
  6324
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6325
isTranslucent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6326
    "return true, if I represent a translucent color;
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6327
     that is: not completely opaque"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6328
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6329
    ^ false
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6330
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6331
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6332
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  6333
isTranslucentColor
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  6334
    "return true, if I represent a translucent color, but not transparent"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  6335
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  6336
    ^ false
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  6337
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  6338
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  6339
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6340
isTransparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6341
    "return true, if I represent a completely transparent color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6342
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6343
    ^ false
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  6344
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6345
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6346
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6347
!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
  6348
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6349
documentation
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6350
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6351
    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
  6352
    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
  6353
    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
  6354
    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
  6355
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6356
    [see also:]
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6357
	Color
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6358
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6359
    [author:]
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6360
	Claus Gittinger
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6361
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6362
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6363
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6364
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6365
!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
  6366
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6367
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
  6368
    "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
  6369
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6370
    device := aDevice.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6371
    colorId := anId.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6372
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6373
    "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
  6374
    "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
  6375
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6376
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6377
!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
  6378
3611
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3598
diff changeset
  6379
finalize
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6380
    "the color for which I am a handle was collected
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6381
     - release system resources"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6382
2096
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  6383
    |id|
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  6384
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  6385
    (id := colorId) notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6386
	colorId := nil.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  6387
	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
  6388
    ].
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6389
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6390
    "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
  6391
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  6392
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  6393
!Color class methodsFor:'documentation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6394
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6395
version
6967
bd2a3899b4f9 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
  6396
    ^ '$Header$'
5419
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  6397
!
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  6398
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  6399
version_CVS
6967
bd2a3899b4f9 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
  6400
    ^ '$Header$'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6401
! !
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
  6402
6110
28bccabea00a class: Color
Claus Gittinger <cg@exept.de>
parents: 5965
diff changeset
  6403
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  6404
Color initialize!