Color.st
author Claus Gittinger <cg@exept.de>
Mon, 13 Feb 2017 20:06:35 +0100
changeset 7885 0144afcdce5a
parent 7833 7cffe851a6d2
child 7909 c5f82e9429f9
permissions -rw-r--r--
#DOCUMENTATION by cg class: Color comment/format in: #contrastingColorFor: #onDevice:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     1
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
     3
	      All Rights Reserved
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     5
 This software is furnished under a license and may be used
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     6
 only in accordance with the terms of that license and with the
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
     9
 other person.  No title to or ownership of the software is
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    10
 hereby transferred.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    11
"
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
    12
"{ Package: 'stx:libview' }"
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
    13
6785
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
    14
"{ NameSpace: Smalltalk }"
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
    15
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    16
Object subclass:#Color
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    17
	instanceVariableNames:'red green blue device colorId ditherForm replacementColor
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    18
		writable'
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    19
	classVariableNames:'MaxValue Cells Black White LightGrey Grey DarkGrey Pseudo0
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
    20
		Pseudo1 PseudoAll Red Green Blue Yellow Orange RetryAllocation
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
    21
		DitherBits ColorErrorSignal ColorAllocationFailSignal
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
    22
		InvalidColorNameSignal StandardColorValues Transparent'
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    23
	poolDictionaries:''
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    24
	category:'Graphics-Support'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    25
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    26
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    27
Object subclass:#DeviceColorHandle
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    28
	instanceVariableNames:'device colorId'
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    29
	classVariableNames:''
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    30
	poolDictionaries:''
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
    31
	privateIn:Color
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    32
!
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
    33
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    34
!Color class methodsFor:'documentation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    35
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    36
copyright
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 (c) 1992 by Claus Gittinger
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
    39
	      All Rights Reserved
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    40
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    41
 This software is furnished under a license and may be used
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    42
 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
    43
 inclusion of the above copyright notice.   This software may not
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    44
 be provided or otherwise made available to, or used by, any
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    45
 other person.  No title to or ownership of the software is
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    46
 hereby transferred.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    47
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    48
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    49
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    50
documentation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    51
"
7782
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    52
    Color represents colors in a device independent manner.
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    53
    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
    54
    
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    55
    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
    56
    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
    57
    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
    58
    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
    59
    
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    60
    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
    61
    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
    62
    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
    63
    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
    64
    for old VGA-like displays 
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    65
    (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
    66
     So we will leave that support in for another few years ;-) ).
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    67
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
    68
    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
    69
    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
    70
    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
    71
    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
    72
    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
    73
    colormap (as usual for bitmaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    74
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    75
    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
    76
    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
    77
    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
    78
    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
    79
    to ugly looking dither colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    80
    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
    81
    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
    82
    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
    83
    (beside 5x5x5, there are various other size combinations available).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    84
    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
    85
    preallocated table may steal colors from the image ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    86
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    87
    [Instance variables:]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    88
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    89
      red             <Integer>       the red component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    90
      green           <Integer>       the green component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    91
      blue            <Integer>       the blue component (0..MaxValue)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    92
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    93
      device          <Device>        the device I am on, or nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    94
      colorId         <Object>        some device dependent identifier (or nil if dithered)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    95
      ditherForm      <Form>          the Form to dither this color (if non-nil)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    96
      writable        <Boolean>       true if this is for a writable color cell
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    97
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    98
    [Class variables:]
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
      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
   101
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   102
      Lobby           <Registry>      all colors in use - keeps track of already allocated
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   103
                                      colors for reuse and finalization.
7650
5781e05a6a1d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7642
diff changeset
   104
                                      (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
   105
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   106
      Cells           <Registry>      keeps track of allocated writable color cells
7650
5781e05a6a1d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7642
diff changeset
   107
                                      (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
   108
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   109
      FixColors       <Array>         preallocated colors for dithering on Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   110
      NumRedFix       <Integer>       number of distinct red values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   111
      NumGreenFix     <Integer>       number of distinct green values in FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   112
      NumBlueFix      <Integer>       number of distinct blue values in FixColors
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   113
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   114
      Black           <Color>         for fast return of black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   115
      White           <Color>         for fast return of white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   116
      Grey            <Color>         for fast return of grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   117
      LightGrey       <Color>         for fast return of lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   118
      DarkGrey        <Color>         for fast return of darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   119
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   120
      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
   121
      Pseudo1         <Color>         a color with 1 as handle (for forms)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   122
      PseudoAll       <Color>         a color with allPlanes as handle (for bitblit)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   123
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   124
      Red             <Color>         red, needed for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   125
      Green           <Color>         green, for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   126
      Blue            <Color>         blue, for dithering
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   127
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   128
      DitherColors    <Collection>    some preallocated colors for dithering
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   129
                                      (kept, so they are available when needed)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   130
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   131
      RetryAllocation <Boolean>       this flag controls how a request for a
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   132
                                      color should be handled which failed previously.
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   133
                                      I.e. a color is asked for, which was dithered
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   134
                                      the last time. Since it could happen, that in
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   135
                                      the meantime more colors became free, the request
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   136
                                      might succeed this time - however, your screen may
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   137
                                      look a bit funny, due to having both dithered and
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   138
                                      undithered versions around.
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   139
                                      The default is true, which means: do retry
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   140
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   141
    compatibility issues:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   142
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   143
        ST-80 seems to represent colors internally with scaled smallInteger
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   144
        components (this can be guessed from uses of
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   145
        scaledRed:scaledGreen:scaledBlue:). The main instance creation method is
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   146
        via 'ColorValue red:green:blue:', passing components in 0..1.
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   147
        In ST/X, component are internally represented as percent.
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   148
        For more compatibility (when subclassing color), these internals may
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   149
        change in the near future. For migration, a compatibility subclass
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   150
        called ColorValue is provided.
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   151
        After the change, Color will be renamed to ColorValue and Color
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   152
        be made a subclass of ColorValue (offering the 0..100 interface for
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   153
        backward compatibility).
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   154
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   155
    [see also:]
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   156
        DeviceWorkstation
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   157
        GraphicsContext DeviceDrawable Form Image Colormap
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   158
        Font Cursor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   159
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   160
    [author:]
6553
7d7458ec2686 class: Color
Claus Gittinger <cg@exept.de>
parents: 6552
diff changeset
   161
        Claus Gittinger
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   162
"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   163
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   164
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   165
!Color class methodsFor:'initialization'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   166
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   167
allocateColorsIn:aColorVector on:aDevice
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   168
    "{ Pragma: +optSpace }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   169
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   170
    "preallocates a nR x nG x nB colorMap for later use in dithering.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   171
     Doing so has the advantage that the system will never run out of colors,
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   172
     however, colors may be either inexact or dithered."
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   173
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   174
    |clr round
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   175
     devClr|
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   176
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   177
    round := 0.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   178
    1 to:aColorVector size do:[:dstIndex |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   179
	clr := aColorVector at:dstIndex.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   180
	devClr := clr exactOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   181
	devClr isNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   182
	    round == 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   183
		'Color [info]: scavenge to reclaim colors' infoPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   184
		ObjectMemory scavenge.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   185
		round := 1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   186
		devClr := clr exactOn:aDevice.
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
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   189
	devClr isNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   190
	    round == 1 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   191
		'Color [info]: collect garbage to reclaim colors' infoPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   192
		ObjectMemory performLowSpaceCleanup.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   193
		ObjectMemory garbageCollect; finalize.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   194
		round := 2.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   195
		devClr := clr exactOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   196
	   ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   197
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   198
	devClr isNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   199
	    ColorAllocationFailSignal raiseErrorString:'failed to allocate fix color'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   200
	    ^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   201
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   202
	aColorVector at:dstIndex put:devClr.
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   203
    ].
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   204
!
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   205
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   206
colorCubeWithRed:nRed green:nGreen blue:nBlue
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   207
    "{ Pragma: +optSpace }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   208
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   209
    |nR "{Class: SmallInteger }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   210
     nG "{Class: SmallInteger }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   211
     nB "{Class: SmallInteger }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   212
     dR dG dB red green blue dstIndex clr round
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   213
     colorCube|
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   214
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   215
    nR := nRed.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   216
    nG := nGreen.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   217
    nB := nBlue.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   218
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   219
    dR := 100.0 / (nR - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   220
    dG := 100.0 / (nG - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   221
    dB := 100.0 / (nB - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   222
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   223
    colorCube := Array new:(nR * nG * nB).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   224
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   225
    round := 0.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   226
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   227
    dstIndex := 1.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   228
    1 to:nR do:[:sR |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   229
	red := dR * (sR - 1).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   230
	1 to:nG do:[:sG |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   231
	    green := dG * (sG - 1).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   232
	    1 to:nB do:[:sB |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   233
		blue := dB * (sB - 1).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   234
		clr := self red:red green:green blue:blue.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   235
		colorCube at:dstIndex put:clr.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   236
		dstIndex := dstIndex + 1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   237
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   238
	]
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   239
    ].
3904
52925c65a8cc colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3903
diff changeset
   240
    ^ colorCube
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   241
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   242
    "Created: 11.7.1996 / 17:55:32 / cg"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   243
    "Modified: 10.1.1997 / 15:37:13 / cg"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   244
!
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   245
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   246
flushDeviceColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   247
    "unassign all colors from their device"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   248
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   249
    self allInstances do:[:aColor |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   250
	aColor restored
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   251
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   252
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   253
    "Modified: 24.2.1997 / 18:27:06 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   254
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   255
3240
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   256
flushDeviceColorsFor:aDevice
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   257
    self allInstancesDo:[:aColor |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   258
	aColor device == aDevice ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   259
	    aColor restored
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   260
	]
3240
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   261
    ]
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   262
!
c93e33069fb5 color reinitialization when coming up on another device
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   263
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   264
getColors6x6x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   265
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   266
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   267
    "preallocates a 6x6x4 (144) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   268
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   269
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   270
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   271
    self getColorsRed:6 green:6 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   272
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   273
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   274
     Color getColors6x6x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   275
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   276
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   277
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   278
getColors6x6x5
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   279
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   280
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   281
    "preallocates a 6x6x5 (180) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   282
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   283
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   284
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   285
    self getColorsRed:6 green:6 blue:5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   286
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   287
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   288
     Color getColors6x6x5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   289
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   290
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   291
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   292
getColors6x6x6
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   293
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   294
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   295
    "preallocates a 6x6x6 (196) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   296
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   297
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   298
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   299
    self getColorsRed:6 green:6 blue:6
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   300
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   301
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   302
     Color getColors6x6x6
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   303
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   304
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   305
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   306
getColors6x7x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   307
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   308
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   309
    "preallocates a 6x7x4 (168) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   310
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   311
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   312
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   313
    self getColorsRed:6 green:7 blue:4
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
     Color getColors6x7x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   317
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   318
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   319
    "Created: 12.6.1996 / 17:41:57 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   322
getColors7x8x4
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   323
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   324
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   325
    "preallocates a 7x8x4 (224) colorMap and later uses those colors only.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   326
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   327
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   328
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   329
    self getColorsRed:7 green:8 blue:4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   330
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   331
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   332
     Color getColors7x8x4
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   333
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   334
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   335
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   336
getColorsRed:nRed green:nGreen blue:nBlue
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   337
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   338
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   339
    "preallocates a nR x nG x nB colorMap for later use in dithering.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   340
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   341
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   342
2999
5e9272beef1b eliminated refs to Display - must use Screen current
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   343
    self getColorsRed:nRed green:nGreen blue:nBlue on:Screen current
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   344
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   345
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   346
     Color getColorsRed:2 green:2 blue:2
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   347
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   348
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   349
    "Modified: 11.7.1996 / 17:58:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   350
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   351
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   352
getColorsRed:nRed green:nGreen blue:nBlue on:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   353
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   354
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   355
    "preallocates a nR x nG x nB colorMap for later use in dithering.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   356
     Doing so has the advantage that the system will never run out of colors,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   357
     however, colors may be either inexact or dithered."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   358
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   359
    |nR "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   360
     nG "{Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   361
     nB "{Class: SmallInteger }"
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   362
     dR dG dB fixColors|
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   363
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   364
    aDevice visualType == #TrueColor ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   365
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   366
    nR := nRed.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   367
    nG := nGreen.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   368
    nB := nBlue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   369
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   370
    dR := 100.0 / (nR - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   371
    dG := 100.0 / (nG - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   372
    dB := 100.0 / (nB - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   373
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   374
    fixColors := self colorCubeWithRed:nRed green:nGreen blue:nBlue.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   375
    self allocateColorsIn:fixColors on:aDevice.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   376
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   377
    aDevice setFixColors:fixColors numRed:nR numGreen:nG numBlue:nB
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   378
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   379
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   380
     Color getColorsRed:2 green:2 blue:2 on:Display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   381
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   382
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   383
    "Created: 11.7.1996 / 17:55:32 / cg"
1165
a5334c030820 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1144
diff changeset
   384
    "Modified: 10.1.1997 / 15:37:13 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   385
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   386
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   387
getGrayColors:nGray on:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   388
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   389
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   390
    "preallocates nGray gray colors for later use in dithering.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   391
     Doing so has the advantage that the system will never run out of colors,
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   392
     however, colors may be either inexact or dithered."
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   393
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   394
    |nG "{Class: SmallInteger }"
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   395
     d fixGrayColors|
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   396
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   397
    aDevice visualType == #TrueColor ifTrue:[^ self].
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   398
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   399
    nG := nGray.
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   400
    d := 100.0 / (nG - 1).
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   401
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   402
    fixGrayColors := self grayColorVector:nGray.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   403
    self allocateColorsIn:fixGrayColors on:aDevice.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   404
1770
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   405
    aDevice setFixGrayColors:fixGrayColors
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   406
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   407
    "
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   408
     Color getGrayColors:16 on:Display
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   409
    "
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   410
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   411
    "Created: 23.6.1997 / 15:29:50 / cg"
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   412
!
144dc9afae32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1707
diff changeset
   413
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   414
getPrimaryColorsOn:aDevice
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   415
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   416
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   417
    "preallocate the primary colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   418
     Doing so during early startup prevents us from running out
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   419
     of (at least those required) colors later.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   420
     This guarantees, that at least some colors are available
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   421
     for dithering (although, with only black, white, red, green and blue,
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   422
     dithered images look very poor)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   423
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   424
    |colors white black red green blue clr dDepth
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   425
     lastPix "{ Class: SmallInteger }" |
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   426
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   427
    (aDevice notNil and:[aDevice ditherColors isNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   428
	white := (self red:100 green:100 blue:100) exactOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   429
	white colorId isNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   430
	    'Color [warning]: cannot allocate white color' errorPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   431
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   432
	black := (self red:0 green:0 blue:0) exactOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   433
	black colorId isNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   434
	    'Color [warning]: cannot allocate black color' errorPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   435
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   436
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   437
	aDevice hasColors ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   438
	    red := (self red:100 green:0 blue:0) exactOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   439
	    green := (self red:0 green:100 blue:0) exactOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   440
	    blue := (self red:0 green:0 blue:100) exactOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   441
	    (red isNil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   442
	    or:[green isNil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   443
	    or:[blue isNil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   444
	    or:[red colorId isNil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   445
	    or:[green colorId isNil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   446
	    or:[blue colorId isNil]]]]]) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   447
		'Color [warning]: cannot allocate primary color(s)' errorPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   448
		dDepth := aDevice depth.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   449
		((dDepth >= 4) and:[dDepth <= 8]) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   450
		    "/
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   451
		    "/ see what we have ...
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   452
		    "/
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   453
		    lastPix := (1 bitShift:dDepth) - 1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   454
		    0 to:lastPix do:[:pixel |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   455
			colors := OrderedCollection new.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   456
			aDevice getRGBFrom:pixel into:[:r :g :b |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   457
			    colors add:((Color red:r green:g blue:b) exactOn:aDevice).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   458
			]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   459
		    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   460
		    red := (self red:100 green:0 blue:0) nearestOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   461
		    green := (self red:0 green:100 blue:0) nearestOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   462
		    blue := (self red:0 green:0 blue:100) nearestOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   463
		] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   464
		    aDevice hasColors:false.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   465
		    aDevice hasGrayscales:false.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   466
		    red := green := blue := nil.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   467
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   468
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   469
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   470
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   471
	aDevice == Display ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   472
	    "/ keep those around for the main display
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   473
	    White := white.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   474
	    Black := black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   475
	    Red := red.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   476
	    Green := green.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   477
	    Blue := blue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   478
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   479
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   480
	aDevice visualType ~~ #TrueColor ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   481
	    aDevice hasColors ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   482
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   483
		"preallocate some colors for dithering
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   484
		 - otherwise, they may not be available when we need them ...
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   485
		 these are: black, white, grey50,
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   486
			    red, green, blue, yellow, cyan and magenta.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   487
		"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   488
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   489
		colors := OrderedCollection new.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   490
		clr := (self gray:50) exactOn:aDevice.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   491
		(clr notNil and:[clr colorId notNil]) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   492
		    colors add:clr
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   493
		].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   494
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   495
		colors add:white; add:black; add:red; add:green; add:blue.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   496
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   497
		colors add:((self red:100 green:100 blue:0) exactOn:aDevice).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   498
		colors add:((self red:100 green:0 blue:100) exactOn:aDevice).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   499
		colors add:((self red:0 green:100 blue:100) exactOn:aDevice).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   500
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   501
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   502
	    aDevice hasGrayscales ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   503
		aDevice hasColors ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   504
		    colors := OrderedCollection new.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   505
		    colors add:((self gray:50) exactOn:aDevice).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   506
		    colors add:white; add:black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   507
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   508
		].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   509
		colors add:((self gray:25) exactOn:aDevice).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   510
		colors add:((self gray:33) exactOn:aDevice).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   511
		colors add:((self gray:67) exactOn:aDevice).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   512
		colors add:((self gray:75) exactOn:aDevice).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   513
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   514
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   515
	    colors notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   516
		colors := colors select:[:clr | clr notNil and:[clr colorId notNil]].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   517
		aDevice setDitherColors:(colors asArray).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   518
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   519
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   520
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   521
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   522
    "Created: 11.7.1996 / 18:09:28 / cg"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   523
    "Modified: 21.10.1997 / 02:42:28 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   524
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   525
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   526
grayColorVector:nGray
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   527
    |nG "{Class: SmallInteger }"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   528
     d gray dstIndex clr round
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   529
     grayColors|
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   530
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   531
    nG := nGray.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   532
    d := 100.0 / (nG - 1).
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   533
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   534
    grayColors := Array new:nG.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   535
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   536
    round := 0.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   537
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   538
    dstIndex := 1.
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   539
    1 to:nG do:[:sG |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   540
	gray := d * (sG - 1).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   541
	clr := self red:gray green:gray blue:gray.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   542
	grayColors at:dstIndex put:clr.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   543
	dstIndex := dstIndex + 1
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   544
    ].
3904
52925c65a8cc colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3903
diff changeset
   545
    ^ grayColors
3903
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   546
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   547
    "
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   548
     Color getGrayColors:16 on:Display
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   549
    "
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   550
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   551
    "Created: 23.6.1997 / 15:29:50 / cg"
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   552
!
dde30ac28db3 colorCube code refactored
Claus Gittinger <cg@exept.de>
parents: 3898
diff changeset
   553
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   554
initialize
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   555
    "setup tracker of known colors and initialize classvars with
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   556
     heavily used colors"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   557
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   558
    ColorErrorSignal isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   559
	ColorErrorSignal := Error newSignalMayProceed:true.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   560
	ColorErrorSignal nameClass:self message:#colorErrorSignal.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   561
	ColorErrorSignal notifierString:'color error'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   562
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   563
	ColorAllocationFailSignal := ColorErrorSignal newSignalMayProceed:true.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   564
	ColorAllocationFailSignal nameClass:self message:#colorAllocationFailSignal.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   565
	ColorAllocationFailSignal notifierString:'color allocation failed'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   566
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   567
	InvalidColorNameSignal := ColorErrorSignal newSignalMayProceed:true.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   568
	InvalidColorNameSignal nameClass:self message:#invalidColorNameSignal.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   569
	InvalidColorNameSignal notifierString:'invalid color name'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   570
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   571
	MaxValue := 16rFFFF.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   572
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   573
	"want to be informed when returning from snapshot"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   574
	ObjectMemory addDependent:self.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   575
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   576
	RetryAllocation := true.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   577
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   578
	DitherBits := self ditherBits.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   579
	self initializeStandardColorNames.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   580
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   581
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   582
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   583
     Color initialize
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   584
    "
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   585
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   586
    "Modified: / 30.9.1998 / 21:56:50 / cg"
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   587
!
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   588
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   589
initializeStandardColorNames
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   590
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   591
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   592
    "setup standard colors"
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   593
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   594
    StandardColorValues := Dictionary new.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   595
    #(
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   596
		'red'     (16rFFFF 16r0000 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   597
		'green'   (16r0000 16rFFFF 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   598
		'blue'    (16r0000 16r0000 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   599
		'yellow'  (16rFFFF 16rFFFF 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   600
		'magenta' (16rFFFF 16r0000 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   601
		'cyan'    (16r0000 16rFFFF 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   602
		'white'   (16rFFFF 16rFFFF 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   603
		'black'   (16r0000 16r0000 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   604
		'olive'   (16r7FFF 16r7FFF 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   605
		'teal'    (16r0000 16r7FFF 16r7FFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   606
		'silver'  (16r6666 16r6666 16r6666)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   607
		'lime'    (16r3333 16rFFFF 16r0000)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   608
		'fuchsia' (16r9999 16r07ae 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   609
		'aqua'    (16r199a 16rFFFF 16rFFFF)
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   610
    ) pairWiseDo:[:name :value |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   611
	StandardColorValues at:name put:value
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   612
    ].
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   613
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   614
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   615
     Color initializeStandardColorNames
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   616
    "
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   617
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   618
    "Modified: 6.3.1997 / 02:28:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   619
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   620
3930
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   621
standardDitherColorsForDepth8
3931
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   622
    "return a set of colors useful for dithering (roughly 200 colors);
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   623
     This includes a color cube and the main grayScale colors."
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   624
3930
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   625
    |ditherColors|
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   626
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   627
    ditherColors := self colorCubeWithRed:6 green:8 blue:4.
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   628
    ditherColors := ditherColors ,
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   629
		    (Array
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   630
			with:(Color gray:20)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   631
			with:(Color gray:25)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   632
			with:(Color gray:40)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   633
			with:(Color gray:50)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   634
			with:(Color gray:60)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   635
			with:(Color gray:75)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   636
			with:(Color gray:80)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   637
			with:(Color rgbValue:16rBFBFBF)).
3930
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   638
    ^ ditherColors
3931
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   639
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   640
    "
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   641
     self standardDitherColorsForDepth8
417757ef9695 +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   642
    "
3930
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   643
!
1eb2b8d1d01d +standardDitherColorsForDepth8
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   644
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   645
update:something with:aParameter from:changedObject
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   646
    "handle image restarts and flush any device resource handles"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   647
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   648
    (something == #returnFromSnapshot) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   649
	Display notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   650
	    Display visualType == #TrueColor ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   651
		Display releaseFixColors
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   652
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   653
		Display fixColors notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   654
		    ColorAllocationFailSignal handle:[:ex |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   655
			ex return
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   656
		    ] do:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   657
			|nR nG nB|
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   658
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   659
			nR := Display numFixRed.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   660
			nG := Display numFixGreen.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   661
			nB := Display numFixBlue.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   662
			Display releaseFixColors.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   663
			self getColorsRed:nR
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   664
				    green:nG
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   665
				     blue:nB
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   666
				       on:Display
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   667
		    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   668
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   669
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   670
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   671
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   672
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   673
    "Created: 15.6.1996 / 15:14:03 / cg"
1370
37dfdffdd4b6 getPrimaryColors now invoked from device
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
   674
    "Modified: 24.2.1997 / 22:08:05 / cg"
4535
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   675
!
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   676
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   677
vgaColors
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   678
    "{ Pragma: +optSpace }"
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   679
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   680
    |colors|
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   681
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   682
    colors := Array new:16.
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   683
    colors at:1 put:(Color rgbValue:16rFFFFFF).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   684
    colors at:2 put:(Color rgbValue:16rC0C0C0).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   685
    colors at:3 put:(Color rgbValue:16r808080).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   686
    colors at:4 put:(Color rgbValue:16r000000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   687
    colors at:5 put:(Color rgbValue:16rFF0000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   688
    colors at:6 put:(Color rgbValue:16r800000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   689
    colors at:7 put:(Color rgbValue:16r008000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   690
    colors at:8 put:(Color rgbValue:16r00FF00).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   691
    colors at:9 put:(Color rgbValue:16r0000FF).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   692
    colors at:10 put:(Color rgbValue:16r000080).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   693
    colors at:11 put:(Color rgbValue:16rFF00FF).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   694
    colors at:12 put:(Color rgbValue:16r800080).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   695
    colors at:13 put:(Color rgbValue:16rFFFF00).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   696
    colors at:14 put:(Color rgbValue:16r808000).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   697
    colors at:15 put:(Color rgbValue:16r00FFFF).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   698
    colors at:16 put:(Color rgbValue:16r008080).
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   699
    ^ colors
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   700
9b9d6b7fa221 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4533
diff changeset
   701
    "Created: / 07-07-2006 / 13:36:15 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   702
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   703
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   704
!Color class methodsFor:'instance creation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   705
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   706
allColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   707
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   708
     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
   709
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   710
    PseudoAll isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   711
	PseudoAll := self basicNew setColorId:-1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   712
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   713
    ^ PseudoAll
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   714
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   715
    "Modified: 17.1.1997 / 00:05:36 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   716
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   717
2455
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   718
bgrValue:bgr
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   719
    "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
   720
     The value is composed of b<<16 + g<<8 + r.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   721
     (this byte-order is sometimes encountered with windows systems (progs)"
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   722
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   723
    |r g b|
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   724
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   725
    b := (bgr bitShift:-16) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   726
    g := (bgr bitShift:-8) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   727
    r := (bgr) bitAnd:16rFF.
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   728
    ^ self redByte:r greenByte:g blueByte:b
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   729
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   730
!
9d61d6c0d0f9 added #bgrValue (sigh)
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
   731
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   732
blue: blue
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   733
    "return a color from blue value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   734
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   735
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   736
    ^ here
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   737
	scaledRed:0 scaledGreen:0 scaledBlue:(blue * MaxValue // 100)
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   738
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   739
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   740
     (Color blue:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   741
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   742
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   743
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   744
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   745
brightness:brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   746
    "create a gray color with given brightness (0..1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   747
     ST-80 compatibility."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   748
3264
ab71c2bd250f fixed #brightness:
Claus Gittinger <cg@exept.de>
parents: 3240
diff changeset
   749
    ^ self scaledGray:(brightness * MaxValue) rounded
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   750
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   751
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   752
colorId:id
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   753
    "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
   754
     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
   755
     or for bitblits if you want to manipulate a specific colorplane."
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
    id == 0 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   758
	^ self noColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   759
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   760
    id == 1 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   761
	Pseudo1 isNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   762
	    Pseudo1 := self basicNew setColorId:1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   763
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   764
	^ Pseudo1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   765
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   766
    id == -1 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   767
	^ self allColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   768
    ].
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   769
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   770
    ^ self basicNew setColorId:id
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   771
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   772
    "Modified: 24.2.1997 / 18:16:30 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   773
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   774
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   775
cyan:c magenta:m yellow:y
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   776
    "return a color from cyan, magenta and yellow values.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   777
     all values are given in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   778
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   779
    ^ self
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   780
	redPercent:(100 - c)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   781
	greenPercent:(100 - m)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   782
	bluePercent:(100 - y)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   783
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   784
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   785
     Color cyan:100 magenta:0 yellow:0      - cyan
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   786
     Color cyan:100 magenta:100 yellow:0    - blue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   787
     Color cyan:100 magenta:0 yellow:100    - green
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   788
     Color cyan:100 magenta:100 yellow:100  - black
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   789
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   790
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   791
    "Modified: 11.6.1996 / 18:29:15 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   792
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   793
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   794
cyan:c magenta:m yellow:y black:k
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   795
    "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
   796
     all values are given in percent (0..100).
2889
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   797
     The value returned here is questionable.
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   798
     TODO: we loose information about one component here,
143b466ea54b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2888
diff changeset
   799
     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
   800
     information internally for later use (when saving)."
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   801
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   802
    |scale r g b|
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   803
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   804
    "/ mhmh - how should we scale black into the components ?
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   805
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   806
    r := (100 - c).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   807
    g := (100 - m).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   808
    b := (100 - y).
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   809
    k ~~ 0 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   810
	"/ more black - darker
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   811
	scale := (100-k) max:0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   812
	scale := scale / 100.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   813
	r := r * scale.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   814
	g := g * scale.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   815
	b := b * scale.
2888
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   816
    ].
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   817
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   818
    ^ self redPercent:r greenPercent:g bluePercent:b
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   819
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   820
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   821
     Color cyan:100 magenta:0 yellow:0 black:0      - cyan
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   822
     Color cyan:100 magenta:0 yellow:0 black:50     - cyan darkened
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   823
     Color cyan:100 magenta:50 yellow:50 black:0    - cyan darkened
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   824
     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
   825
    "
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   826
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   827
    "Modified: 11.6.1996 / 18:29:15 / cg"
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   828
!
ce7e932e7cf6 added cyan:magenta:yellow:black
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
   829
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   830
dither:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   831
    "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
   832
     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
   833
     colors.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   834
     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
   835
     (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
   836
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   837
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   838
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   839
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   840
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   841
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   842
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   843
    (c1 isNil or:[c2 isNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   844
	'Color [warning]: monoDither failed - no real colors given' errorPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   845
	^ nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   846
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   847
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   848
    self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   849
	monoDitherFor:fraction
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   850
	between:c1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   851
	and:c2
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   852
	on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   853
	into:[:c :f | newColor := c. form := f].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   854
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   855
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   856
    form isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   857
	"/ cannot happen
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   858
	'Color [warning]: monoDither failed' errorPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   859
	^ nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   860
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   861
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   862
    newColor := self basicNew
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   863
			setScaledRed:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   864
			scaledGreen:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   865
			scaledBlue:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   866
			device:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   867
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   868
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   869
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   870
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   871
    "
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   872
     (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
   873
     (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
   874
     (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
   875
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   876
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   877
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   878
    "Modified: 3.5.1997 / 11:10:51 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   879
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   880
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   881
dithered:fraction between:color1 and:color2 on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   882
    "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
   883
     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
   884
     colors.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   885
     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
   886
     (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
   887
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   888
    |newColor form c1 c2|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   889
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   890
    "/ both must be true device colors
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   891
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   892
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   893
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   894
    (c1 isNil or:[c2 isNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   895
	'Color [warning]: monoDither failed - no real colors given' errorPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   896
	^ nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   897
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   898
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   899
    self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   900
	monoDitherFor:fraction
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   901
	between:c1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   902
	and:c2
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   903
	on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   904
	into:[:c :f | newColor := c. form := f].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   905
    newColor notNil ifTrue:[^ newColor].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   906
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   907
    form isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   908
	"/ cannot happen
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   909
	'Color [warning]: monoDither failed' errorPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   910
	^ nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   911
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   912
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   913
    newColor := self basicNew
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   914
			setScaledRed:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   915
			scaledGreen:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   916
			scaledBlue:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   917
			device:aDevice.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   918
    newColor setDitherForm:form.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   919
    newColor setDevice:aDevice colorId:nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   920
    ^ newColor
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   921
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   922
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   923
     |c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   924
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   925
     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
   926
     c inspect.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   927
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   928
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   929
     |v c|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   930
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   931
     v := StandardSystemView new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   932
     v extent:100@100.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   933
     v openAndWait.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   934
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   935
     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
   936
     v paint:c.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   937
     v fillRectangle:(10@10 corner:90@90).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   938
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   939
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   940
    "Created: 3.5.1997 / 10:54:32 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   941
    "Modified: 3.5.1997 / 11:13:12 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   942
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   943
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   944
fromUser
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   945
    "{ Pragma: +optSpace }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
   946
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   947
    "let user point on a screen pixel.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   948
     Return an instance for that pixels color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   949
4896
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   950
    ^ self fromUserWithFeedBack:nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   951
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   952
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   953
     Color fromUser
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   954
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   955
1976
fcf9afd72f0f Do not use obsolete method Color>>at:
Stefan Vogel <sv@exept.de>
parents: 1971
diff changeset
   956
    "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
   957
    "Modified: / 9.1.1998 / 20:48:58 / stefan"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   958
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   959
4896
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   960
fromUserWithFeedBack:feedbackBlockOrNil
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   961
    "{ Pragma: +optSpace }"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   962
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   963
    "let user point on a screen pixel.
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   964
     Return an instance for that pixels color"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   965
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   966
    |p screen|
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   967
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   968
    screen := Screen current.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   969
    p := screen
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   970
	    pointFromUserShowing:(Cursor crossHair)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   971
	    positionFeedback:[:p |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   972
				feedbackBlockOrNil notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   973
				    feedbackBlockOrNil value:(screen colorAt:p)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   974
				]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   975
			    ].
4896
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   976
    ^ screen colorAt:p
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   977
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   978
    "
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   979
     Color fromUserWithFeedBack:nil
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   980
    "
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   981
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   982
    "Modified: / 31.8.1995 / 01:34:22 / claus"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   983
    "Modified: / 9.1.1998 / 20:48:58 / stefan"
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   984
!
bd1f161a578a added feedback option in color-fromUser
Claus Gittinger <cg@exept.de>
parents: 4851
diff changeset
   985
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   986
green:green
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   987
    "return a color from green value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   988
     the argument green is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   989
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   990
    ^ here
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
   991
	scaledRed:0 scaledGreen:(green * MaxValue // 100) scaledBlue:0
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   992
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   993
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   994
     (Color green:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   995
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
   996
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   997
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
   998
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   999
hue:h light:l saturation:s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1000
    "return a color from hue, light and saturation values.
7569
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
  1001
     Hue is in degrees (0..360); light and saturation are
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1002
     in percent (0..100)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1003
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1004
    self withRGBFromHue:h light:l saturation:s do:[:r :g :b |
7569
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
  1005
        ^ self
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
  1006
            redPercent:(r clampBetween:0 and:100)
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
  1007
            greenPercent:(g clampBetween:0 and:100)
872e25793b0e #DOCUMENTATION by mawalch
mawalch
parents: 7430
diff changeset
  1008
            bluePercent:(b clampBetween:0 and:100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1009
    ]
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1010
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1011
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1012
     Color hue:0 light:50 saturation:100     - red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1013
     Color hue:60 light:50 saturation:100    - yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1014
     Color hue:120 light:50 saturation:100   - green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1015
     Color hue:120 light:75 saturation:100   - bright green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1016
     Color hue:120 light:25 saturation:100   - dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1017
     Color hue:120 light:50 saturation:50    - greyish dark green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1018
     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
  1019
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1020
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1021
    "Modified: 23.4.1996 / 13:22:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1022
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1023
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1024
name:colorName
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1025
    "Return a named color (either exact or dithered).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1026
     Report an error, if aString is not a valid color name.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1027
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1028
     We hereby only guarantee that the 8 basic colors are supported
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1029
     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
  1030
     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
  1031
     common names)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1032
     - use with special names (such as 'mediumGoldenRod' is not recommended).
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1033
     Better use: #name:ifIllegal: and provide a fallBack."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1034
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1035
    ^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1036
	name:colorName
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1037
	ifIllegal:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1038
	    InvalidColorNameSignal
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1039
		raiseRequestWith:colorName errorString:' : ' , colorName
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1040
	]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1041
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1042
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1043
     Color name:'brown'
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1044
     Color name:'snow'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1045
     Color name:'foo'
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1046
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1047
1534
73dd2c4b86c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1502
diff changeset
  1048
    "Modified: 4.4.1997 / 15:32:33 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1049
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1050
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1051
name:colorName ifIllegal:errorBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1052
    "Return a named color (either exact or dithered).
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1053
     If aString is not a valid color name,
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1054
     return the result from evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1055
3399
02a4018f9549 care for no-display case when asking for a color-by-name
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
  1056
    |triple r g b currScreen|
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1057
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1058
    triple := StandardColorValues at:colorName asString ifAbsent:nil.
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1059
    triple notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1060
	r := triple at:1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1061
	g := triple at:2.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1062
	b := triple at:3.
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1063
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1064
	"/ ask display (if there is one) ...
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1065
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1066
	(Screen notNil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1067
	and:[ (currScreen := Screen current) notNil])
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1068
	ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1069
	    currScreen
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1070
		getScaledRGBFromName:colorName
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1071
		into:[:rr :gg :bb |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1072
		    r := rr.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1073
		    g := gg.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1074
		    b := bb
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1075
		].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1076
	]
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1077
    ].
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1078
    r notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1079
	^ here scaledRed:r scaledGreen:g scaledBlue:b
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1080
    ].
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  1081
    ^ errorBlock value
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1082
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1083
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1084
     Color name:'brown' ifIllegal:[Color black]
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1085
     Color name:'red' ifIllegal:[Color black]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1086
     Color name:'fuchsia' ifIllegal:[Color black]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1087
     Color name:'foo' ifIllegal:[Color black]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1088
     Color name:'foo' ifIllegal:[nil]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1089
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1090
1428
79251ddda7a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1091
    "Modified: 6.3.1997 / 02:32:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1092
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1093
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1094
noColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1095
    "return a special color which, when used for bit-blitting will
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1096
     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
  1097
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1098
     Pseudo0 isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1099
	 Pseudo0 := self basicNew setColorId:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1100
     ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1101
     ^ Pseudo0
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1102
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1103
    "Modified: 17.1.1997 / 00:06:49 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1104
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1105
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1106
red:red
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1107
    "return a color from red value;
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1108
     the argument r is interpreted as percent (0..100)"
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1109
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1110
    ^ here
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1111
	scaledRed:(red * MaxValue // 100) scaledGreen:0 scaledBlue:0
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1112
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1113
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1114
     (Color red:50) inspect
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1115
    "
1985
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1116
!
4af804551b39 some instancing methods added
tz
parents: 1976
diff changeset
  1117
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1118
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1119
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1120
     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
  1121
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1122
    ^ here scaledRed:(r * MaxValue // 100)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1123
	   scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1124
	   scaledBlue:(b * MaxValue // 100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1125
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1126
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1127
redByte:r greenByte:g blueByte:b
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1128
    "return a color from red, green and blue values;
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1129
     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
  1130
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1131
    ^ here scaledRed:(r * MaxValue // 255)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1132
	   scaledGreen:(g * MaxValue // 255)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1133
	   scaledBlue:(b * MaxValue // 255)
1237
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1134
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1135
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1136
     (Color redByte:255 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1137
     (Color redByte:255 greenByte:255 blueByte:255) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1138
     (Color redByte:0 greenByte:0 blueByte:0) inspect
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1139
    "
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1140
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1141
    "Modified: 16.1.1997 / 23:32:43 / cg"
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1142
!
15848ece8b95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1143
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1144
redByte:r greenByte:g blueByte:b alphaByte:a
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1145
    "return a color from red, green, blue and alpha values;
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1146
     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
  1147
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1148
    ^ (here scaledRed:(r * MaxValue // 255)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1149
	   scaledGreen:(g * MaxValue // 255)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1150
	   scaledBlue:(b * MaxValue // 255))
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1151
	   alpha:(a / 255)
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1152
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1153
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1154
     (Color redByte:255 greenByte:0 blueByte:0 alphaByte:127) 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 / 11:15:47 / cg"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1158
!
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1159
5144
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1160
redFraction:r greenFraction:g blueFraction:b
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1161
    "return a color from red, green and blue values;
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1162
     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
  1163
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1164
    ^ here scaledRed:(r * MaxValue) rounded
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1165
	   scaledGreen:(g * MaxValue) rounded
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1166
	   scaledBlue:(b * MaxValue) rounded
5144
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1167
!
d93391e9ea8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5131
diff changeset
  1168
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1169
redPercent:r greenPercent:g bluePercent:b
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1170
    "return a color from red, green and blue values;
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1171
     the arguments, r, g and b are interpreted as percent (0..100)"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1172
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1173
    ^ here scaledRed:(r * MaxValue // 100)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1174
	   scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1175
	   scaledBlue:(b * MaxValue // 100)
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1176
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1177
5127
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1178
redPercent:r greenPercent:g bluePercent:b alphaPercent:a
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1179
    "return a color from red, green and blue values;
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1180
     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
  1181
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1182
    ^ (here scaledRed:(r * MaxValue // 100)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1183
	   scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1184
	   scaledBlue:(b * MaxValue // 100))
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1185
	   alpha:(a * 255 // 100)
5127
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1186
!
40d2ac51c76d color conversions fixed (16bit images)
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1187
3956
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1188
redShort:r greenShort:g blueShort:b
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1189
    "return a color from red, green and blue short values;
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1190
     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
  1191
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1192
    ^ here scaledRed:(r * MaxValue // 16rFFFF)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1193
	   scaledGreen:(g * MaxValue // 16rFFFF)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1194
	   scaledBlue:(b * MaxValue // 16rFFFF)
3956
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1195
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1196
    "
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1197
     (Color redShort:16rFFFF greenShort:0 blueShort:0) inspect
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1198
    "
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1199
!
74f5434f3e38 +redShort:greenShort:blueShort:
Claus Gittinger <cg@exept.de>
parents: 3935
diff changeset
  1200
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1201
rgbValue:rgb
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  1202
    "return a color from a 24bit RGB value;
1859
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1203
     The value is composed of r<<16 + g<<8 + b."
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1204
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1205
    |r g b|
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1206
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1207
    r := (rgb bitShift:-16) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1208
    g := (rgb bitShift:-8) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1209
    b := (rgb) bitAnd:16rFF.
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1210
    ^ self redByte:r greenByte:g blueByte:b
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1211
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1212
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1213
     (Color rgbValue:16rFF0000) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1214
     (Color rgbValue:16r00FF00) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1215
     (Color rgbValue:16r0000FF) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1216
     (Color rgbValue:16rFF00FF) inspect
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1217
    "
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1218
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1219
    "Modified: 13.8.1997 / 20:24:37 / cg"
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1220
!
b483006c48f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1856
diff changeset
  1221
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1222
scaledGray:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1223
    "return a gray color with a scaled gray value (0..MaxValue)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1224
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1225
    ^ self scaledRed:aGrayValue scaledGreen:aGrayValue scaledBlue:aGrayValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1226
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1227
    "Modified: 11.6.1996 / 16:31:42 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1230
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1231
    "return a color from red, green and blue values;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1232
     the arguments, r, g and b are interpreted as (0..MaxValue)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1233
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1234
    |newColor|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1235
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1236
"/    "look if already known"
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1237
"/
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1238
"/    aDevice deviceColors do:[:aColor |
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1239
"/        (r == aColor scaledRed) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1240
"/            (g == aColor scaledGreen) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1241
"/                (b == aColor scaledBlue) ifTrue:[
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1242
"/                    ^ aColor
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1243
"/                ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1244
"/            ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1245
"/        ]
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1246
"/    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1247
    newColor := self basicNew setScaledRed:r scaledGreen:g scaledBlue:b device:nil.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1248
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1249
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1250
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1251
     (Color red:100 green:0 blue:0) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1252
     (Color red:100 green:50 blue:50) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1253
     (Color red:50 green:0 blue:0) inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1254
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1255
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1256
    "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
  1257
    "Modified: 24.2.1997 / 18:18:47 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1258
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1259
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1260
variableColorOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1261
    "return a variable color (i.e. allocate a writable colorcell) on
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1262
     aDevice. The returned color is not shared and its rgb components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1263
     are initially undefined. The components can be set to any value
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1264
     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
  1265
     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
  1266
     being a pseudocolor device using colormaps).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1267
     Returns nil, if no more colorCells are available, or the display
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1268
     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
  1269
     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
  1270
     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
  1271
     things in another color)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1272
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1273
    |c lutIndex|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1274
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1275
    lutIndex := aDevice colorCell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1276
    lutIndex isNil ifTrue:[^ nil].
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
    c := self new.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  1279
    c setDevice:aDevice colorId:lutIndex writable:true.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1280
    Cells isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1281
	Cells := Registry new.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1282
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1283
    Cells register:c.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1284
    ^ c
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1285
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1286
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1287
     |l cell|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1288
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1289
     l := Label new.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1290
     l label:('hello' asText allBold).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1291
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1292
     cell := Color variableColorOn:(Screen current).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1293
     l foregroundColor:cell.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1294
     [
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1295
	1 to:40 do:[:i|
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1296
	    i odd ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1297
		cell red:100 green:0 blue:0
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1298
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1299
		cell red:0 green:0 blue:0
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1300
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1301
	    Display flush.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1302
	    (Delay forSeconds:0.4) wait
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1303
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1304
	l destroy.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1305
     ] fork.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1306
     l open
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1307
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1308
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1309
    "Modified: 13.5.1996 / 12:41:53 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1310
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1311
3892
fb62c937c134 category
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  1312
!Color class methodsFor:'Compatibility-Squeak'!
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1313
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1314
colorPaletteForDepth: depth extent: chartExtent
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1315
	"Squeak mimicri:
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1316
	 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
  1317
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1318
	"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
  1319
	"(Color colorPaletteForDepth: 16 extent: 190@60) display"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1320
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1321
	| 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
  1322
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
  1323
"/        Smalltalk isSmalltalkX ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1324
	    palette := Image extent:chartExtent depth:24.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1325
	    palette photometric:#rgb.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1326
	    palette bits:(ByteArray new:chartExtent x * chartExtent y * 3).
3324
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
  1327
"/        ] ifFalse:[
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
  1328
"/            palette := Form extent: chartExtent depth: depth.
a4244f890bde *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3309
diff changeset
  1329
"/        ].
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1330
	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
  1331
		(Form extent: 34@9 depth: 1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1332
			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
  1333
			offset: 0@0).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1334
	transHt := transCaption height.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1335
	palette fillWhite: (0@0 extent: palette width@transHt).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1336
	palette fillBlack: (0@transHt extent: palette width@1).
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1337
"/        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
  1338
	grayWidth := 10.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1339
	startHue := 338.0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1340
	vSteps := palette height - transHt // 2.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1341
	hSteps := palette width - grayWidth.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1342
	x := 0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1343
	startHue to: startHue + 360.0 by: 360.0/hSteps do: [:h |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1344
		basicHue := Color h: h asFloat s: 1.0 v: 1.0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1345
		y := transHt+1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1346
		0 to: vSteps do: [:n |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1347
			c := basicHue mixed: (n asFloat / vSteps asFloat) with: Color white.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1348
			palette fill: (x@y extent: 1@1) fillColor: c.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1349
			y := y + 1].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1350
		1 to: vSteps do: [:n |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1351
			c := Color black mixed: (n asFloat / vSteps asFloat) with: basicHue.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1352
			y < palette height ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1353
			    palette fill: (x@y extent: 1@1) fillColor: c.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1354
			].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1355
			y := y + 1].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1356
		x := x + 1].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1357
	y := transHt + 1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1358
	1 to: vSteps * 2 do: [:n |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1359
		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
  1360
		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
  1361
		y := y + 1].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1362
	^ palette
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1363
!
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1364
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1365
fromRgbTriplet:aTriple
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1366
    ^ self r:(aTriple at:1)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1367
	   g:(aTriple at:2)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1368
	   b:(aTriple at:3)
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1369
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1370
!
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1371
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1372
h:hue s:saturation v:brightness
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1373
    "Squeak mimicri:
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1374
     Create a color with the given hue, saturation, and brightness.
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1375
     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
  1376
     where red is zero degrees.
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1377
     Saturation and brightness are numbers in [0.0..1.0],
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1378
     where larger values are more saturated or brighter colors.
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1379
     For example, (Color h: 0 s: 1 v: 1) is pure red."
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1380
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  1381
    "Note: By convention, brightness is abbreviated 'v' to avoid confusion with blue."
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1382
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1383
    ^ self hue:hue light:(brightness*50) saturation:(saturation*100)
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1384
!
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1385
4986
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1386
indexedColors
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1387
    "Build an array of colors corresponding to the fixed colormap used
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1388
     for display depths of 1, 2, 4, or 8 bits."
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1389
    "Color indexedColors"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1390
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1391
    | a index grayVal |
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1392
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1393
    a := Array new: 256.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1394
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1395
    "1-bit colors (monochrome)"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1396
    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
  1397
    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
  1398
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1399
    "additional colors for 2-bit color"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1400
    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
  1401
    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
  1402
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1403
    "additional colors for 4-bit color"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1404
    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
  1405
    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
  1406
    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
  1407
    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
  1408
    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
  1409
    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
  1410
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1411
    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
  1412
    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
  1413
    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
  1414
    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
  1415
    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
  1416
    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
  1417
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1418
    "additional colors for 8-bit color"
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1419
    "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
  1420
    index := 17.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1421
    1 to: 31 do: [:v |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1422
	(v \\ 4) = 0 ifFalse: [
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1423
	    grayVal := v / 32.0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1424
	    a at: index put: (Color r: grayVal g: grayVal b: grayVal).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1425
	    index := index + 1]].
4986
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1426
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1427
    "The remainder of color table defines a color cube with six steps
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1428
     for each primary color. Note that the corners of this cube repeat
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1429
     previous colors, but this simplifies the mapping between RGB colors
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1430
     and color map indices. This color cube spans indices 40 through 255
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1431
     (indices 41-256 in this 1-based array)."
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1432
    0 to: 5 do: [:r |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1433
	0 to: 5 do: [:g |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1434
	    0 to: 5 do: [:b |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1435
		index := 41 + ((36 * r) + (6 * b) + g).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1436
		index > 256 ifTrue: [
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1437
		    self error: 'index out of range in color table compuation'].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1438
		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
  1439
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1440
    ^ a.
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1441
!
a9325e813324 +indexedColors
Claus Gittinger <cg@exept.de>
parents: 4910
diff changeset
  1442
3893
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1443
paleBlue
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1444
    ^ self r:0.75 g:0.75 b:1
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1445
!
0e96816ba790 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3892
diff changeset
  1446
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  1447
pixelScreenForDepth: depth
3898
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1448
    "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
  1449
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1450
    | mask bits |
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1451
6584
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1452
    (Smalltalk isSmalltalkX) ifTrue:[
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1453
        depth == 1 ifTrue:[
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1454
            ^ Form mediumGreyFormOn:Screen current
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1455
        ].
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1456
        self shouldImplement.
3898
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1457
    ].
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1458
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1459
    mask := (1 bitShift: depth) - 1.
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1460
    bits := 2 * depth.
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1461
    [bits >= 32] whileFalse: [
6584
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1462
        mask := mask bitOr: (mask bitShift: bits).  "double the length of mask"
f087c33d95db class: Color
Claus Gittinger <cg@exept.de>
parents: 6554
diff changeset
  1463
        bits := bits + bits
3898
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1464
    ].
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1465
    ^ Bitmap with: mask with: mask bitInvert32
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1466
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1467
    "
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1468
     self pixelScreenForDepth: depth
368c43005b5a isSmalltalkX -> dialectName comparison (CS-Compatibility)
Claus Gittinger <cg@exept.de>
parents: 3893
diff changeset
  1469
    "
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1470
!
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1471
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1472
r:redFraction g:greenFraction b:blueFraction
3021
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1473
    "Squeak mimicri:
5f9fc57177b8 more Squeak compatibility stuff
ps
parents: 3005
diff changeset
  1474
     return a color from red, green and blue fractional values;
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1475
     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
  1476
2937
4536e6de438a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2934
diff changeset
  1477
    ^ here scaledRed:(redFraction * MaxValue) rounded
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1478
	   scaledGreen:(greenFraction * MaxValue) rounded
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1479
	   scaledBlue:(blueFraction * MaxValue) rounded
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1480
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1481
    "Modified: / 06-06-2007 / 11:19:53 / cg"
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1482
!
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1483
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1484
r:r g:g b:b alpha:alphaValue
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1485
    "return a color from red, green and blue values;
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1486
     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
  1487
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1488
    ^ (self r:r g:g b:b) alpha:alphaValue
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1489
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1490
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1491
     (Color r:1 g:0 b:0 alpha:0) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1492
     (Color r:0 g:1 b:0 alpha:0.5) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1493
     (Color r:0 g:0 b:1 alpha:1) inspect
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1494
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1495
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1496
    "Created: / 06-06-2007 / 10:48:21 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1497
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1498
4202
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1499
r:r g:g b:b range:componentMax
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1500
    "return a color from red, green and blue values;
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1501
     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
  1502
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1503
    ^ here scaledRed:(r * MaxValue // componentMax)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1504
	   scaledGreen:(g * MaxValue // componentMax)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1505
	   scaledBlue:(b * MaxValue // componentMax)
4202
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1506
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1507
    "
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1508
     (Color r:1023 g:0 b:0 range:1023) inspect
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1509
     (Color r:1023 g:1023 b:1023 range:1023) inspect
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1510
     (Color r:0 g:0 b:0 range:1023) inspect
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1511
    "
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1512
!
a82c1cbb8d30 +r:g:b:range:
Claus Gittinger <cg@exept.de>
parents: 4186
diff changeset
  1513
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1514
showColors: colorList
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1515
	"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
  1516
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1517
	| w r |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1518
	w := Screen current width // colorList size.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1519
	r := 0@0 extent: w@((w min: 30) max: 10).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1520
	colorList do: [:c |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1521
		Screen current fill: r fillColor: c.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1522
		r := r translateBy: w@0].
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1523
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1524
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1525
wheel: thisMany
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1526
    "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
  1527
    "Color showColors: (Color wheel: 12)"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1528
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1529
    ^ Color wheel: thisMany saturation: 0.9 brightness: 0.7
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1530
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1531
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1532
wheel: thisMany saturation: s brightness: v
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1533
    "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
  1534
     all of the given saturation and brightness."
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1535
    "Color showColors: (Color wheel: 12 saturation: 0.4 brightness: 1.0)"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1536
    "Color showColors: (Color wheel: 12 saturation: 0.8 brightness: 0.5)"
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1537
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  1538
    ^ (Color h: 0.0 s: s v: v) wheel: thisMany
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1539
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  1540
    "Modified: / 06-06-2007 / 11:20:59 / cg"
2934
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1541
! !
33b1988133d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1542
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1543
!Color class methodsFor:'Signal constants'!
1023
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
colorAllocationFailSignal
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1546
    "return the signal raised when a color allocation failed."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1547
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1548
    ^ ColorAllocationFailSignal
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1549
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1550
    "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
  1551
!
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1552
2379
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1553
colorErrorSignal
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1554
    "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
  1555
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1556
    ^ ColorErrorSignal
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1557
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1558
    "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
  1559
!
b2a844aabc93 made my signals children of a common colorErrorSignal
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
  1560
1269
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1561
invalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1562
    "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
  1563
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1564
    ^ InvalidColorNameSignal
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1565
f0777b2cc08a use a signal for invalid color names
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1566
    "Created: 24.1.1997 / 13:36:25 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1567
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1568
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1569
!Color class methodsFor:'accessing'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1570
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1571
allocatedColorsOn:aDevice
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1572
    "return a collection of colors which have already been allocated
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1573
     on aDevice."
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1574
4176
40b359dfc293 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4170
diff changeset
  1575
    <resource: #obsolete>
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1576
    self obsoleteMethodWarning:'use #allocatedColorsOnDevice:'.
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1577
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1578
    ^ self allocatedColorsOnDevice:aDevice
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1579
!
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1580
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1581
allocatedColorsOnDevice:aDevice
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1582
    "return a collection of colors which have already been allocated
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1583
     on aDevice."
1023
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
    |colors|
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
    colors := OrderedCollection new.
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1588
    aDevice deviceColors do:[:clr |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1589
	clr colorId notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1590
	    colors add:clr
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1591
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1592
	    'Color [oops]: nil colorId in color' infoPrintCR.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1593
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1594
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1595
    ^ colors asArray
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
    "
3833
4537841edc0f code cleanup
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  1598
     Color allocatedColorsOnDevice:Display
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1599
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1600
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  1601
    "Modified: 24.2.1997 / 18:16:14 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1602
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1603
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1604
!Color class methodsFor:'color space conversions'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1605
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1606
withHLSFromRed:r green:g blue:b do:aBlock
3543
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1607
    "compute hls form rgb, evaluate aBlock with h,l and s as arguments.
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1608
     r,g,b in 0..100
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1609
     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
  1610
6110
28bccabea00a class: Color
Claus Gittinger <cg@exept.de>
parents: 5965
diff changeset
  1611
    |max min r1 g1 b1 delta h l s divisor|
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1612
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1613
    r1 := r / 100.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1614
    g1 := g / 100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1615
    b1 := b / 100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1616
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1617
    max := (r1 max:g1) max:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1618
    min := (r1 min:g1) min:b1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1619
    l := (max + min) / 2.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1620
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1621
    max = min ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1622
	"achromatic, r=g=b"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1623
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1624
	s := 0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1625
	h := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1626
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1627
	l < 0.5 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1628
	    divisor := (max + min)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1629
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1630
	    divisor := (2 - max - min)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1631
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1632
	divisor = 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1633
	    s := 1.0
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1634
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1635
	    s := (max - min) / divisor
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1636
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1637
	"calc hue"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1638
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1639
	delta := max - min.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1640
	r1 = max ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1641
	    h := (g1 - b1) / delta
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1642
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1643
	    g1 = max ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1644
		h := 2 + ((b1 - r1) / delta)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1645
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1646
		h := 4 + ((r1 - g1) / delta)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1647
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1648
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1649
	h := h * 60.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1650
	h < 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1651
	    h := h + 360
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1652
	].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1653
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1654
    aBlock value:h value:(l * 100) value:(s * 100)
6110
28bccabea00a class: Color
Claus Gittinger <cg@exept.de>
parents: 5965
diff changeset
  1655
28bccabea00a class: Color
Claus Gittinger <cg@exept.de>
parents: 5965
diff changeset
  1656
    "Modified: / 27-07-2013 / 11:48:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1657
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1658
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1659
withHLSFromScaledRed:r scaledGreen:g scaledBlue:b do:aBlock
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1660
    "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
  1661
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1662
    ^ self withHLSFromRed:(r * 100.0 / MaxValue)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1663
		    green:(g * 100.0 / MaxValue)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1664
		     blue:(b * 100.0 / MaxValue)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1665
		       do:aBlock
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1666
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1667
    "Created: 11.6.1996 / 17:23:47 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1670
withRGBFromHue:h light:l saturation:s do:aBlock
3543
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1671
    "compute rgb form hls, evaluate aBlock with r,g and b as arguments
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1672
     r,g,b in 0..100
240b9b32ec20 comments
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
  1673
     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
  1674
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1675
    |valueFunc s1 l1 r g b m1 m2|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1676
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1677
    valueFunc := [:n1 :n2 :hIn |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1678
	|hue|
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1679
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1680
	hue := hIn.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1681
	hue > 360 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1682
	    hue := hue - 360
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1683
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1684
	    hue < 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1685
		hue := hue + 360
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1686
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1687
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1688
	hue < 60 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1689
	    n1 + ((n2 - n1) * hue / 60)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1690
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1691
	    hue < 180 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1692
		n2
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1693
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1694
		hue < 240 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1695
		    n1 + ((n2 - n1) * (240 - hue) / 60)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1696
		] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1697
		    n1
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1698
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1699
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1700
	]
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1703
    "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
  1704
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1705
    s1 := s / 100.0.   "scale to  0..1"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1706
    l1 := l / 100.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1707
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1708
    l1 <= 0.5 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1709
	m2 := l1 * (1 + s1)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1710
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1711
	m2 := l1 + s1 - (l1 * s1)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1712
    ].
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
    m1 := 2 * l1 - m2.
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
    s1 = 0 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1717
	"achromatic, ignore hue"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1718
	r := g := b := l1
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1719
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1720
	r := valueFunc value:m1 value:m2 value:h + 120.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1721
	g := valueFunc value:m1 value:m2 value:h.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1722
	b := valueFunc value:m1 value:m2 value:h - 120.
1023
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
    aBlock value:r*100 value:g*100 value:b*100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1725
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1726
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1727
!Color class methodsFor:'constant colors'!
1023
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
black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1730
    "return the black color"
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
    Black isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1733
	Black := self red:0 green:0 blue:0
1023
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
    ^ Black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1736
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1737
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1738
     Color black inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1739
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1740
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1741
    "Modified: 11.6.1996 / 15:55:31 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1742
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1743
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1744
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1745
    "return the blue color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1746
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1747
    Blue isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1748
	Blue := self redPercent:0 greenPercent:0 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1749
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1750
    ^ Blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1751
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1752
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1753
     Color blue inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1754
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1755
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1756
    "Modified: 23.4.1996 / 13:15:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1757
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1758
2962
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1759
brown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1760
    ^ self redPercent:60 greenPercent:20 bluePercent:0
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1761
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1762
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1763
     Color brown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1764
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1765
!
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1766
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1767
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1768
    "return the cyan color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1769
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1770
    ^ self cyan:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1771
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1772
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1773
     Color cyan inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1774
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1775
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1776
    "Modified: 23.4.1996 / 13:16:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1777
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1778
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1779
cyan: cyan
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1780
    "return a cyan color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1781
     the argument cyan is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1782
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1783
     ^ self cyan:100 magenta:100-cyan yellow:100-cyan
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1784
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1785
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  1786
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1787
darkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1788
    "return the dark grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1789
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1790
    DarkGrey isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1791
	DarkGrey := self grayPercent:33
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1792
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1793
    ^ DarkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1794
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1795
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1796
     Color darkGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1797
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1798
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1799
    "Modified: 24.2.1997 / 21:33:11 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1800
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1801
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1802
darkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1803
    "return the darkGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1804
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1805
    ^ self darkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1806
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1807
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1808
     Color darkGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1809
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1810
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1811
    "Modified: 28.5.1996 / 20:47:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1812
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1813
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1814
gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1815
    "return a medium grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1816
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1817
    Grey isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1818
	Grey := self grayPercent:50
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1819
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1820
    ^ Grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1821
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1822
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1823
     Color gray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1824
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1825
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1826
    "Modified: 24.2.1997 / 21:33:19 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1827
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1828
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1829
gray:gray
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1830
    "return a gray color (US version).
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1831
     The argument, gray is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1832
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1833
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1834
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1835
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1836
     Color gray:25
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1837
    "
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1838
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1839
    "Modified: 28.5.1996 / 20:49:51 / cg"
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1840
!
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1841
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1842
grayPercent:gray
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1843
    "return a gray color (US version).
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1844
     The argument, gray is interpreted as percent (0..100)."
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1845
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  1846
    ^ self redPercent:gray greenPercent:gray bluePercent:gray
1023
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1849
     Color gray:25
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1852
    "Modified: 28.5.1996 / 20:49:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1853
!
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
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1856
    "return green"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1857
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1858
    Green isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1859
	Green := self redPercent:0 greenPercent:100 bluePercent:0
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1860
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1861
    ^ Green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1862
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1863
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1864
     Color green inspect
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1867
    "Modified: 23.4.1996 / 13:23:08 / cg"
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
7832
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1870
greenCaringForColorBlindness
7833
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1871
    "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
  1872
     possibly using anther color if the settings specifies color blindness"
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1873
     
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1874
    UserPreferences current useColorsForColorBlindness ifTrue:[
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1875
        "/ for now: later, this will also be configurable
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1876
        ^ self blue.
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1877
    ] ifFalse:[
7833
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1878
        ^ self green darkened.
7832
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1879
    ].
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1880
7833
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1881
    "
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1882
     self greenCaringForColorBlindness
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1883
    "
7cffe851a6d2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7832
diff changeset
  1884
7832
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1885
    "Created: / 03-02-2017 / 14:02:26 / cg"
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1886
!
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  1887
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1888
grey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1889
    "return the grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1890
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1891
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1892
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1893
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1894
     Color grey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1895
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1896
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1897
    "Modified: 28.5.1996 / 20:48:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1898
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1899
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1900
grey:grey
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1901
    "return a grey color (English version).
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1902
     The argument, grey is interpreted as percent (0..100)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1903
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1904
    ^ self grayPercent:grey
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1905
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1906
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1907
     Color grey:25
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1908
     Color grey:12.5
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1909
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1910
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1911
    "Modified: 24.2.1997 / 21:33:28 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1912
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1913
5419
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1914
greyByte:greyByte
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1915
    "return a grey color (English version).
5419
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1916
     The argument, grey is interpreted as byte-value (0..255)."
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1917
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1918
    ^ self redByte:greyByte greenByte:greyByte blueByte:greyByte
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1919
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1920
    "
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1921
     Color greyByte:127
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1922
    "
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1923
!
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  1924
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1925
lightBlue
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1926
    "return a light blue color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1927
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1928
    ^ self redPercent:50 greenPercent:50 bluePercent:100
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1929
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1930
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1931
     Color lightBlue inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1932
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1933
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1934
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1935
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1936
2962
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1937
lightBrown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1938
    ^ self brown lighter
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1939
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1940
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1941
     Color lightBrown
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1942
    "
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1943
!
c60ec983a6f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  1944
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1945
lightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1946
    "return the lightGrey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1947
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1948
    LightGrey isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  1949
	LightGrey := self grayPercent:67
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1950
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1951
    ^ LightGrey
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
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1954
     Color lightGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1955
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1956
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  1957
    "Modified: 24.2.1997 / 21:33:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1958
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1959
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1960
lightGreen
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1961
    "return a light green color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1962
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1963
    ^ self redPercent:50 greenPercent:100 bluePercent:50
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1964
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1965
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1966
     Color lightGreen inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1967
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1968
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1969
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1970
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1971
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1972
lightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1973
    "return the lightGrey color (English version ;-)"
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
    ^ self lightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1976
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1977
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1978
     Color lightGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1979
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1980
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1981
    "Modified: 28.5.1996 / 20:51:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1982
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  1983
2388
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1984
lightRed
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1985
    "return a light red color"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1986
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1987
    ^ self redPercent:100 greenPercent:50 bluePercent:50
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1988
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1989
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1990
     Color lightRed inspect
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1991
    "
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1992
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1993
    "Modified: 23.4.1996 / 13:23:08 / cg"
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1994
!
8a7f4bb3847c added lightRed/lightGreen/lightBlue
Claus Gittinger <cg@exept.de>
parents: 2379
diff changeset
  1995
2949
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1996
lightYellow
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1997
    ^ self yellow lighter
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1998
!
b747daf42e13 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1999
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2000
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2001
    "return the magenta color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2002
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2003
    ^ self magenta:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2004
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2005
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2006
     Color magenta inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2007
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2008
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2009
    "Modified: 23.4.1996 / 13:23:41 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2010
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2011
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2012
magenta: magenta
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2013
    "return a magenta color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2014
     the argument magenta is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2015
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2016
     ^ self cyan:100-magenta magenta:100 yellow:100-magenta
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2017
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2018
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2019
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2020
mediumGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2021
    "return medium-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2022
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2023
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2024
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2025
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2026
     Color mediumGray inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2027
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2028
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2029
    "Created: 23.4.1996 / 13:24:17 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2030
    "Modified: 28.5.1996 / 20:51:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2031
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2032
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2033
mediumGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2034
    "return medium-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2035
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2036
    ^ self gray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2037
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2038
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2039
     Color mediumGrey inspect
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2040
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2041
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2042
    "Modified: 28.5.1996 / 20:51:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2043
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2044
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2045
orange
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2046
    "return the orange color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2047
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2048
    Orange isNil ifTrue:[
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2049
        Orange := self redPercent:100 greenPercent:50 bluePercent:0.
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2050
    ].
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2051
    ^ Orange
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2052
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2053
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2054
     Color orange inspect
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2055
    "
2077
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2056
!
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2057
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2058
orange: orange
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2059
    "return a orange color;
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2060
     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
  2061
442b9763111c #orange should return an orange color and not a brown color
tz
parents: 2071
diff changeset
  2062
     ^ self redPercent:orange greenPercent:orange/2 bluePercent:0
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2063
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2064
!
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2065
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2066
pink
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2067
    "return the pink color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2068
1348
acb4e4874e4d care for ColorValue (ColorValue cyan)
ca
parents: 1347
diff changeset
  2069
     ^ self redPercent:100 greenPercent:0 bluePercent:100
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2070
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2071
    "Modified: 23.4.1996 / 13:29:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2072
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2073
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2074
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2075
    "return the red color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2076
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2077
    Red isNil ifTrue:[
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2078
        Red := self redPercent:100 greenPercent:0 bluePercent:0.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2079
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2080
    ^ Red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2081
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2082
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2083
     Color red inspect
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2084
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2085
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2086
    "Modified: 23.4.1996 / 13:29:44 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2087
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2088
7832
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2089
redCaringForColorBlindness
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2090
    "return the color to use for green,
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2091
     possibly using anther color if the settings specifies color blindness"
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2092
     
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2093
    UserPreferences current useColorsForColorBlindness ifTrue:[
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2094
        "/ for now: later, this will also be configurable
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2095
        ^ self red.
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2096
    ] ifFalse:[
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2097
        ^ self red.
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2098
    ].
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2099
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2100
    "Created: / 03-02-2017 / 14:02:50 / cg"
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2101
!
9f302a33066b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7831
diff changeset
  2102
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2103
transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2104
    "return the transparent-color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2105
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2106
    Transparent isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2107
	Transparent := TranslucentColor scaledRed:0 scaledGreen:0 scaledBlue:0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2108
	Transparent setAlphaByte:0.
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2109
    ].
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2110
    ^ Transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2111
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2112
    "
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2113
     self transparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2114
    "
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2115
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  2116
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2117
veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2118
    "return a very dark-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2119
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  2120
    ^ self grayPercent:13
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2121
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2122
    "Created: 23.4.1996 / 13:33:14 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  2123
    "Modified: 24.2.1997 / 21:33:52 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2124
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2125
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2126
veryDarkGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2127
    "return a very dark-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2128
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2129
    ^ self veryDarkGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2130
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2131
    "Modified: 28.5.1996 / 20:52:49 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2132
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2133
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2134
veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2135
    "return a very light-grey color (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2136
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  2137
    ^ self grayPercent:87
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2138
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2139
    "Created: 23.4.1996 / 13:33:46 / cg"
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  2140
    "Modified: 24.2.1997 / 21:33:58 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2141
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2142
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2143
veryLightGrey
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2144
    "return a very light-grey color (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2145
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2146
    ^ self veryLightGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2147
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2148
    "Modified: 28.5.1996 / 20:52:03 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2149
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2150
3030
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2151
veryVeryLightGray
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2152
    "return a very very light-grey color (US version ;-)"
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2153
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2154
    ^ self grayPercent:93
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2155
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2156
!
11cb6482e344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3024
diff changeset
  2157
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2158
white
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2159
    "return the white-color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2160
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2161
    White isNil ifTrue:[
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2162
        White := self redPercent:100 greenPercent:100 bluePercent:100.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2163
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2164
    ^ White
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2165
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2166
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2167
     Color white inspect
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2168
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2169
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2170
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2171
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2172
    "return the yellow color - ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2173
7642
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2174
    Yellow isNil ifTrue:[
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2175
        Yellow := self redPercent:100 greenPercent:100 bluePercent:0.
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2176
    ].
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2177
    ^ Yellow
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2178
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2179
    "
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2180
     Color yellow inspect
9285a6619b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7639
diff changeset
  2181
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2182
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2183
    "Modified: 23.4.1996 / 13:33:56 / cg"
2087
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2184
!
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2185
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2186
yellow: yellow
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2187
    "return a yellow color;
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2188
     the argument yellow is interpreted as percent (0..100)"
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2189
619e0288e4e1 #cyan:, #magenta:, and #yellow: added
tz
parents: 2083
diff changeset
  2190
     ^ self cyan:100-yellow magenta:100-yellow yellow:100
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2191
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2192
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2193
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2194
!Color class methodsFor:'obsolete'!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2195
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2196
nameOrDither:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2197
    "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
  2198
     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
  2199
     illegal."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2200
3427
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2201
    <resource:#obsolete>
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2202
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2203
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2204
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2205
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2206
    "Modified: 16.1.1997 / 23:01:03 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2207
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2208
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2209
nameOrDither:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2210
    "return a named color - if the exact color is not available,
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2211
     return a dithered color. If the colorname is illegal, return
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2212
     the value of evaluating errorBlock."
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2213
3427
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2214
    <resource:#obsolete>
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2215
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2216
    self obsoleteMethodWarning:'use #name:ifIllegal:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2217
    ^ self name:colorName ifIllegal:errorBlock
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2218
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2219
    "Modified: 16.1.1997 / 23:01:32 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2220
!
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2221
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2222
nameOrNearest:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2223
    "return a named color - or its nearest match"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2224
3427
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2225
    <resource:#obsolete>
609caad9766c Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3399
diff changeset
  2226
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2227
    self obsoleteMethodWarning:'use #name:'.
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2228
    ^ self name:colorName
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2229
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2230
    "Modified: 16.1.1997 / 23:02:18 / cg"
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2231
! !
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  2232
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  2233
!Color class methodsFor:'private'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2234
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2235
colorNearRed:r green:g blue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2236
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2237
     almost matching. If there is one, nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2238
     This is tried as a last chance before dithering.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2239
     The algorithm needs rework, the color components
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2240
     should be weighted according some theory :-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2241
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2242
    |bestColor minDelta diff rr rg rb dRed|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2243
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2244
"/    rr := (r * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2245
"/    rg := (g * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2246
"/    rb := (b * 3.0) rounded / 3.0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2247
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2248
    rr := r rounded.                "round to 1%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2249
    rg := (g * 2.0) rounded / 2.0.  "round to 0.5%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2250
    rb := (b / 2) rounded * 2.      "round to 2%"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2251
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2252
    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
  2253
    aDevice deviceColors do:[:aColor |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2254
	dRed := rr - aColor red.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2255
	dRed < 10 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2256
	    diff := dRed asInteger squared
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2257
		    + (rg - aColor green) asInteger squared
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2258
		    + (rb - aColor blue) asInteger squared.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2259
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2260
	    diff < minDelta ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2261
		diff = 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2262
		    "got it"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2263
		    ^ aColor
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2264
		].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2265
		bestColor := aColor.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2266
		minDelta := diff
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
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2269
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2270
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2271
    "allow an error of 10% per component"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2272
    minDelta < (100+100+100) ifTrue:[ ^ bestColor ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2273
    ^ nil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2274
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  2275
    "Modified: 24.2.1997 / 18:17:24 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2276
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2277
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2278
existingColorRed:r green:g blue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2279
    "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
  2280
     if there is one, nil otherwise."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2281
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2282
    ^ self existingColorScaledRed:(r * MaxValue // 100)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2283
			scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2284
			scaledBlue:(b * MaxValue // 100)
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2285
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2286
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2287
existingColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2288
    "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
  2289
     if there is one, nil otherwise."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2290
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2291
    aDevice deviceColors do:[:aColor |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2292
	(r == aColor scaledRed) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2293
	    (g == aColor scaledGreen) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2294
		(b == aColor scaledBlue) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2295
		    ^ aColor
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2296
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2297
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2298
	]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2299
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2300
    ^ nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2301
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2302
    "Modified: 24.2.1997 / 18:17:35 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2303
! !
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2304
3878
28052cae1ad3 method category rename
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
  2305
!Color class methodsFor:'private-dithering'!
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2306
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2307
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
  2308
    "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
  2309
     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
  2310
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2311
    |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
  2312
     dir   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2313
     start "{ Class: SmallInteger }"
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2314
     end   "{ Class: SmallInteger }"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2315
     map
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2316
     w     "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2317
     h     "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2318
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2319
"/    w := h := 32.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2320
"/    w := h := 4.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2321
    w := h := 2.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2322
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2323
    errR := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2324
    errG := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2325
    errB := 0.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2326
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2327
    "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
  2328
    f := Form width:w height:h depth:(aDevice depth) onDevice:aDevice.
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2329
    f isNil ifTrue:[^ nil].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2330
    map := IdentityDictionary new.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2331
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2332
    0 to:(w-1) do:[:x |
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2333
        x even ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2334
            dir := 1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2335
            start := 0.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2336
            end := (h-1).
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2337
        ] ifFalse:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2338
            dir := -1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2339
            start := (h-1).
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2340
            end := 0.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2341
        ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2342
        start to:end by:dir do:[:y |
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2343
            wantR := red + errR.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2344
            wantR > MaxValue ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2345
                wantR := MaxValue
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2346
            ] ifFalse:[ wantR < 0 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2347
                wantR := 0
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2348
            ]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2349
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2350
            wantG := green + errG.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2351
            wantG > MaxValue ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2352
                wantG := MaxValue
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2353
            ] ifFalse:[ wantG < 0 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2354
                wantG := 0
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2355
            ]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2356
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2357
            wantB := blue + errB.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2358
            wantB > MaxValue ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2359
                wantB := MaxValue
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2360
            ] ifFalse:[ wantB < 0 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2361
                wantB := 0
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2362
            ]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2363
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2364
            "find the nearest color"
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2365
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2366
            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
  2367
"
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2368
            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
  2369
"
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2370
            clr isNil ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2371
                clr := Color scaledRed:wantR scaledGreen:wantG scaledBlue:wantB.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2372
                clr brightness > 0.5 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2373
                    clr := Color white
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2374
                ] ifFalse:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2375
                    clr := Color black
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2376
                ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2377
                clr := clr onDevice:aDevice
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2378
"
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2379
                ^ aBlock value:nil value:nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2380
"
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2381
            ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2382
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2383
            f paint:clr.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2384
            f displayPointX:x y:y.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2385
            map at:clr colorId + 1 put:clr.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2386
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2387
            "compute the new error"
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2388
            errR := wantR - clr scaledRed.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2389
            errG := wantG - clr scaledGreen.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2390
            errB := wantB - clr scaledBlue.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  2391
        ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2392
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2393
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2394
    f colorMap:map.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2395
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2396
'hard dither' printNewline.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2397
"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2398
    ^ aBlock value:nil value:f
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2399
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2400
    "Created: 3.5.1997 / 11:02:47 / cg"
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2401
    "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
  2402
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  2403
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2404
ditherBits
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2405
    "return a dither pattern for x/64; x in 1..63"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2406
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2407
    ^ #(
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  2408
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2409
	"/ 1in64
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
	  #[2r10000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2412
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2413
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2414
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2415
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2416
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2417
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2418
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2419
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2420
	"/ 2in64
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
	  #[2r10000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2423
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2424
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2425
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2426
	    2r00001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2427
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2428
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2429
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2430
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2431
	"/ 3in64
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
	  #[2r10000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2434
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2435
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2436
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2437
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2438
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2439
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2440
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2441
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2442
	"/ 4in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2445
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2446
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2447
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2448
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2449
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2450
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2451
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2452
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2453
	"/ 5in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2456
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2457
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2458
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2459
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2460
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2461
	    2r00000010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2462
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2463
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2464
	"/ 6in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2467
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2468
	    2r00100000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2469
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2470
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2471
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2472
	    2r00000010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2473
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2474
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2475
	"/ 7in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2478
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2479
	    2r00100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2480
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2481
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2482
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2483
	    2r00000010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2484
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2485
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2486
	"/ 8in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2489
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2490
	    2r00100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2491
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2492
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2493
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2494
	    2r00100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2495
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2496
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2497
	"/ 9in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2500
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2501
	    2r00100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2502
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2503
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2504
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2505
	    2r10100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2506
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2507
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2508
	"/ 10in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2511
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2512
	    2r00101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2513
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2514
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2515
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2516
	    2r10100010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2517
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2518
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2519
	"/ 11in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2522
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2523
	    2r00101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2524
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2525
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2526
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2527
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2528
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2529
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2530
	"/ 12in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2533
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2534
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2535
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2536
	    2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2537
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2538
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2539
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2540
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2541
	"/ 13in64
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
	  #[2r10001000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2544
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2545
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2546
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2547
	    2r10101000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2548
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2549
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2550
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2551
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2552
	"/ 14in64
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
	  #[2r10001010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2555
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2556
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2557
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2558
	    2r10101000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2559
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2560
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2561
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2562
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2563
	"/ 15in64
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
	  #[2r10001010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2566
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2567
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2568
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2569
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2570
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2571
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2572
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2573
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2574
	"/ 16in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2577
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2578
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2579
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2580
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2581
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2582
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2583
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2584
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2585
	"/ 17in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2588
	    2r01000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2589
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2590
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2591
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2592
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2593
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2594
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2595
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2596
	"/ 18in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2599
	    2r01000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2600
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2601
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2602
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2603
	    2r00000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2604
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2605
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2606
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2607
	"/ 19in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2610
	    2r01000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2611
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2612
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2613
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2614
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2615
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2616
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2617
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2618
	"/ 20in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2621
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2622
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2623
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2624
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2625
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2626
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2627
	    2r00000000]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2628
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2629
	"/ 21in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2632
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2633
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2634
	    2r00000000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2635
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2636
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2637
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2638
	    2r00000001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2639
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2640
	"/ 22in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2643
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2644
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2645
	    2r00010000
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2646
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2647
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2648
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2649
	    2r00000001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2650
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2651
	"/ 23in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2654
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2655
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2656
	    2r00010001
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2657
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2658
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2659
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2660
	    2r00000001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2661
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2662
	"/ 24in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2665
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2666
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2667
	    2r00010001
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2668
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2669
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2670
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2671
	    2r00010001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2672
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2673
	"/ 25in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2676
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2677
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2678
	    2r00010001
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2679
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2680
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2681
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2682
	    2r01010001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2683
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2684
	"/ 26in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2687
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2688
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2689
	    2r00010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2690
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2691
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2692
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2693
	    2r01010001]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2694
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2695
	"/ 27in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2698
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2699
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2700
	    2r00010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2701
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2702
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2703
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2704
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2705
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2706
	"/ 28in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2709
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2710
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2711
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2712
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2713
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2714
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2715
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2716
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2717
	"/ 29in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2720
	    2r01000100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2721
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2722
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2723
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2724
	    2r01010100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2725
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2726
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2727
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2728
	"/ 30in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2731
	    2r01000101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2732
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2733
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2734
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2735
	    2r01010100
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2736
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2737
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2738
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2739
	"/ 31in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2742
	    2r01000101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2743
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2744
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2745
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2746
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2747
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2748
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2749
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2750
	"/ 32in64
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
	  #[2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2753
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2754
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2755
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2756
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2757
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2758
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2759
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2760
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2761
	"/ 33in64
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
	  #[2r11101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2764
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2765
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2766
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2767
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2768
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2769
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2770
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2771
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2772
	"/ 34in64
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
	  #[2r11101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2775
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2776
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2777
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2778
	    2r10101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2779
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2780
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2781
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2782
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2783
	"/ 35in64
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
	  #[2r11101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2786
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2787
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2788
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2789
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2790
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2791
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2792
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2793
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2794
	"/ 36in64
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
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2797
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2798
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2799
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2800
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2801
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2802
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2803
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2804
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2805
	"/ 37in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2806
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2807
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2808
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2809
	    2r10101010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2810
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2811
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2812
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2813
	    2r10101011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2814
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2815
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2816
	"/ 38in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2817
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2818
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2819
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2820
	    2r10111010
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2821
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2822
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2823
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2824
	    2r10101011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2825
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2826
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2827
	"/ 39in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2828
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2829
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2830
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2831
	    2r10111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2832
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2833
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2834
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2835
	    2r10101011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2836
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2837
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2838
	"/ 40in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2839
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2840
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2841
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2842
	    2r10111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2843
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2844
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2845
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2846
	    2r10111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2847
	    2r01010101]
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
	"/ 41in64
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
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2852
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2853
	    2r10111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2854
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2855
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2856
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2857
	    2r11111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2858
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2859
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2860
	"/ 42in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2861
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2862
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2863
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2864
	    2r10111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2865
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2866
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2867
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2868
	    2r11111011
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2869
	    2r01010101]
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
	"/ 43in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2872
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2873
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2874
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2875
	    2r10111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2876
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2877
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2878
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2879
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2880
	    2r01010101]
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
	"/ 44in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2883
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2884
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2885
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2886
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2887
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2888
	    2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2889
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2890
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2891
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2892
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2893
	"/ 45in64
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
	  #[2r11101110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2896
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2897
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2898
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2899
	    2r11111110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2900
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2901
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2902
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2903
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2904
	"/ 46in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2905
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2906
	  #[2r11101111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2907
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2908
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2909
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2910
	    2r11111110
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2911
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2912
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2913
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2914
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2915
	"/ 47in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2916
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2917
	  #[2r11101111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2918
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2919
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2920
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2921
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2922
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2923
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2924
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2925
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2926
	"/ 48in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2927
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2928
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2929
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2930
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2931
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2932
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2933
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2934
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2935
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2936
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2937
	"/ 49in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2938
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2939
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2940
	    2r01110101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2941
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2942
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2943
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2944
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2945
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2946
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2947
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2948
	"/ 50in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2949
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2950
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2951
	    2r01110101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2952
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2953
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2954
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2955
	    2r01010111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2956
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2957
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2958
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2959
	"/ 51in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2960
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2961
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2962
	    2r01110101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2963
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2964
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2965
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2966
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2967
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2968
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2969
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2970
	"/ 52in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2971
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2972
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2973
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2974
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2975
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2976
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2977
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2978
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2979
	    2r01010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2980
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2981
	"/ 53in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2982
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2983
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2984
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2985
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2986
	    2r01010101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2987
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2988
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2989
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2990
	    2r11010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2991
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2992
	"/ 54in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2993
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2994
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2995
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2996
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2997
	    2r01011101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2998
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  2999
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3000
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3001
	    2r11010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3002
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3003
	"/ 55in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3004
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3005
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3006
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3007
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3008
	    2r11011101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3009
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3010
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3011
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3012
	    2r11010101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3013
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3014
	"/ 56in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3015
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3016
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3017
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3018
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3019
	    2r11011101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3020
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3021
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3022
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3023
	    2r11011101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3024
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3025
	"/ 57in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3026
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3027
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3028
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3029
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3030
	    2r11011101
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3031
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3032
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3033
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3034
	    2r11111101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3035
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3036
	"/ 58in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3037
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3038
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3039
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3040
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3041
	    2r11011111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3042
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3043
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3044
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3045
	    2r11111101]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3046
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3047
	"/ 59in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3048
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3049
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3050
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3051
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3052
	    2r11011111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3053
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3054
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3055
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3056
	    2r11111111]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3057
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3058
	"/ 60in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3059
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3060
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3061
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3062
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3063
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3064
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3065
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3066
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3067
	    2r11111111]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3068
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3069
	"/ 61in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3070
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3071
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3072
	    2r01110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3073
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3074
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3075
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3076
	    2r01111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3077
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3078
	    2r11111111]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3079
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3080
	"/ 62in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3081
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3082
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3083
	    2r11110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3084
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3085
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3086
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3087
	    2r01111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3088
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3089
	    2r11111111]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3090
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3091
	"/ 63in64
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3092
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3093
	  #[2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3094
	    2r11110111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3095
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3096
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3097
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3098
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3099
	    2r11111111
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3100
	    2r11111111]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3101
     )
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3102
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3103
    "Modified: 23.4.1996 / 13:31:50 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3104
    "Created: 11.6.1996 / 15:34:29 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3105
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3106
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3107
ditherGrayFor:fraction on:aDevice into:aBlock
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3108
    "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
  3109
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3110
     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
  3111
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3112
    |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
  3113
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3114
    d := aDevice depth.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3115
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3116
    "/ special code for b&w displays
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3117
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3118
    d == 1 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3119
	aDevice blackpixel == 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3120
	    clr1 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3121
	    clr2 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3122
	    newFraction := fraction.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3123
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3124
	    clr1 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3125
	    clr2 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3126
	    newFraction := 1 - fraction
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3127
	]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3128
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3129
	"/ special code for 2-plane displays (NeXT)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3130
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3131
	d == 2 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3132
	    fraction <= 0.01 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3133
		clr1 := Black exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3134
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3135
		(fraction between:0.32 and:0.34) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3136
		    clr1 := (Color gray:33) exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3137
		] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3138
		    (fraction between:0.66 and:0.68) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3139
			clr1 := (Color gray:67) exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3140
		    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3141
			fraction >= 0.99 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3142
			    clr1 := White exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3143
			]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3144
		    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3145
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3146
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3147
	    clr1 notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3148
		^ aBlock value:clr1 value:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3149
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3150
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3151
	    (fraction between:0 and:0.33) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3152
		clr1 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3153
		clr2 := Color gray:33.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3154
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3155
		(fraction between:0.34 and:0.66) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3156
		    clr1 := Color gray:33.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3157
		    clr2 := Color gray:67.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3158
		] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3159
		    clr1 := Color gray:67.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3160
		    clr2 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3161
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3162
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3163
	    scaledGray1 := clr1 scaledRed.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3164
	    scaledGray2 := clr2 scaledRed.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3165
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3166
	    scaledGrey := (MaxValue * fraction) rounded.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3167
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3168
	    nGray := (1 bitShift:d) - 1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3169
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3170
	    "/ scale greyValue into grey levels
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3171
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3172
	    grayBelow := (fraction * nGray) truncated.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3173
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3174
	    grayBelow < 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3175
		^ Color black exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3176
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3177
	    grayBelow >= nGray ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3178
		^ Color white exactOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3179
	    ].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3180
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3181
	    scaledGrey := (MaxValue * fraction) rounded.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3182
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3183
	    step := MaxValue // nGray.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3184
	    scaledGray1 := grayBelow * step.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3185
	    scaledGray2 := scaledGray1 + step.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3186
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3187
	    clr1 := Color scaledGray:scaledGray1.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3188
	    clr2 := Color scaledGray:scaledGray2.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3189
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3190
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3191
	"/ scale remainder in between low..high
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3192
	newFraction := (scaledGrey - scaledGray1) asFloat / (scaledGray2 - scaledGray1).
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3193
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3194
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3195
    clr1 := clr1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3196
    clr2 := clr2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3197
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3198
    (clr1 isNil or:[clr2 isNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3199
	"/ fall back to b&w dither
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3200
	aDevice blackpixel == 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3201
	    clr1 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3202
	    clr2 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3203
	    newFraction := fraction.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3204
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3205
	    clr1 := White.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3206
	    clr2 := Black.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3207
	    newFraction := 1 - fraction
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3208
	]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3209
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3210
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3211
    ^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3212
	monoDitherFor:newFraction
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3213
	between:clr1 and:clr2
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3214
	on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3215
	into:aBlock
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3216
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3217
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3218
     Color basicNew
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3219
	ditherGrayFor:0.5
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3220
	on:Display
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3221
	into:[:clr :form | clr notNil ifTrue:[clr inspect].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3222
			   form notNil ifTrue:[(form magnifiedBy:16) inspect].]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3223
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3224
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3225
     Color basicNew
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3226
	ditherGrayFor:0.25
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3227
	on:Display
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3228
	into:[:clr :form | clr notNil ifTrue:[clr inspect].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3229
			   form notNil ifTrue:[(form magnifiedBy:16) inspect].]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3230
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3231
5779
def9764b9b8a changed: #ditherGrayFor:on:into:
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  3232
    "Created: / 03-05-1997 / 10:59:57 / cg"
def9764b9b8a changed: #ditherGrayFor:on:into:
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  3233
    "Modified: / 24-07-2011 / 07:18:00 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3234
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3235
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3236
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
  3237
    "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
  3238
     Returns 2 values (either color or ditherForm) through
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3239
     aBlock.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3240
     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
  3241
     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
  3242
     are handled"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3243
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3244
    |rh rl rs
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3245
     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
  3246
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3247
    "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
  3248
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3249
    Color withHLSFromScaledRed:rV scaledGreen:gV scaledBlue:bV do:[:hue :light :saturation |
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3250
        hue notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3251
            rh := (hue * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3252
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3253
        rl := (light * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3254
        rs := (saturation * 3.0) rounded / 3.0.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3255
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3256
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3257
    rh isNil ifTrue:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3258
        "achromatic,  dither between achromatic colors"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3259
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3260
        lowL := nil.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3261
        hiL := nil.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3262
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3263
        "find the 2 bounding colors"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3264
        aDevice deviceColors do:[:aColor |
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3265
            aColor colorId notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3266
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3267
                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
  3268
                    | cl |
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3269
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3270
                    hue isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3271
                        cl := (light * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3272
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3273
                        cl > rl ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3274
                            hiL isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3275
                                hiL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3276
                                hiValL := cl.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3277
                            ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3278
                                cl < hiValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3279
                                    hiL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3280
                                    hiValL := cl.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3281
                                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3282
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3283
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3284
                            lowL isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3285
                                lowL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3286
                                lowValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3287
                            ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3288
                                cl > lowValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3289
                                    lowL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3290
                                    lowValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3291
                                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3292
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3293
                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3294
                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3295
                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3296
            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3297
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3298
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3299
        (lowL notNil and:[hiL notNil]) ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3300
            ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3301
                monoDitherFor:1.0 / (hiValL - lowValL) * (rl - lowValL)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3302
                between:lowL and:hiL
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3303
                on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3304
                into:aBlock
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3305
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3306
        "cannot happen, should always find at least black and white"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3307
        '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
  3308
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3309
        ^ aBlock value:nil value:nil
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
    "chromatic case"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3313
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3314
    aDevice hasColors ifFalse:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3315
        "no chance, return nil values"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3316
        ^ aBlock value:nil value:nil
1707
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
    (Red isNil or:[Green isNil or:[Blue isNil]]) ifTrue:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3319
        "if we where not able to get primary colors: no chance"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3320
        ^ aBlock value:nil value:nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3321
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3322
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3323
    "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
  3324
     dither on light between those"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3325
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3326
    lowL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3327
    hiL := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3328
    lowS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3329
    hiS := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3330
    lowH := nil.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3331
    hiH := nil.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3332
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  3333
    aDevice deviceColors do:[:aColor |
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3334
        aColor colorId notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3335
            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
  3336
                | cl ch cs|
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3337
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3338
                hue notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3339
                   ch := (hue * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3340
                ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3341
                   ch := nil
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3342
                ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3343
                cl := (light * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3344
                cs := (saturation * 3.0) rounded / 3.0.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3345
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3346
                ((ch = rh) and:[cs = rs]) ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3347
                    "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
  3348
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3349
                    cl > rl ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3350
                        hiL isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3351
                            hiL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3352
                            hiValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3353
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3354
                            cl < hiValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3355
                                hiL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3356
                                hiValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3357
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3358
                        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3359
                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3360
                        lowL isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3361
                            lowL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3362
                            lowValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3363
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3364
                            cl > lowValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3365
                                lowL := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3366
                                lowValL := cl
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3367
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3368
                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3369
                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3370
                ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3371
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3372
                (((ch = rh) or:[ch isNil]) and:[cl = rl]) ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3373
                    "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
  3374
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3375
                    cs > rs ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3376
                        hiS isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3377
                            hiS := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3378
                            hiValS := cs
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3379
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3380
                            cs < hiValS ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3381
                                hiS := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3382
                                hiValS := cs
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3383
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3384
                        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3385
                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3386
                        lowS isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3387
                            lowS := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3388
                            lowValS := cs
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3389
                        ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3390
                            cs > lowValS ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3391
                                lowS := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3392
                                lowValS := cs
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3393
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3394
                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3395
                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3396
                ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3397
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3398
                rh notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3399
                    cl = rl ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3400
                        cs = rs ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3401
                            ch notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3402
                                d := (ch - rh) abs.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3403
                                d > 300 ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3404
                                    rh > 180 ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3405
                                        ch := ch + 360
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3406
                                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3407
                                        ch := ch - 360
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3408
                                    ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3409
                                ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3410
                                ch > rh ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3411
                                    hiH isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3412
                                        hiH := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3413
                                        hiValH := ch
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3414
                                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3415
                                        ch < hiValH ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3416
                                            hiH := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3417
                                            hiValH := ch
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3418
                                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3419
                                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3420
                                ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3421
                                    lowH isNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3422
                                        lowH := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3423
                                        lowValH := ch
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3424
                                    ] ifFalse:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3425
                                        ch > lowValH ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3426
                                            lowH := aColor.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3427
                                            lowValH := ch
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3428
                                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3429
                                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3430
                                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3431
                            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3432
                        ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3433
                    ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3434
                ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3435
            ]
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3436
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3437
    ].
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3438
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3439
    "found bounds for light ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3440
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3441
    lowL notNil ifTrue:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3442
        rl = lowValL ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3443
            ^ aBlock value:lowL value:nil
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3444
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3445
        hiL notNil ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3446
            ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3447
                monoDitherFor:1.0 / (hiValL - lowValL) / (rl - lowValL)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3448
                between:lowL and:hiL
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3449
                on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3450
                into:aBlock
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3451
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3452
        "found bound for light - dither with white"
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3453
        ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3454
            monoDitherFor:1.0 / (100 - lowValL) / (rl - lowValL)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3455
            between:lowL and:White
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3456
            on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3457
            into:aBlock
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3458
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3459
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3460
    "found bound for light - dither with black"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3461
    hiL notNil ifTrue:[
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3462
        ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3463
            monoDitherFor:1.0 / (hiValL) / (rl)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3464
            between:Black and:hiL
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3465
            on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3466
            into:aBlock
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3467
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3468
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3469
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3470
    "found bounds for saturation?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3471
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3472
    (lowS notNil and:[hiS notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3473
"
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3474
        'saturation dither' printNewline.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3475
"
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3476
        ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3477
            monoDitherFor:1.0 / (hiValS - lowValS) / (rs - lowValS)
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3478
            between:lowS and:hiS
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3479
            on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3480
            into:aBlock
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3481
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3482
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3483
    "found bounds for hue ?"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3484
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3485
    (lowH notNil and:[hiH notNil]) ifTrue:[
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3486
"
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3487
        'hue dither' printNewline.
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3488
"
7798
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3489
        hiValH < lowValH ifTrue:[
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3490
            hiValH := hiValH + 360
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3491
        ].
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3492
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3493
        d := hiValH - lowValH.
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3494
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3495
        ^ self
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3496
            monoDitherFor:1.0 / (d / (rh - lowValH))
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3497
            between:lowH and:hiH
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3498
            on:aDevice
8af654223c89 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7782
diff changeset
  3499
            into:aBlock
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3500
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3501
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3502
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3503
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3504
    "Modified: 3.5.1997 / 10:58:54 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3505
    "Created: 3.5.1997 / 11:02:03 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3506
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3507
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3508
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
  3509
    "get a dither form for an rgb value.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3510
     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
  3511
     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
  3512
     dither colors."
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3513
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3514
    |
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3515
     nR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3516
     nG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3517
     nB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3518
     hR "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3519
     hG "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3520
     hB "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3521
     eR eG eB
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3522
     rI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3523
     gI "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3524
     bI  "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3525
     idx "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3526
     f clr
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3527
     r    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3528
     g    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3529
     b    "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3530
     x1   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3531
     x2   "{ Class: SmallInteger }"
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3532
     step "{ Class: SmallInteger }"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3533
     lastIdx mx
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3534
     dS   "{ Class: SmallInteger }"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3535
     cube|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3536
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3537
    (cube := aDevice fixColors) notNil ifTrue:[
7360
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3538
        dS := 4.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3539
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3540
        f := Form width:dS height:dS depth:(aDevice depth) onDevice:aDevice.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3541
        f isNil ifTrue:[^ nil].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3542
        f initGC.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3543
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3544
        mx := MaxValue asFloat.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3545
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3546
        nR := aDevice numFixRed.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3547
        nG := aDevice numFixGreen.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3548
        nB := aDevice numFixBlue.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3549
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3550
        hR := nR // 2.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3551
        hG := nG // 2.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3552
        hB := nB // 2.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3553
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3554
        eR := eG := eB := 0.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3555
        r := redVal.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3556
        g := greenVal.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3557
        b := blueVal.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3558
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3559
        step := -1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3560
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3561
        0 to:dS-1 do:[:y |
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3562
            step == -1 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3563
                x1 := 0. x2 := dS-1. step := 1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3564
            ] ifFalse:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3565
                x1 := dS-1. x2 := 0. step := -1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3566
            ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3567
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3568
            x1 to:x2 by:step do:[:x |
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3569
                "/ the nearest along the grid
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3570
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3571
                r := redVal + eR.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3572
                r > MaxValue ifTrue:[r := MaxValue]
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3573
                             ifFalse:[r < 0 ifTrue:[r := 0]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3574
                g := greenVal + eG.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3575
                g > MaxValue ifTrue:[g := MaxValue]
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3576
                             ifFalse:[g < 0 ifTrue:[g := 0]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3577
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3578
                b := blueVal + eB.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3579
                b > MaxValue ifTrue:[b := MaxValue]
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3580
                             ifFalse:[b < 0 ifTrue:[b := 0]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3581
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3582
                rI := (r * (nR-1) + hR / mx) rounded.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3583
                gI := (g * (nG-1) + hG / mx) rounded .
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3584
                bI := (b * (nB-1) + hB / mx) rounded .
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3585
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3586
                idx := (((rI * nG) + gI) * nB + bI) + 1.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3587
                clr := (cube at:idx) exactOn:aDevice.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3588
                lastIdx isNil ifTrue:[lastIdx := idx]
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3589
                ifFalse:[lastIdx ~~ idx ifTrue:[lastIdx := -1]].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3590
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3591
                f foreground:clr.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3592
                f displayPointX:x y:y.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3593
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3594
                eR := r  - clr scaledRed.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3595
                eG := g  - clr scaledGreen.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3596
                eB := b  - clr scaledBlue.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3597
            ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3598
        ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3599
        f releaseGC.
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3600
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3601
        lastIdx ~~ -1 ifTrue:[
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3602
            ^ aBlock value:clr value:nil
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3603
        ].
6629a4f605c4 #QUALITY by sr
sr
parents: 7291
diff changeset
  3604
        ^ aBlock value:nil value:f
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3605
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3606
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3607
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3608
    ^ aBlock value:nil value:nil
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3609
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3610
    "Modified: 11.7.1996 / 18:30:28 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3611
    "Created: 3.5.1997 / 11:03:18 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3612
!
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3613
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3614
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
  3615
    "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
  3616
     Fraction is 0..1.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3617
     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
  3618
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3619
    |form c1 c2
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3620
     index "{ Class:SmallInteger }"|
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3621
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3622
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3623
    "/ 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
  3624
    "/ 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
  3625
    "/
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3626
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3627
    index := (fraction * 64) rounded.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3628
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3629
    c1 := color1 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3630
    index < 1 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3631
	^ aBlock value:c1 value:nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3632
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3633
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3634
    c2 := color2 exactOn:aDevice.
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3635
    index >= 64 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3636
	^ aBlock value:c2 value:nil
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3637
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3638
4772
be4524221fa7 Use Form class>>#width:height:fromArray:onDevice: instead of obsolete
Stefan Vogel <sv@exept.de>
parents: 4749
diff changeset
  3639
    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
  3640
    form colorMap:(Array with:c1 with:c2).
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3641
    ^ aBlock value:nil value:form
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3642
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3643
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3644
     Color basicNew
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3645
	monoDitherFor:(MaxValue // 2)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3646
	between:Color black
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3647
	and:Color white
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3648
	on:Display
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3649
	into:[:clr :dither | clr inspect. dither inspect]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3650
    "
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3651
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3652
    "Created: 3.5.1997 / 10:55:06 / cg"
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  3653
    "Modified: 3.5.1997 / 11:05:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3654
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3655
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3656
!Color class methodsFor:'queries'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3657
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3658
constantNames
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3659
    "return names known as instance creation messages"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3660
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3661
    ^ #(white black
6534
876e009486be class: Color
Claus Gittinger <cg@exept.de>
parents: 6385
diff changeset
  3662
        grey mediumGray veryLightGray lightGray darkGray veryDarkGray
876e009486be class: Color
Claus Gittinger <cg@exept.de>
parents: 6385
diff changeset
  3663
        red green blue cyan yellow pink orange magenta)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3664
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3665
    "Modified: 2.5.1996 / 11:34:05 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3666
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3667
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3668
scalingValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3669
    "ST-80 compatibility"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3670
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3671
    ^ MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3672
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3673
    "Created: 2.5.1996 / 11:30:09 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3674
    "Modified: 11.7.1996 / 21:42:26 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3675
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3676
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  3677
!Color class methodsFor:'special instance creation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3678
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3679
nearestColorRed:r green:g blue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3680
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3681
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3682
     If there is one, return it; nil otherwise.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3683
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3684
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3685
     vector distance (which may not be the best possible solution)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3686
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3687
    ^ self
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3688
	nearestColorScaledRed:(r * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3689
		  scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3690
		   scaledBlue:(b * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3691
			   on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3692
			   in:colors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3693
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3694
    "Modified: 11.6.1996 / 18:04:55 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3695
    "Created: 14.6.1996 / 20:05:13 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3696
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3697
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3698
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
  3699
    "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
  3700
     collection, containing colors from a colorCube.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3701
     This is used with preallocated fixColors and is quite fast
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3702
     (no need to search)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3703
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3704
    |sR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3705
     sG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3706
     sB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3707
     idx "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3708
     nR  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3709
     nG  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3710
     nB  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3711
     rI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3712
     gI  "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3713
     bI  "{ Class: SmallInteger }"|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3714
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3715
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3716
     round to the step given by FixColors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3717
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3718
    nR := nRed.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3719
    nG := nGreen.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3720
    nB := nBlue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3721
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3722
    sR := MaxValue // (nR - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3723
    sG := MaxValue // (nG - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3724
    sB := MaxValue // (nB - 1).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3725
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3726
    rI := (r + (sR // 2)) // sR.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3727
    gI := (g + (sG // 2)) // sG.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3728
    bI := (b + (sB // 2)) // sB.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3729
    idx := (((rI * nG) + gI) * nB + bI) + 1.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3730
    ^ aColorCube at:idx
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3731
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3732
    "Modified: 11.7.1996 / 17:52:46 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3733
    "Created: 11.7.1996 / 18:20:13 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3734
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3735
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3736
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3737
    "return a device color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3738
     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
  3739
     Near is defined as having an error less than the argument
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3740
     error (in percent). The error is computed by the color
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3741
     vector distance (which may not be the best possible solution)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3742
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3743
    |cube|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3744
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3745
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3746
     if there are preallocated colors, things are much easier ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3747
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3748
    (cube := aDevice fixColors) notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3749
	^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3750
	    nearestColorScaledRed:r
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3751
	    scaledGreen:g
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3752
	    scaledBlue:b
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3753
	    inCube:cube
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3754
	    numRed:(aDevice numFixRed)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3755
	    numGreen:(aDevice numFixGreen)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3756
	    numBlue:(aDevice numFixBlue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3757
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3758
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3759
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3760
     search in existing colors ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3761
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3762
    ^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3763
	nearestColorScaledRed:r
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3764
	scaledGreen:g
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3765
	scaledBlue:b
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3766
	on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3767
	in:aDevice deviceColors
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3768
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3769
    "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
  3770
    "Modified: 24.2.1997 / 18:17:51 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3771
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3772
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3773
nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice in:colors
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3774
    "return the nearest color on aDevice with RGB values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3775
     same or near r/g/b in a collection of colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3776
     If there is one, return it; nil otherwise."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3777
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3778
    |delta minDelta bestSoFar|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3779
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3780
    minDelta := 9999999.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3781
1619
4a7dbd25c588 handle the case where not even r/g/b primaries can be allocated
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3782
    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
  3783
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3784
    colors do:[:aColor |
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3785
	|cr cg cb|
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3786
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3787
	(aDevice isNil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3788
	or:[(aColor graphicsDevice == aDevice)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3789
	    and:[aColor colorId notNil]]) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3790
		delta := aColor deltaFromScaledRed:r scaledGreen:g scaledBlue:b.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3791
		delta < minDelta ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3792
		    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3793
		     an exact fit - no need to continue search
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3794
		    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3795
		    delta == 0 ifTrue:[^ aColor].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3796
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3797
		    bestSoFar := aColor.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3798
		    minDelta := delta
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3799
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3800
	    ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3801
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3802
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3803
    ^ bestSoFar
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3804
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  3805
    "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
  3806
    "Modified: / 28.7.1998 / 20:40:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3807
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3808
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3809
quickNearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3810
    "return a device color on aDevice with rgb values
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3811
     same or near r/g/b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3812
     This looks for primary colors only and is thus faster
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3813
     than the general nearestColor search (slightly uglier though)."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3814
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3815
    |cube|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3816
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3817
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3818
     if there are preallocated colors, things are much easier ...
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3819
    "
1954
479d294564d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
  3820
    (cube := aDevice fixColors) notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3821
	^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3822
	    nearestColorScaledRed:r
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3823
	    scaledGreen:g
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3824
	    scaledBlue:b
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3825
	    inCube:cube
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3826
	    numRed:(aDevice numFixRed)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3827
	    numGreen:(aDevice numFixGreen)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3828
	    numBlue:(aDevice numFixBlue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3829
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3830
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3831
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3832
     search in existing colors ...
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3833
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3834
    ^ self nearestColorScaledRed:r
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3835
		     scaledGreen:g
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3836
		      scaledBlue:b
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3837
			on:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3838
			in:(aDevice availableDitherColors)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3839
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3840
    "Created: 14.6.1996 / 20:13:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3841
    "Modified: 11.7.1996 / 18:20:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3842
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  3843
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3878
diff changeset
  3844
!Color methodsFor:'Compatibility-ST80'!
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3845
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3846
asDevicePaintOn:aDevice
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3847
    "ST-80 compatibility: an alias for on:.
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3848
     create a new Color representing the same color as
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3849
     myself on aDevice; if one already exists, return the one"
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  3850
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  3851
    ^ self onDevice:aDevice
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3852
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3853
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3854
asHiliteColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3855
    "same as lightened - for ST-80 compatibility"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3856
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3857
    ^ self lightened
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3858
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3859
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3860
asShadowColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3861
    "same as darkened - for ST-80 compatibility"
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3862
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3863
    ^ self darkened
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3864
! !
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3865
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3878
diff changeset
  3866
!Color methodsFor:'Compatibility-Squeak'!
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3867
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3868
alphaMixed: proportion with: aColor
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3869
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3870
     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
  3871
     between 0.0 and 1.0, determines what what fraction of the receiver to
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3872
     use in the mix. For example, 0.9 would yield a color close to the
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3873
     receiver. This method uses RGB interpolation; HSV interpolation can lead
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3874
     to surprises.  Mixes the alphas (for transparency) also."
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3875
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3876
    | frac1 frac2 |
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3877
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3878
    frac1 := proportion asFloat min: 1.0 max: 0.0.
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3879
    frac2 := 1.0 - frac1.
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  3880
    ^ self class
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  3881
        r: ((red * frac1) + (aColor scaledRed * frac2)) / MaxValue
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  3882
        g: ((green * frac1) + (aColor scaledGreen * frac2)) / MaxValue
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  3883
        b: ((blue * frac1) + (aColor scaledBlue * frac2)) / MaxValue
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  3884
        alpha: (self alpha * frac1) + (aColor alpha * frac2)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3885
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3886
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3887
     (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
  3888
     (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
  3889
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3890
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3891
    "Created: / 06-06-2007 / 10:53:25 / cg"
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3892
    "Modified (comment): / 03-02-2017 / 11:37:53 / cg"
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3893
!
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  3894
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3895
bitPatternForDepth: depth
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3896
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3897
     Return a Bitmap, possibly containing a stipple pattern,
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3898
     that best represents this color at the given depth.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3899
     BitBlt calls this method to convert colors into Bitmaps.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3900
     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
  3901
     pattern of several lines.  "
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3902
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3903
    "See also:
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3904
        pixelValueAtDepth:      -- value for single pixel
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3905
        pixelWordAtDepth:       -- a 32-bit word filled with the pixel value"
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3906
    "Details: The pattern for the most recently requested depth is cached."
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3907
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3908
^ self.
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3909
"/    depth == cachedDepth ifTrue: [^ cachedBitPattern].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3910
"/    cachedDepth _ depth.
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3911
"/
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3912
"/    depth > 2 ifTrue: [^ cachedBitPattern _ Bitmap with: (self pixelWordForDepth: depth)].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3913
"/    depth = 1 ifTrue: [^ cachedBitPattern _ self halfTonePattern1].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3914
"/    depth = 2 ifTrue: [^ cachedBitPattern _ self halfTonePattern2].
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3915
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3916
    "Modified (comment): / 03-02-2017 / 11:38:04 / cg"
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3917
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  3918
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3919
colorForInsets
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3920
    "Squeak compatibility - dummy"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3921
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3922
    ^ self
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3923
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3924
    "Modified (comment): / 03-02-2017 / 11:38:24 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3925
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3926
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3927
darker
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3928
    "Squeak compatibility;
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3929
     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
  3930
     Almost the same as darkened for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3931
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3932
    ^ self mixed:0.8333 with:Black
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3933
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3934
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3935
     (Color red) darker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3936
     (Color red) muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3937
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3938
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3939
    "Modified: / 11-06-1996 / 18:10:37 / cg"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3940
    "Modified (comment): / 03-02-2017 / 11:38:42 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3941
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3942
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3943
lighter
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3944
    "Squeak compatibility;
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3945
     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
  3946
     Almost the same as lightened for Squeak compatibility."
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3947
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3948
    ^ self mixed:0.8333 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3949
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3950
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  3951
     (Color red)
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3952
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3953
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3954
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3955
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3956
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3957
    "Modified: / 11-06-1996 / 18:10:49 / cg"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3958
    "Modified (comment): / 03-02-2017 / 11:38:47 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3959
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3960
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3961
muchDarker
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3962
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3963
     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
  3964
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3965
    ^ self mixed:0.233 with:Black
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3966
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3967
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3968
     (Color red) darker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3969
     (Color red) muchDarker
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3970
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3971
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3972
    "Modified: / 11-06-1996 / 18:10:49 / cg"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3973
    "Modified (comment): / 03-02-2017 / 11:37:46 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3974
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3975
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3976
muchLighter
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3977
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3978
     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
  3979
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3980
    ^ self mixed:0.233 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3981
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3982
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3983
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3984
     (Color red) mixed:0.833 with:Color white
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3985
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3986
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3987
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  3988
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3989
    "Modified: / 11-06-1996 / 18:10:49 / cg"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  3990
    "Modified (comment): / 03-02-2017 / 11:39:05 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  3991
!
3024
a565d805ad69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3021
diff changeset
  3992
4203
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3993
privateBlue
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3994
    "Squeak compatibility:
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3995
     return the blue components value mapped to 0..MaxValue"
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3996
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3997
    ^ self scaledBlue
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3998
!
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  3999
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4000
privateGreen
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4001
    "Squeak compatibility:
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4002
     return the green components value mapped to 0..MaxValue"
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4003
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4004
    ^ self scaledGreen
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4005
!
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4006
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4007
privateRed
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4008
    "Squeak compatibility:
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4009
     return the red components value mapped to 0..MaxValue"
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4010
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4011
    ^ self scaledRed
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4012
!
b306a1133946 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  4013
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4014
scaledPixelValue32
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4015
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4016
     return the argb byteValues packed into a 32bit integer;
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4017
     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
  4018
     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
  4019
     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
  4020
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4021
    ^ (self redByte bitShift:16)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4022
      + (self greenByte bitShift:8)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4023
      + (self blueByte)
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4024
      + (self alphaByte bitShift:24)
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4025
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4026
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4027
    "
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4028
     Color yellow scaledPixelValue
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4029
     Color yellow rgbValue
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4030
     Color yellow alpha
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4031
     Color yellow alphaByte
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4032
    "
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4033
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4034
    "Modified (comment): / 03-02-2017 / 11:40:03 / cg"
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4035
!
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4036
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4037
veryMuchLighter
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4038
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4039
     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
  4040
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4041
    ^ self mixed:0.1165 with:White
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4042
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4043
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4044
     (Color red) lighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4045
     (Color red) muchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4046
     (Color red) veryMuchLighter
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4047
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  4048
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4049
    "Modified: / 11-06-1996 / 18:10:49 / cg"
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4050
    "Modified (comment): / 03-02-2017 / 11:40:13 / cg"
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4051
!
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4052
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4053
wheel:thisMany
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4054
    "Squeak compatibility:
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4055
     An array of thisMany colors around the color wheel,
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4056
     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
  4057
     Array is of length thisMany.  
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4058
     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
  4059
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4060
    | sat l hue step c |
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4061
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4062
    thisMany = 1 ifTrue: [^ Array with: self].
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4063
    
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4064
    sat := self saturation.
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4065
    l := self light.
3396
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4066
    hue := self hue.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4067
    step := 360.0 / thisMany.
18f99e9fc5ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
  4068
    ^ (1 to: thisMany) collect: [:num |
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4069
        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
  4070
        hue := hue + step.
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4071
        c
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4072
    ].
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4073
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4074
    "
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4075
     Color red wheel:20
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4076
     Color red wheel:40
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4077
    "
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4078
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4079
    "Modified (comment): / 03-02-2017 / 11:50:59 / cg"
1347
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4080
! !
4e19b2d586a4 VW now has #on:, but calls it #asDevicePaintOn:
ca
parents: 1326
diff changeset
  4081
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4082
!Color methodsFor:'accessing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4083
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4084
alpha
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4085
    "return the alpha value (0..1),
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4086
     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
  4087
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4088
    ^ 1.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4089
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  4090
3309
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4091
alphaByte
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4092
    "return the alpha byte-value (0..255),
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4093
     where 0 is completely transparent and 255 is completely opaque"
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4094
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4095
    ^ 255.
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4096
!
cea34469e23f squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  4097
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4098
blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4099
    "return the blue component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4101
    (blue isNil and:[colorId notNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4102
	device isNil ifTrue:[^ 0].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4103
	device getRGBFrom:colorId into:[:r :g :b | ^ b].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4104
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4105
    ^ blue * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4106
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4107
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4108
blueByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4109
    "return the blue components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4110
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4111
    blue isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4112
    ^ blue * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4113
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4114
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4115
     Color red blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4116
     Color blue blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4117
     Color green blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4118
     Color black blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4119
     Color grey blueByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4120
     Color white blueByte
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4121
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4122
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4123
    "Created: / 7.6.1996 / 18:30:25 / cg"
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4124
    "Modified: / 26.7.1998 / 12:31:44 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4125
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4126
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4127
colorId
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4128
    "return the device-dependent color-id"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4129
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4130
    colorId notNil ifTrue:[^ colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4131
    replacementColor notNil ifTrue:[^ replacementColor colorId].
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4132
    ^ nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4133
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4134
    "Modified: 17.1.1997 / 00:03:18 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4135
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4136
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4137
cyan
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4138
    "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
  4139
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4140
    ^ 100 - self red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4141
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4142
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4143
    "Created: 11.6.1996 / 18:30:00 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4144
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4145
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4146
device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4147
    "return the device I am associated to"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4148
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4149
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4150
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4151
    "Modified: 23.4.1996 / 13:36:42 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4152
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4153
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4154
deviceBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4155
    "return the actual value of the blue component in percent."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4156
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4157
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4158
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4159
    device getRGBFrom:colorId into:[:r :g :b | v := b].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4160
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4161
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4162
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4163
deviceGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4164
    "return the actual value of the green component in percent.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4165
     (usually 16bit in X; but could be different on other systems)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4166
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4167
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4168
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4169
    device getRGBFrom:colorId into:[:r :g :b | v := g].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4170
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4171
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4172
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4173
deviceRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4174
    "return the actual value of the red component in percent."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4175
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4176
    |v|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4177
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4178
    device getRGBFrom:colorId into:[:r :g :b | v := r].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4179
    ^ v
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4180
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4181
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4182
     (Color yellow on:Display) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4183
     (Color yellow on:aPrinterPage) deviceRedValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4184
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4185
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4186
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4187
ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4188
    "return the form to dither the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4189
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4190
    ^ ditherForm
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4191
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4192
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4193
graphicsDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4194
    "same as #device, for ST-80 compatibility naming.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4195
     Return the device I am associated with."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4196
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4197
    ^ device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4198
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4199
    "Created: 28.5.1996 / 18:39:27 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4200
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4201
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4202
green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4203
    "return the green component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4204
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4205
    (green isNil and:[colorId notNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4206
	device isNil ifTrue:[^ 0].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4207
	device getRGBFrom:colorId into:[:r :g :b | ^ g].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4208
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4209
    ^ green * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4210
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4211
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4212
greenByte
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4213
    "return the green components value mapped to 0..255"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4214
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4215
    green isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4216
    ^ green * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4217
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4218
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4219
     Color red greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4220
     Color blue greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4221
     Color green greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4222
     Color black greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4223
     Color grey greenByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4224
     Color white greenByte
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4225
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4226
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4227
    "Modified: / 26.7.1998 / 12:31:33 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4228
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4229
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4230
hue
6654
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4231
    "return the hue (in hue/light/saturation model) in degrees [0..360].
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4232
     The hue value is the position on the color wheel.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4233
     0 is red, 120 green, 240 blue"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4234
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4235
    |r g b h|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4236
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4237
    (red isNil and:[colorId notNil]) ifTrue:[
6654
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4238
        device getRGBFrom:colorId into:[:xr :xg :xb |
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4239
            r := xr.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4240
            g := xg.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4241
            b := xb.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4242
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4243
    ] ifFalse:[
6654
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4244
        r := self red.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4245
        g := self green.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4246
        b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4247
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4248
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4249
    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
  4250
        h := xh
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4251
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4252
    ^ h
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4253
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4254
    "
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4255
     Color red hue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4256
     Color yellow hue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4257
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4258
6654
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4259
    "
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4260
     color wheel:
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4261
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4262
     |v|
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4263
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4264
     v := View new extent:200@200.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4265
     v openAndWait.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4266
     0 to:360 do:[:hue |
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4267
        100 downTo:0 do:[:sat |
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4268
            |p|
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4269
            v paint:(Color hue:hue light:50 saturation:sat).
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4270
            p := Point r:sat degrees:hue.
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4271
            v displayLineFrom:100@100 to:p+(100@100).
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4272
        ].
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4273
     ].
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4274
    "
57ee2fe958b9 class: Color
Claus Gittinger <cg@exept.de>
parents: 6584
diff changeset
  4275
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4276
    "Modified: 11.6.1996 / 17:14:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4277
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4278
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4279
light
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4280
    "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
  4281
     This corresponds to the brightness of the color (if displayed on
6170
8b03d05c720d class: Color
Claus Gittinger <cg@exept.de>
parents: 6110
diff changeset
  4282
     a b&w television screen).
8b03d05c720d class: Color
Claus Gittinger <cg@exept.de>
parents: 6110
diff changeset
  4283
     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
  4284
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4285
    |r g b l|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4286
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4287
    (red isNil and:[colorId notNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4288
	device getRGBFrom:colorId into:[:xr :xg :xb |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4289
	    r := xr.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4290
	    g := xg.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4291
	    b := xb.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4292
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4293
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4294
	r := self red.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4295
	g := self green.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4296
	b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4297
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4298
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4299
    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
  4300
	l := xl
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4301
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4302
    ^ l
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4303
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4304
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4305
     Color yellow light
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4306
     Color yellow darkened light
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4307
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4308
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4309
    "Modified: 11.6.1996 / 17:15:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4310
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4311
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4312
magenta
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4313
    "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
  4314
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4315
    ^ 100 - self green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4316
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4317
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4318
    "Created: 11.6.1996 / 18:30:11 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4319
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4320
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4321
privateAlpha
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4322
    "return the internal alpha value (0..255),
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4323
     where 0 is completely transparent and 255 is completely opaque"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4324
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4325
    ^ 255
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4326
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4327
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  4328
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4329
red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4330
    "return the red component in percent [0..100]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4331
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4332
    (red isNil and:[colorId notNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4333
	device isNil ifTrue:[^ 0].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4334
	device getRGBFrom:colorId into:[:r :g :b | ^ r].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4335
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4336
    red isNil ifTrue:[^ 0].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4337
    ^ red * 100.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4338
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4339
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4340
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4341
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4342
red:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4343
    "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
  4344
     table in pseudocolor devices.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4345
     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
  4346
     Color>>variableColorOn: on pseudoColor displays).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4347
     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
  4348
     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
  4349
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4350
    ^ self scaledRed:(r * MaxValue // 100)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4351
	   scaledGreen:(g * MaxValue // 100)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4352
	   scaledBlue:(b * MaxValue // 100)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4353
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4354
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4355
     |c|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4356
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4357
     c := Color variableColorOn:Display.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4358
     c inspect.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4359
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4360
     c red:100 green:0 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4361
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4362
     c red:0 green:100 blue:0.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4363
     (Delay forSeconds:5) wait.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4364
     c red:0 green:0 blue:100.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4365
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4366
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4367
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4368
redByte
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4369
    "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
  4370
     nil if it has no red component."
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4371
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4372
    red isNil ifTrue:[^ nil].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4373
    ^ red * 255 // MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4374
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4375
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4376
     Color red redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4377
     Color blue redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4378
     Color green redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4379
     Color black redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4380
     Color grey redByte
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4381
     Color white redByte
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4382
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4383
2183
3c2115660746 removed row[Red/Green/Blue]Byte;
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
  4384
    "Modified: / 26.7.1998 / 12:31:22 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4385
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4386
7830
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4387
rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4388
    "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
  4389
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4390
    |r "{ Class: SmallInteger }"
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4391
     g "{ Class: SmallInteger }"
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4392
     b "{ Class: SmallInteger }"|
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4393
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4394
    r := red * 255 // MaxValue.
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4395
    g := green * 255 // MaxValue.
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4396
    b := blue * 255 // MaxValue.
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4397
    ^ ByteArray with:r with:g with:b
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4398
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4399
    "
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4400
     Color red rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4401
     Color blue rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4402
     Color green rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4403
     Color black rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4404
     Color grey rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4405
     Color white rgbBytes
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4406
    "
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4407
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4408
    "Created: / 03-02-2017 / 11:31:24 / cg"
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4409
!
fa41edb7876a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7798
diff changeset
  4410
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4411
rgbValue
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4412
    "return the rgb byteValues packed into a 24bit integer;
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4413
     The returned value is composed of r<<16 + g<<8 + b."
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4414
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4415
    |t "{ Class: SmallInteger }"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4416
     v "{ Class: SmallInteger }"|
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4417
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4418
    v := red * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4419
    t := green * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4420
    v := (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4421
    t := blue * 255 // MaxValue.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4422
    ^ (v bitShift:8) + t.
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4423
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4424
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4425
     Color red rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4426
     Color blue rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4427
     Color green rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4428
     Color black rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4429
     Color grey rgbValue hexPrintString
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4430
     Color white rgbValue hexPrintString
1929
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4431
    "
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4432
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4433
    "Modified: 17.10.1997 / 20:00:25 / cg"
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4434
!
e500fcf94969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4435
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4436
saturation
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4437
    "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
  4438
     This corresponds to the saturation setting of a color TV"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4439
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4440
    |r g b s|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4441
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4442
    (red isNil and:[colorId notNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4443
	device getRGBFrom:colorId into:[:xr :xg :xb |
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4444
	    r := xr.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4445
	    g := xg.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4446
	    b := xb.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4447
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4448
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4449
	r := self red.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4450
	g := self green.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4451
	b := self blue.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4452
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4453
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4454
    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
  4455
	s := xs
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4456
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4457
    ^ s
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4458
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4459
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4460
     Color yellow saturation
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4461
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4462
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4463
    "Modified: 11.6.1996 / 17:15:47 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4464
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4465
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4466
scaledAlpha
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4467
    "ST-80 compatibility:
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4468
     return the alpha components value mapped to 0..MaxValue"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4469
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4470
    ^ MaxValue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4471
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4472
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4473
     Color blue scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4474
     Color black scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4475
     Color grey scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4476
    "
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4477
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4478
    "Modified: 7.6.1996 / 18:32:30 / cg"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4479
!
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4480
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4481
scaledBlue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4482
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4483
     return the blue components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4484
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4485
    ^ blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4486
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4487
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4488
     Color blue scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4489
     Color black scaledBlue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4490
     Color grey scaledBlue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4491
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4492
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4493
    "Modified: 7.6.1996 / 18:32:30 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4494
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4495
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4496
scaledGray
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4497
    "return the grey intensity scaled to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4498
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4499
    ^ ((red * 3) + (green * 6) + blue) // 10
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4500
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4501
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4502
     Color blue scaledGray
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4503
     Color black scaledGray
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4504
     Color white scaledGray
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4505
     Color grey scaledGray
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4506
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4507
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4508
    "Modified: 11.6.1996 / 14:43:51 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4509
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4510
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4511
scaledGreen
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4512
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4513
     return the green components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4514
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4515
    ^ green
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4516
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4517
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4518
     Color green scaledRed
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4519
     Color black scaledRed
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4520
     Color grey scaledRed
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4521
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4522
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4523
    "Modified: 7.6.1996 / 18:32:38 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4524
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4525
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4526
scaledRed
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4527
    "ST-80 compatibility:
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4528
     return the red components value mapped to 0..MaxValue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4529
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4530
    ^ red
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4531
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4532
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4533
     Color red scaledRed
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4534
     Color black scaledRed
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4535
     Color grey scaledRed
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4536
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4537
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4538
    "Modified: 7.6.1996 / 18:32:43 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4539
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4540
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4541
scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4542
    "set r/g/b components in 0..MaxValue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4543
     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
  4544
     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
  4545
     Color>>variableColorOn: on pseudoColor displays).
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4546
     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
  4547
     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
  4548
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4549
    (colorId isNil or:[red notNil]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4550
	^ self error:'operation is not allowed for shared colors'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4551
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4552
    device setColor:colorId scaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4553
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4554
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4555
writable
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4556
    "return true, if this is a writable colorcell"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4557
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4558
    ^ writable == true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4559
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4560
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4561
yellow
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4562
    "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
  4563
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4564
    ^ 100 - self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4565
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4566
    "Modified: 11.6.1996 / 17:20:07 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4567
    "Created: 11.6.1996 / 18:30:20 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4568
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4569
5131
95d91d6d649c care for invalid hue/light/saturation
Claus Gittinger <cg@exept.de>
parents: 5127
diff changeset
  4570
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4571
!Color methodsFor:'comparing'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4572
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4573
= aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4574
    "two colors are considered equal, if the color components are;
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4575
     independent of the device, the color is on"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4576
2083
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  4577
    aColor == self ifTrue:[^ true].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4578
    aColor isColor ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4579
	(red == aColor scaledRed) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4580
	    (green == aColor scaledGreen) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4581
		(blue == aColor scaledBlue) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4582
		    ^ true
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4583
		]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4584
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4585
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4586
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4587
    ^ false
2083
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  4588
117f2e5ca733 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  4589
    "Modified: / 2.4.1998 / 10:04:39 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4590
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4591
1390
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4592
almostSameAs:aColor
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4593
    "return true, if aColor looks almost the same as the receiver
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4594
     (i.e. the components differ by a small, invisible amount).
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4595
     We assume, that the human eye can distinguish roughly 100 grey levels
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4596
     (which is optimistic ;-);
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4597
     therefore, allow a 1 percent difference in each component for the colors
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4598
     to compare as looking the same."
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4599
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4600
     (self red - aColor red) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4601
     (self green - aColor green) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4602
     (self blue - aColor blue) abs > 1 ifTrue:[^ false].
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4603
     ^ true
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4604
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4605
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4606
      (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
  4607
     "
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4608
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4609
    "Modified: 28.2.1997 / 12:00:01 / cg"
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4610
!
4b519886451f added #almostSameAs:
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  4611
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4612
hash
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4613
    "return an integer useful as hash key for the receiver.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4614
     Redefined since = is redefined"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4615
2318
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  4616
    red isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4617
	^ colorId
2318
36d73b850969 fixed hash for colorId colors.
Claus Gittinger <cg@exept.de>
parents: 2313
diff changeset
  4618
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4619
    ^ red + green + blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4620
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4621
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4622
!Color methodsFor:'converting'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4623
6830
4b029193d399 class: Color
Claus Gittinger <cg@exept.de>
parents: 6793
diff changeset
  4624
asByteArray
7831
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4625
    "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
  4626
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4627
    ^ self rgbBytes.
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4628
"/    ^ByteArray
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4629
"/            with: self redByte
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4630
"/            with: self greenByte
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4631
"/            with: self blueByte
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4632
460d842964af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7830
diff changeset
  4633
    "Modified: / 03-02-2017 / 11:33:23 / cg"
6830
4b029193d399 class: Color
Claus Gittinger <cg@exept.de>
parents: 6793
diff changeset
  4634
!
4b029193d399 class: Color
Claus Gittinger <cg@exept.de>
parents: 6793
diff changeset
  4635
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4636
fromLiteralArrayEncoding:encoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4637
    "read my values from an encoding.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4638
     The encoding is supposed to be either of the form:
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4639
        (#Color redPart greenPart bluePart)
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4640
     or:
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4641
        (#Color constantColorSymbol)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4642
     This is the reverse operation to #literalArrayEncoding."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4643
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4644
    |clr nameOrRGB|
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4645
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4646
    encoding size == 2 ifTrue:[
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4647
        nameOrRGB := encoding at:2.
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4648
        nameOrRGB isSymbol ifTrue:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4649
            clr := self class perform:nameOrRGB
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4650
        ] ifFalse:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4651
            clr := self class rgbValue:nameOrRGB.
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4652
        ].
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4653
        red := clr scaledRed.
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4654
        green := clr scaledGreen.
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4655
        blue := clr scaledBlue
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4656
    ] ifFalse:[
6554
6595cc1cf732 class: Color
Claus Gittinger <cg@exept.de>
parents: 6553
diff changeset
  4657
        red := ((encoding at:2) / 100.0 * MaxValue) rounded asInteger.
6595cc1cf732 class: Color
Claus Gittinger <cg@exept.de>
parents: 6553
diff changeset
  4658
        green := ((encoding at:3) / 100.0 * MaxValue) rounded asInteger.
6595cc1cf732 class: Color
Claus Gittinger <cg@exept.de>
parents: 6553
diff changeset
  4659
        blue := ((encoding at:4) / 100.0 * MaxValue) rounded asInteger.
2778
3ef64f104266 allow 'Color colorName' in literalEncoding.
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  4660
    ].
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
    "
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4663
      Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4664
      Color new fromLiteralArrayEncoding:#(#Color 16rFF00FF)
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4665
      Color new fromLiteralArrayEncoding:#(#Color blue)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4666
    "
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4669
literalArrayEncoding
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4670
    "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
  4671
     can be reconstructed with #decodeAsLiteralArray.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4672
     The encoding is:
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4673
        (#Color redPart greenPart bluePart)
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4676
    ^ Array
6552
9a9548feb83c class: Color
Claus Gittinger <cg@exept.de>
parents: 6534
diff changeset
  4677
        with:self class name
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4678
        with:((red * 100.0 / MaxValue) roundTo:0.25)
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4679
        with:((green * 100.0 / MaxValue) roundTo:0.25)
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  4680
        with:((blue * 100.0 / MaxValue) roundTo:0.25)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4681
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4682
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4683
      Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4684
      (Color red:25 green:30 blue:70) literalArrayEncoding
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4685
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4686
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4687
    "Modified: 22.4.1996 / 13:00:11 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4690
!Color methodsFor:'copying'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4691
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4692
postCopy
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4693
    "redefined to clear out any device handles in the copy"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4694
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4695
    device := colorId := ditherForm := replacementColor := nil
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4696
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4697
    "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
  4698
!
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4699
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4700
skipInstvarIndexInDeepCopy:index
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4701
    index == 4 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4702
	^ true "/ skip device
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4703
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4704
    index == 5 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4705
	^ true "/ skip colorId
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4706
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4707
    index == 6 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4708
	^ true "/ skip ditherForm
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4709
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4710
    index == 7 ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4711
	^ true "/ skip replacementColor
2910
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4712
    ].
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4713
    ^ false
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4714
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4715
    "
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4716
     (Color black onDevice:Screen current) deepCopy
97a836c7e15c deepCopy fix (do not copy device dependent stuff)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  4717
    "
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4720
!Color methodsFor:'getting a device color'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4721
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4722
exactOn:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4723
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4724
     myself on aDevice; if one already exists, return the one.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4725
     Do not dither or otherwise approximate the color, but return
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4726
     nil, if the exact color is not available.
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4727
     Used to acquire primary colors for dithering, during startup."
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4728
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4729
    |newColor id r g b|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4730
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4731
    "if Iam already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4732
    (device == aDevice and:[ditherForm isNil]) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4733
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4734
    r := red.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4735
    g := green.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4736
    b := blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4737
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4738
    "first look if not already there"
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4739
    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
  4740
    (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
  4741
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4742
    r := (r bitAnd:16rFF00) bitOr:(r bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4743
    g := (g bitAnd:16rFF00) bitOr:(g bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4744
    b := (b bitAnd:16rFF00) bitOr:(b bitShift:-8).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4745
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4746
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4747
    id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4748
    id isNil ifTrue:[
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4749
        "/ this is a kludge: scavenge to free unused colors
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4750
        "/  and try again ...
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4751
        ObjectMemory scavenge; finalize.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4752
        id := aDevice colorScaledRed:r scaledGreen:g scaledBlue:b
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4753
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4754
    id isNil ifTrue:[
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4755
        "no such color - fail"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4756
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4757
"/      'COLOR: no color for ' infoPrint. self displayString infoPrintCR.
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4758
        ^ nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4759
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4760
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4761
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4762
    device isNil ifTrue:[
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4763
        device := aDevice.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4764
        colorId := id.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4765
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4766
        aDevice visualType ~~ #TrueColor ifTrue:[
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4767
            "/ Lobby register:self.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4768
            aDevice registerColor:self.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4769
        ].
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4770
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4771
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4772
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4773
    "receiver was already associated to another device - need a new color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4774
    newColor := (self class basicNew) setScaledRed:r scaledGreen:g scaledBlue:b device:aDevice.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4775
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4776
    aDevice visualType ~~ #TrueColor ifTrue:[
7403
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4777
        "/ Lobby register:newColor.
9a4c5d6da62c #OTHER by mawalch
mawalch
parents: 7360
diff changeset
  4778
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4779
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4780
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4781
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4782
    "Modified: 24.2.1997 / 18:23:20 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4783
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4784
1856
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4785
exactOrNearestOn:aDevice
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4786
    "get a device color for the receiver, which is either exact
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4787
     or the nearest, but never dithered.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4788
     This can be used for viewBackgrounds, where the exact greyLevel
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4789
     does not matter, but a dithered color is not wanted."
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4790
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4791
    |deviceColor|
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4792
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4793
    deviceColor := self exactOn:aDevice.
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4794
    deviceColor isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4795
	deviceColor := self nearestOn:aDevice
1856
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4796
    ].
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4797
    ^ deviceColor
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4798
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4799
    "Created: 13.8.1997 / 15:25:48 / cg"
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4800
!
50a92c932fbd added #exactOrNearestOn:
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  4801
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4802
nearestIn:aColorMap
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4803
    "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
  4804
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4805
    ^ self class
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4806
	nearestColorScaledRed:(self scaledRed)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4807
		  scaledGreen:(self scaledGreen)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4808
		   scaledBlue:(self scaledBlue)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4809
			   on:nil
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4810
			   in:aColorMap
2198
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4811
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4812
    "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
  4813
!
122ff0da86d6 added support to find the nearest color in a colorMap.
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
  4814
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4815
nearestOn:aDevice
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4816
    "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
  4817
     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
  4818
     search for the nearest match"
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
    |newColor id|
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4821
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4822
    "if I'am already assigned to that device ..."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4823
    (device == aDevice) ifTrue:[^ self].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4824
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4825
    "first look if not already there"
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4826
    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
  4827
    newColor notNil ifTrue:[^ newColor].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4828
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4829
    "ask that device for the color"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4830
    id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4831
    id isNil ifTrue:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4832
        "this is a kludge:
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4833
            scavenge to possuby free unused colors and try again ...
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4834
            this is a compromise: actually a full GC is required here,
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4835
            but that is too expensive.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4836
        "
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4837
        ObjectMemory scavenge; finalize.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4838
        id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4839
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4840
    id isNil ifTrue:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4841
        "no color - fail"
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4842
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4843
        ^ nil
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4846
    "receiver was not associated - do it now"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4847
    device isNil ifTrue:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4848
        device := aDevice.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4849
        colorId := id.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4850
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4851
        aDevice visualType ~~ #TrueColor ifTrue:[
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4852
            "/ Lobby register:self.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4853
            aDevice registerColor:self.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4854
        ].
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4855
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4856
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4857
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4858
    "receiver was already associated to another device - need a new color"
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4859
    newColor := self class basicNew setScaledRed:red scaledGreen:green scaledBlue:blue device:aDevice.
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  4860
    newColor setColorId:id.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4861
    aDevice visualType ~~ #TrueColor ifTrue:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4862
        "/ Lobby register:newColor.
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4863
        aDevice registerColor:newColor.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4864
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4865
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4866
1365
37a9e7ac4dbc moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
  4867
    "Modified: 24.2.1997 / 18:23:26 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4868
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4869
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4870
on:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4871
    "create a new Color representing the same color as
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4872
     myself on aDevice; if one already exists, return the one"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4873
3623
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4874
    "/ send out a warning: #on: is typically used to create views
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4875
    "/ operating on a model.
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4876
    "/ Please use #onDevice: to avoid confusion.
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4877
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4878
    <resource:#obsolete>
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4879
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4880
    self obsoleteMethodWarning:'use #onDevice:'.
2836
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4881
    ^ self onDevice:aDevice
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4882
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4883
    "Created: / 16.11.1995 / 20:16:42 / cg"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4884
    "Modified: / 8.9.1998 / 17:32:10 / cg"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4885
!
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4886
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4887
onDevice:aDevice
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4888
    "create a new Color representing the same color as
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4889
     myself on aDevice; if one already exists, return the one"
6c1f6b223329 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2828
diff changeset
  4890
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4891
    |newColor id form
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4892
     greyV "{ Class: SmallInteger }"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4893
     rV    "{ Class: SmallInteger }"
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4894
     gV    "{ Class: SmallInteger }"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4895
     bV    "{ Class: SmallInteger }"
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4896
     deviceVisual deviceFixColors deviceDepth|
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4897
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  4898
    "/ the most common cases (already allocated) first
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4899
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  4900
    colorId notNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4901
        "/ is someone validating me before drawing on aDevice ?
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4902
        (aDevice notNil and:[aDevice == device]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4903
            ^ self
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4904
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4905
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4906
        "/ a special case for pseudo-colors (0 and 1 in bitmaps)
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4907
        "/ those have nil r/g/b values, but a nonNil colorId
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4908
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4909
        red isNil ifTrue:[^ self].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4910
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4911
        "/ want to release color ?
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4912
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4913
        (aDevice isNil and:[device notNil]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4914
            "/ trueColor device-colors are not registered
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4915
            device visualType ~~ #TrueColor ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4916
                device unregisterColor:newColor.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4917
                device freeColor:colorId
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4918
            ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4919
            device := nil.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4920
            colorId := nil.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4921
            ^ self
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4922
        ].
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4923
    ].
2313
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4924
    aDevice isNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4925
        ^ self
2313
35b10e50a455 care for early onDevice:nil
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
  4926
    ].
1205
e28b664586f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
  4927
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4928
    device == aDevice ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4929
        ditherForm notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4930
            ^ self
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4931
        ]
1707
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4932
    ].
c4ba0f13330c made all dither stuff class protocol
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
  4933
7650
5781e05a6a1d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7642
diff changeset
  4934
    "/ 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
  4935
    "/ especially freeing colors
2842
dcb1f8eb648f removed obsolete method
Claus Gittinger <cg@exept.de>
parents: 2836
diff changeset
  4936
    "/ (no need to register)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4937
2375
265a5137e286 oops - possible color reuse between devices fixed
Claus Gittinger <cg@exept.de>
parents: 2318
diff changeset
  4938
    deviceDepth := aDevice depth.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4939
    (deviceVisual := aDevice visualType) == #TrueColor ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4940
        deviceDepth >= 15 ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4941
            id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4942
            id notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4943
                device isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4944
                    "/ receiver was not associated - do it now & return mySelf
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4945
                    colorId := id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4946
                    ditherForm := nil.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4947
                    device := aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4948
                    ^ self
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4949
                ].
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4950
                newColor := self class basicNew
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4951
                                    setScaledRed:red
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4952
                                    scaledGreen:green
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4953
                                    scaledBlue:blue
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4954
                                    device:aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4955
                newColor setColorId:id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4956
                ^ newColor
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4957
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4958
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4959
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4960
1239
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4961
    rV := red.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4962
    gV := green.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4963
    bV := blue.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4964
7782
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
  4965
"/    "/ 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
  4966
"/    rV := (red / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4967
"/    gV := (green / 100.0) rounded * 100.
f4bd3bc9f3f9 oops - dont round when searching for existing colors
Claus Gittinger <cg@exept.de>
parents: 1238
diff changeset
  4968
"/    bV := (blue / 50.0) rounded * 50.
7782
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
  4969
"/
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
  4970
"/    "/ if I am already assigned to that device ...
5c396aabbe58 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7762
diff changeset
  4971
"/
1368
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4972
"/    ((device == aDevice) and:[ditherForm notNil]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4973
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4974
"/        "/ 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
  4975
"/        "/ try again - maybe some colors were reclaimed in the meanwhile
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4976
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4977
"/        deviceFixColors := aDevice fixColors.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4978
"/
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4979
"/        (deviceFixColors isNil
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4980
"/         and:[RetryAllocation]) ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4981
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4982
"/             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
  4983
"/            "
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4984
"/            aDevice depth > 2 ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4985
"/                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4986
"/                id notNil ifTrue:[
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4987
"/                    colorId := id.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4988
"/                    ditherForm := nil.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4989
"/                    device registerColor:self.
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4990
"/                ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4991
"/            ]
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4992
"/        ].
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4993
"/        ^ self
cb5fbbcf568f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
  4994
"/    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  4995
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  4996
    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
  4997
    newColor notNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4998
        (newColor scaledRed ~~ red
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  4999
        or:[newColor scaledGreen ~~ green
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5000
        or:[newColor scaledBlue ~~ blue]]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5001
            Transcript showCR:'Color>>#onDevice: got different color'.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5002
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5003
        ^ newColor
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5004
    ].
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5005
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5006
    "/ ask that device for the exact color
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5007
    id := aDevice colorScaledRed:red scaledGreen:green scaledBlue:blue.
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5008
    id notNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5009
        device isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5010
            "/ receiver was not associated - do it now & return mySelf
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5011
            colorId := id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5012
            ditherForm := nil.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5013
            device := aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5014
            newColor := self.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5015
        ] ifFalse:[
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5016
            newColor := self class basicNew
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5017
                                setScaledRed:red
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5018
                                scaledGreen:green
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5019
                                scaledBlue:blue
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5020
                                device:aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5021
            newColor setColorId:id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5022
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5023
        id notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5024
            deviceVisual ~~ #TrueColor ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5025
                aDevice registerColor:newColor.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5026
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5027
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5028
        ^ newColor
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5029
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5030
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5031
    "/
2973
59770deee81c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2972
diff changeset
  5032
    "/ 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
  5033
    "/ the nearest.
7885
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5034
    "/ 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
  5035
    "/
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5036
    greyV := (3 * red) + (6 * green) + (1 * blue).
1621
5b1e6427d5f6 monochrome fixes
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  5037
    greyV := (greyV / 1000.0) rounded * 100.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5038
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5039
    "/ allow an error of 1% in red & green, 2% in blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5040
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5041
    ((rV - greyV) abs <= 655                    "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5042
    and:[(gV - greyV) abs <= 655                "/ MaxValue // 100
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5043
    and:[(bV - greyV) abs <= 1310]]) ifTrue:[   "/ MaxValue // 100 * 2
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5044
        rV := gV := bV := greyV.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5045
    ] ifFalse:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5046
        rV := red. gV := green. bV := blue.
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5049
    aDevice hasColors ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5050
        deviceFixColors := aDevice fixColors.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5051
        deviceFixColors isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5052
            "/ ask that device for the exact color
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5053
            id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5054
            id isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5055
                aDevice isOpen ifFalse:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5056
                    ^ nil
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5057
                ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5058
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5059
                "/ this is a kludge: scavenge to free unused colors
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5060
                "/ and try again ...
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5061
                ObjectMemory scavenge; finalize.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5062
                id := aDevice colorScaledRed:rV scaledGreen:gV scaledBlue:bV
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5063
            ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5064
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5065
            id isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5066
                "/ no such color - try color dithers
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5067
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5068
                self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5069
                    ditherRed:rV green:gV blue:bV
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5070
                    on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5071
                    into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5072
                newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5073
            ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5074
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5075
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5076
        "/ none found ? -> do a hard dither using fixColors
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5077
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5078
        (id isNil and:[form isNil]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5079
            deviceFixColors notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5080
                self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5081
                    fixDitherRed:rV green:gV blue:bV
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5082
                    on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5083
                    into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5084
                newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5085
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5086
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5087
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5088
        "/ still none found ? -> do a very hard dither using existing colors
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5089
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5090
        (id isNil and:[form isNil]) ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5091
            self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5092
                complexDitherRed:rV green:gV blue:bV
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5093
                on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5094
                into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5095
            newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5096
        ].
1023
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5099
    (id isNil and:[form isNil]) ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5100
        "still no result - try graying"
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5101
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5102
        greyV == 0 ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5103
            id := aDevice blackpixel
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5104
        ] ifFalse:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5105
            greyV == MaxValue ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5106
                id := aDevice whitepixel
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5107
            ] ifFalse:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5108
                aDevice hasGrayscales ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5109
                    self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5110
                        ditherGrayFor:(greyV / MaxValue)
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5111
                        on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5112
                        into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5113
                    newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5114
                ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5115
                form isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5116
                    "/ still none - dither b&w
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5117
                    self class
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5118
                        monoDitherFor:(greyV / MaxValue)
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5119
                        between:Black and:White
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5120
                        on:aDevice
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5121
                        into:[:c :f | newColor := c. form := f].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5122
                    newColor notNil ifTrue:[^ newColor].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5123
                    form isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5124
                        "/ cannot happen
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5125
                        'Color [warning]: monoDither failed' errorPrintCR.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5126
                        ^ nil
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5127
                    ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5128
                ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5129
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5130
        ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5131
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5132
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5133
    device isNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5134
        "/ receiver was not associated - do it now & return mySelf
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5135
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5136
        device := aDevice.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5137
        id isNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5138
            ditherForm := form
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5139
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5140
        colorId := id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5141
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5142
        "/ have to register - otherwise it keeps old info around
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5143
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5144
        id notNil ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5145
            deviceVisual ~~ #TrueColor ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5146
                aDevice registerColor:self.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5147
            ]
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5148
        ].
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5149
        ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5150
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5151
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5152
    "/ receiver was already associated to another device
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5153
    "/ - need a new color and return it
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5154
7762
29af5517f03a #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7758
diff changeset
  5155
    newColor := self class basicNew
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5156
                        setScaledRed:red
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5157
                        scaledGreen:green
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5158
                        scaledBlue:blue
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5159
                        device:aDevice.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5160
    id isNil ifTrue:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5161
        newColor setDitherForm:form
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5162
    ] ifFalse:[
7291
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5163
        newColor setColorId:id.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5164
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5165
        "/ trueColor device-colors are not registered
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5166
        deviceVisual ~~ #TrueColor ifTrue:[
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5167
            aDevice registerColor:newColor.
27effa38e219 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6967
diff changeset
  5168
        ]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5169
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5170
    ^ newColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5171
7885
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5172
    "Created: / 16-11-1995 / 20:16:42 / cg"
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5173
    "Modified: / 08-09-1998 / 17:32:10 / cg"
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5174
    "Modified (comment): / 13-02-2017 / 19:58:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5175
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5176
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5177
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5178
!Color methodsFor:'instance creation'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5179
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5180
alpha:alphaValue
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5181
    "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
  5182
     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
  5183
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5184
    alphaValue = 1 ifTrue:[ ^ self].
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5185
    ^ (TranslucentColor
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5186
	   scaledRed:red
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5187
	   scaledGreen:green
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5188
	   scaledBlue:blue) alpha:alphaValue
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5189
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5190
    "
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5191
     (Color red alpha:0.5) alpha
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5192
     Color red alpha
4789
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5193
    "
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5194
8a525695f2ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  5195
    "Modified: / 06-06-2007 / 11:17:55 / cg"
2948
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5196
!
86566f076d30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  5197
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5198
blendWith:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5199
    "create a new color from equally mixing the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5200
     and the argument, aColor.
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5201
     Mixing is done by adding components
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5202
     (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
  5203
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5204
    ^ self mixed:1 with:aColor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5205
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5206
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5207
     (Color red) blendWith:(Color yellow)
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5208
     (Color red) blendWith:(Color blue)
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5209
     (Color red) blendWith:(Color black)
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5210
     (Color red) blendWith:(Color white)
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5211
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5212
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5213
    "Modified: 10.2.1997 / 22:08:14 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5214
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5215
5965
4f8e9e2ec50b class: Color
Stefan Vogel <sv@exept.de>
parents: 5957
diff changeset
  5216
contrastingBlackOrWhite
7639
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5217
    "answer either black or white, whichever gives a better contrast
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5218
     for drawing text on a background with my color.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5219
     (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
  5220
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5221
    ^ self brightness < 0.55 
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5222
        ifTrue:[self class white] 
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5223
        ifFalse:[self class black]
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5224
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5225
    "
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5226
     (Color blue) contrastingBlackOrWhite
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5227
     (Color red) contrastingBlackOrWhite
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5228
     (Color green) contrastingBlackOrWhite
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5229
     (Color yellow) contrastingBlackOrWhite
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5230
    "
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5231
!
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5232
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5233
contrastingColorFor:aBackgroundColor
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5234
    "answer a slightly brightened or darkened variant of myself,
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5235
     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
  5236
     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
  5237
     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
  5238
     Use this for alert strings shown on a color background."
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5239
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5240
    |colorUsed bgBrightness|
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5241
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5242
    colorUsed := self.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5243
    bgBrightness := aBackgroundColor brightness.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5244
    
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5245
    (bgBrightness dist:colorUsed brightness) < 0.5 ifTrue:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5246
        bgBrightness > 0.5 ifTrue:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5247
            colorUsed := self slightlyDarkened.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5248
            (bgBrightness dist:colorUsed brightness) < 0.5 ifTrue:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5249
                colorUsed := self darkened.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5250
            ].
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5251
        ] ifFalse:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5252
            colorUsed := self slightlyLightened.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5253
            (bgBrightness dist:colorUsed brightness) < 0.5 ifTrue:[
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5254
                colorUsed := self lightened.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5255
            ].
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5256
        ].    
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5257
    ].
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5258
    ^ colorUsed.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5259
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5260
    "
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5261
     (Color blue) contrastingColorFor:Color white.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5262
     (Color blue) contrastingColorFor:Color blue.
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5263
     (Color red) contrastingColorFor:Color grey
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5264
     (Color blue) contrastingColorFor:Color black
78da2ec0985d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 7620
diff changeset
  5265
    "
7885
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5266
0144afcdce5a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7833
diff changeset
  5267
    "Modified (comment): / 13-02-2017 / 19:58:34 / cg"
5965
4f8e9e2ec50b class: Color
Stefan Vogel <sv@exept.de>
parents: 5957
diff changeset
  5268
!
4f8e9e2ec50b class: Color
Stefan Vogel <sv@exept.de>
parents: 5957
diff changeset
  5269
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5270
darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5271
    "return a new color, which is slightly darker than the receiver"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5272
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5273
    ^ self blendWith:Black
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5274
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
     (Color red) darkened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5277
     (Color red) darkened darkened
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5280
    "Modified: 11.6.1996 / 18:10:37 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5281
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5282
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5283
lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5284
    "return a new color, which is slightly lighter than the receiver"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5285
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5286
    ^ self blendWith:White
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5287
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5288
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5289
     (Color red) lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5290
     (Color red) lightened lightened
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5291
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5292
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5293
    "Modified: 11.6.1996 / 18:10:49 / cg"
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5294
!
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5295
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5296
mixed:amount with:aColor
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5297
    "create a new color from mixing amount of the receiver
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5298
     with the argument, aColor.
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5299
     Mixing is done by adding components (i.e. additive mixing)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5300
     (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
  5301
     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
  5302
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5303
    red isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5304
	^ aColor
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5305
    ].
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5306
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5307
    ^ (self class)
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5308
	scaledRed:((red * amount) + aColor scaledRed) // (1 + amount)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5309
	scaledGreen:((green * amount) + aColor scaledGreen) // (1 + amount)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5310
	scaledBlue:((blue * amount) + aColor scaledBlue) // (1 + amount)
2943
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5311
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5312
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5313
     (Color red) mixed:1 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5314
     (Color red) mixed:0.9 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5315
     (Color red) mixed:0.8 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5316
     (Color red) mixed:0.5 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5317
     (Color red) mixed:0.25 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5318
     (Color red) mixed:0 with:(Color yellow)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5319
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5320
     (Color red) mixed:1 with:(Color white)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5321
     (Color red) mixed:0.8 with:(Color white)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5322
     (Color red) mixed:0.8 with:(Color black)
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5323
    "
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5324
6b4dca5fbee2 more lightening/darkening stuff
Claus Gittinger <cg@exept.de>
parents: 2942
diff changeset
  5325
    "Modified: 10.2.1997 / 22:08:14 / cg"
3724
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5326
!
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5327
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5328
slightlyDarkened
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5329
    "return a new color, which is a bit darker than the receiver"
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5330
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5331
    ^ self blendWith:(self blendWith:Black)
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5332
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5333
    "
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5334
     (Color green) inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5335
     (Color green) darkened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5336
     (Color green) slightlyDarkened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5337
    "
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5338
!
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5339
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5340
slightlyLightened
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5341
    "return a new color, which is a bit lighter than the receiver"
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5342
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5343
    ^ self blendWith:(self blendWith:White)
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5344
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5345
    "
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5346
     (Color red) inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5347
     (Color red) lightened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5348
     (Color red) slightlyLightened inspect
e35133b39f25 + slightlyLightened/darkened
Claus Gittinger <cg@exept.de>
parents: 3665
diff changeset
  5349
    "
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5350
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5351
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5352
!Color methodsFor:'instance release'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5353
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5354
executor
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5355
    "redefined, since for finalization only device and colorIndex
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5356
     are needed - thus a faster copy is possible here"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5357
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5358
    ^ DeviceColorHandle basicNew setDevice:device colorId:colorId
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5359
!
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5360
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5361
releaseFromDevice
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5362
    "I am no longer available on the device"
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5363
2975
9ddc41c98ca6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2973
diff changeset
  5364
    colorId := device := ditherForm := replacementColor := nil.
2845
0794fef6db4a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2842
diff changeset
  5365
1023
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
3122
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5368
!Color methodsFor:'misc'!
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5369
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5370
magnifiedTo: extent
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5371
    "do nothing here, for compatibility with Image/Form"
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5372
! !
ecf190618501 AEG extensions removed
Claus Gittinger <cg@exept.de>
parents: 3039
diff changeset
  5373
6967
bd2a3899b4f9 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
  5374
4851
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5375
!Color methodsFor:'object persistency'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5376
4207
9e70f7998f66 elementDescriptorFor: instead of encodingVectorFor:
penk
parents: 4203
diff changeset
  5377
elementDescriptorFor:aspect
4851
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5378
    "support for persistency:
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5379
     answer the elements to be made persistent with an ObjectCoder"
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5380
3935
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5381
    red isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5382
	^ Array with:(#colorId->colorId)
3935
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5383
    ].
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5384
    ^ 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
  5385
! !
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5386
c0a32100d99e category change
Claus Gittinger <cg@exept.de>
parents: 4850
diff changeset
  5387
!Color methodsFor:'printing & storing'!
3935
c025aa0417cd encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3931
diff changeset
  5388
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5389
hex
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5390
    <resource: #obsolete>
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5391
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5392
    self obsoleteMethodWarning:'use #hexPrintString'.
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5393
    ^ self hexPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5394
!
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5395
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5396
hexPrintString
4908
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5397
    "return a hex-printString as rrggbb"
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5398
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5399
    |s|
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5400
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5401
    s := WriteStream on:(String new:6).
5920
6048353b1ba8 changed: #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 5779
diff changeset
  5402
    red isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5403
	colorId notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5404
	    colorId printOn:s base:16 size:6 fill:$0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5405
	]
5920
6048353b1ba8 changed: #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 5779
diff changeset
  5406
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5407
	self redByte   printOn:s base:16 size:2 fill:$0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5408
	self greenByte printOn:s base:16 size:2 fill:$0.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5409
	self blueByte  printOn:s base:16 size:2 fill:$0.
5920
6048353b1ba8 changed: #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 5779
diff changeset
  5410
    ].
4908
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5411
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5412
    ^ s contents.
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5413
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5414
    "
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5415
     Color red hexPrintString
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5416
     Color green hexPrintString
bb534a1fc0e3 #hexPrintString
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
  5417
     Color blue hexPrintString
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5418
     Color yellow hexPrintString
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5419
    "
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5420
!
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5421
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5422
htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5423
    "return a hex-printString for html as #rrggbb;"
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5424
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5425
    ^ '#',(self hexPrintString)
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5426
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5427
    "
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5428
     Color red htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5429
     Color green htmlPrintString
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5430
     Color blue htmlPrintString
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5431
     Color yellow htmlPrintString
4850
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5432
    "
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5433
!
5e45abdda305 hexPrintString; htmlPrintString
Claus Gittinger <cg@exept.de>
parents: 4789
diff changeset
  5434
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5435
printOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5436
    "append a string representing of the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5437
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5438
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5439
    self storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5440
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5441
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5442
storeOn:aStream
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5443
    "append a string representing an expression to reconstruct the receiver
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5444
     to the argument, aStream"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5445
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5446
    |clsName|
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5447
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5448
    clsName := self class name.
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5449
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5450
    red isNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5451
	colorId notNil ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5452
	    aStream nextPutAll:'(' , clsName , ' colorId:'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5453
	    colorId storeOn:aStream.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5454
	    aStream nextPut:$).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5455
	    ^ self
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5456
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5457
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5458
    (red == green and:[red == blue]) ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5459
	red == 0 ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5460
	    aStream nextPutAll:'(' , clsName , ' black)'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5461
	] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5462
	    red == MaxValue ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5463
		aStream nextPutAll:'(' , clsName , ' white)'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5464
	    ] ifFalse:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5465
		aStream nextPutAll:'(' , clsName , ' grey:'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5466
		(self red) storeOn:aStream.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5467
		aStream nextPut:$).
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5468
	    ]
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5469
	].
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5470
	^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5471
    ].
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5472
    aStream nextPutAll:'(' , clsName , ' red:'.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5473
    (self red) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5474
    aStream nextPutAll:' green:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5475
    (self green) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5476
    aStream nextPutAll:' blue:'.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5477
    (self blue) storeOn:aStream.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5478
    aStream nextPut:$).
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5479
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5480
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5481
!Color methodsFor:'private'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5482
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5483
restored
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5484
    "private: color has been restored (either from snapin or binary store);
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5485
     flush device stuff or reallocate a cell."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5486
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5487
    ditherForm := replacementColor := nil.
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5488
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5489
    red notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5490
	device := nil.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5491
	colorId := nil
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5492
    ] ifFalse:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5493
	"a variable color has been restored"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5494
	(colorId notNil and:[writable == true and:[device notNil]]) ifTrue:[
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5495
	    colorId := device colorCell.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5496
	    device setColor:colorId scaledRed:red scaledGreen:green scaledBlue:blue
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5497
	]
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5498
    ]
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5499
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5500
    "Modified: 17.1.1997 / 00:04:14 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5501
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5502
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5503
setColorId:anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5504
    "private: set the deviceId"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5505
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5506
    colorId := anId
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5507
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5508
    "Created: 17.1.1997 / 00:05:41 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5509
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5510
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5511
setDevice:aDevice colorId:aNumber
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5512
    "private:set device and colorId"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5513
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5514
    device := aDevice.
1934
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5515
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5516
    writable := false.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5517
!
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5518
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5519
setDevice:aDevice colorId:aNumber writable:wBool
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5520
    "private:set device, colorId and writable flag"
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5521
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5522
    device := aDevice.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5523
    colorId := aNumber.
fe7d73fe0df4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  5524
    writable := wBool.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5525
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5526
1238
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5527
setDitherForm:aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5528
    "private: set the ditherForm"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5529
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5530
    ditherForm := aForm
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5531
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5532
    "Created: 17.1.1997 / 00:04:57 / cg"
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5533
!
b363894182d0 prepare for replacement colors
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  5534
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5535
setScaledRed:r scaledGreen:g scaledBlue:b device:aDevice
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5536
    "private: set the components"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5537
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5538
    red notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5539
	"oops cannot change (you want to make red be green - or what)"
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5540
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5541
	self error:'Colors cannot change their components'.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5542
	^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5543
    ].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5544
    red := r.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5545
    green := g.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5546
    blue := b.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5547
    device := aDevice
1233
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5548
c6796bddc7d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
  5549
    "Modified: 16.1.1997 / 22:39:26 / cg"
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5550
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5551
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5552
!Color methodsFor:'queries'!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5553
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5554
averageColor
6793
4eb2c49db190 class: Color
Claus Gittinger <cg@exept.de>
parents: 6785
diff changeset
  5555
    "return the average color - that's myself.
4eb2c49db190 class: Color
Claus Gittinger <cg@exept.de>
parents: 6785
diff changeset
  5556
     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
  5557
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5558
    ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5559
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5560
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5561
averageColorIn:aRectangle
7580
1c51d1d76b32 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7569
diff changeset
  5562
    "return the average color - that's myself.
6793
4eb2c49db190 class: Color
Claus Gittinger <cg@exept.de>
parents: 6785
diff changeset
  5563
     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
  5564
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5565
    ^ self
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5566
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5567
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5568
brightness
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5569
    "ST80 compatibility: return the grey intensity in [0..1]"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5570
6384
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  5571
    red isNil ifTrue:[
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  5572
        "/ a hack for colorId:0 and colorId:1 pseudo mask colors.
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  5573
        colorId == 0 ifTrue:[^ 0].
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  5574
        ^ 1
b6ddf75e709e class: Color
Claus Gittinger <cg@exept.de>
parents: 6353
diff changeset
  5575
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5576
    ^ ((3 * red) + (6 * green) + (blue)) / 10.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5577
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5578
    "Modified: 7.6.1996 / 19:42:21 / cg"
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
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5581
deltaFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5582
    "return the distance of the receiver from some color specified
6785
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
  5583
     by r/g/b values.
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
  5584
     A very questionable value;
7411
9fdde791fac0 #DOCUMENTATION by mawalch
mawalch
parents: 7403
diff changeset
  5585
     basing the distance on rgb values is very bad
6785
7babceb91298 class: Color
Claus Gittinger <cg@exept.de>
parents: 6654
diff changeset
  5586
     - better do a distance in a cie color cone"
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
    ^ aColor deltaFromRed:self red green:self green blue:self blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5589
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5590
    "
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5591
     Color red deltaFrom:(Color blue)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5592
     Color red deltaFrom:(Color yellow)
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5593
     Color red deltaFrom:(Color red:50)
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5594
    "
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5595
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5596
    "Created: 14.6.1996 / 20:07:22 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5597
    "Modified: 14.6.1996 / 20:49:32 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5598
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5599
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5600
deltaFromRed:r green:g blue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5601
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5602
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5603
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5604
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5605
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5606
    "
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5607
    ^ ((self red - r) abs
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5608
      + (self green - g) abs
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5609
      + (self blue - b) abs) rounded.
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5610
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5611
    "Created: 14.6.1996 / 20:03:58 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5612
    "Modified: 14.6.1996 / 20:20:24 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5613
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5614
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5615
deltaFromScaledRed:r scaledGreen:g scaledBlue:b
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5616
    "return the distance of the receiver from some color specified
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5617
     by r/g/b values"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5618
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5619
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5620
     Q: how should component errors be weighted ?
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5621
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5622
    ^ (red - r) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5623
      + (green - g) abs
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5624
      + (blue - b) abs.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5625
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5626
    "Created: 11.6.1996 / 18:01:12 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5627
    "Modified: 14.6.1996 / 20:36:14 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5628
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5629
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5630
errorFrom:aColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5631
    "return some value which can be used to compare colors.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5632
     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
  5633
     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
  5634
     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
  5635
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5636
    ^ (red - aColor scaledRed) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5637
       + (green - aColor scaledGreen) squared
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5638
       + (blue - aColor scaledBlue) squared.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5639
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5640
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5641
grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5642
    "return the grey intensity in percent [0..100] (US version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5643
6385
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  5644
    red isNil ifTrue:[
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  5645
        "/ a hack for colorId:0 and colorId:1 pseudo mask colors.
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  5646
        colorId == 0 ifTrue:[^ 0].
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  5647
        ^ 100
463b0c40db9c class: Color
Claus Gittinger <cg@exept.de>
parents: 6384
diff changeset
  5648
    ].
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5649
    ^ ((3 * red) + (6 * green) + (1 * blue)) * 10.0 / MaxValue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5650
7758
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  5651
    "
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  5652
     Color red brightness
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  5653
     Color red grayIntensity
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  5654
    "
2e96180d15d8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7650
diff changeset
  5655
    
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5656
    "Created: 2.5.1996 / 11:38:21 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5657
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5658
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5659
greyIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5660
    "return the grey intensity in percent [0..100] (English version ;-)"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5661
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5662
    ^ self grayIntensity
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5663
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5664
    "Modified: 28.5.1996 / 20:45:41 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5665
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5666
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5667
isColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5668
    "return true if the receiver is a Color."
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5669
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5670
    ^ true
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5671
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5672
2828
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  5673
isColorObject
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  5674
    ^ true
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  5675
!
5795bf162314 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  5676
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5677
isDithered
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5678
    "return true, if this is a dithered Color.
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5679
     Only makes sense if the receiver is a device color."
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
    ^ ditherForm notNil
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5682
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5683
1326
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5684
isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5685
    "same as isGrayColor - for ST80 compatibility."
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5686
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5687
    ^ self isGrayColor
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5688
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5689
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5690
     (Color grey:50) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5691
     (Color red) isGray
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5692
    "
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5693
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5694
    "Created: 10.2.1997 / 22:10:25 / cg"
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5695
!
a519593747e8 #isGray - ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  5696
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5697
isGrayColor
3005
b8d9132ebbfd checkin from browser
Stefan Vogel <sv@exept.de>
parents: 2999
diff changeset
  5698
    "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
  5699
     i.e. red = green = blue"
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
    red ~~ green ifTrue:[^ false].
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5702
    ^ red == blue
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5703
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5704
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5705
     (Color grey:50) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5706
     (Color red) isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5707
    "
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5708
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5709
    "Created: 2.5.1996 / 11:38:48 / cg"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5710
!
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5711
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5712
isGreyColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5713
    "return true, if this color is a grey one (English version ;-) -
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5714
     i.e. red = green = blue"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5715
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5716
    ^ self isGrayColor
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5717
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5718
    "(Color grey:50) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5719
    "(Color red) isGreyColor"
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5720
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5721
    "Modified: 28.5.1996 / 20:44:36 / cg"
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5722
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5723
3598
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5724
isOnDevice:aGraphicsDevice
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5725
    "return true if i am allocated on aGraphicsDevice"
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5726
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5727
    ^ device == aGraphicsDevice
3598
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5728
      and:[colorId notNil or:[replacementColor notNil and:[replacementColor colorId notNil]]]
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5729
!
2b6e50a38de6 New: #isOnDevice:
Stefan Vogel <sv@exept.de>
parents: 3543
diff changeset
  5730
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5731
isOpaque
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5732
    "return true, if I represent an opaque color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5733
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5734
    ^ true
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5735
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5736
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5737
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5738
isTranslucent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5739
    "return true, if I represent a translucent color;
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5740
     that is: not completely opaque"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5741
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5742
    ^ false
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5743
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5744
!
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5745
2945
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5746
isTranslucentColor
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5747
    "return true, if I represent a translucent color, but not transparent"
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5748
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5749
    ^ false
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5750
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5751
!
937fdf02965d more compatibility stuff
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
  5752
2942
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5753
isTransparent
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5754
    "return true, if I represent a completely transparent color"
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5755
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5756
    ^ false
513981eb5180 prepared support for translucent colors
Claus Gittinger <cg@exept.de>
parents: 2937
diff changeset
  5757
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5758
! !
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5759
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5760
!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
  5761
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5762
documentation
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5763
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5764
    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
  5765
    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
  5766
    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
  5767
    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
  5768
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5769
    [see also:]
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5770
	Color
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5771
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5772
    [author:]
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5773
	Claus Gittinger
1907
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5774
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5775
"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5776
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5777
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5778
!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
  5779
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5780
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
  5781
    "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
  5782
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5783
    device := aDevice.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5784
    colorId := anId.
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5785
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5786
    "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
  5787
    "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
  5788
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5789
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5790
!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
  5791
3611
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3598
diff changeset
  5792
finalize
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5793
    "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
  5794
     - release system resources"
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5795
2096
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5796
    |id|
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5797
f3f0d358239f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2087
diff changeset
  5798
    (id := colorId) notNil ifTrue:[
6353
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5799
	colorId := nil.
757f173c4d2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6206
diff changeset
  5800
	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
  5801
    ].
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5802
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5803
    "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
  5804
! !
61fdff318175 Make Device*Handles (used for finalization) private in their resp. classes.
Stefan Vogel <sv@exept.de>
parents: 1859
diff changeset
  5805
1144
07f3de59864d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  5806
!Color class methodsFor:'documentation'!
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5807
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5808
version
6967
bd2a3899b4f9 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
  5809
    ^ '$Header$'
5419
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  5810
!
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  5811
7718ae7f7e6b added: #greyByte:
Claus Gittinger <cg@exept.de>
parents: 5337
diff changeset
  5812
version_CVS
6967
bd2a3899b4f9 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
  5813
    ^ '$Header$'
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5814
! !
3757
d6b9e17dcc45 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 3727
diff changeset
  5815
6110
28bccabea00a class: Color
Claus Gittinger <cg@exept.de>
parents: 5965
diff changeset
  5816
1023
ddbc71885249 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
  5817
Color initialize!