Colormap.st
author Claus Gittinger <cg@exept.de>
Tue, 23 Apr 1996 22:16:35 +0200
changeset 603 7e2b1e471427
parent 602 f4827cf7d3f9
child 611 e0442439a3c6
permissions -rw-r--r--
commentary
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     1
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     3
	      All Rights Reserved
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     4
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    11
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    12
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    13
SequenceableCollection subclass:#Colormap
572
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    14
	instanceVariableNames:'redVector greenVector blueVector'
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    15
	classVariableNames:''
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    16
	poolDictionaries:''
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    17
	category:'Graphics-Images support'
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    18
!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    19
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    20
!Colormap class methodsFor:'documentation'!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    21
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    22
copyright
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    23
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    25
	      All Rights Reserved
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    26
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    27
 This software is furnished under a license and may be used
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    32
 hereby transferred.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    33
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    34
!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    35
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    36
documentation
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    37
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    38
    Colormaps are used with images (and Forms) to keep the byte-to-color
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    39
    mapping.
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    40
    Externally, either colors or pixel values can be accessed.
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    41
    Internally, the values are stored as 3 separate byte-arrays
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    42
    (i.e. individual components can be 0..255).
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    43
    This was done to avoid overhead due to allocation of many color
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    44
    instances.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    45
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    46
    [see also:]
603
7e2b1e471427 commentary
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
    47
        Color Image Form
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    48
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    49
! !
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    50
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    51
!Colormap class methodsFor:'instance creation'!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    52
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    53
fromColors:aColorArray
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    54
    "given a collection of real colors, return a new instance
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    55
     of myself"
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    56
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    57
    |n rV gV bV|
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    58
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    59
    n := aColorArray size.
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    60
    rV := ByteArray new:n.
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    61
    gV := ByteArray new:n.
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    62
    bV := ByteArray new:n.
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    63
    1 to:n do:[:i |
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    64
        |clr|
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    65
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    66
        clr := aColorArray at:i.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    67
        rV at:i put:(clr red * 255 / 100) rounded.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    68
        bV at:i put:(clr green * 255 / 100) rounded.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    69
        gV at:i put:(clr blue * 255 / 100) rounded.
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    70
    ].
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    71
    ^ self new redVector:rV greenVector:gV blueVector:bV
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    72
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    73
    "
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    74
     Colormap 
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    75
        fromColors:(Array with:Color black
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    76
                          with:Color red
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    77
                          with:Color white)
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    78
    "
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    79
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    80
    "Modified: 23.4.1996 / 22:15:22 / cg"
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    81
!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    82
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    83
redVector:r greenVector:g blueVector:b
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    84
    "given vectors of red/green/and blue pixelValues,
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    85
     return a new instance of myself.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    86
     The values must be in the range 0..255."
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    87
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    88
    ^ self new redVector:r greenVector:g blueVector:b
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    89
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    90
    "
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    91
     Colormap 
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    92
        redVector:#[0 127 255]
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    93
        greenVector:#[0 127 255]
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    94
        blueVector:#[0 127 255]
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    95
    "
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    96
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    97
    "Modified: 23.4.1996 / 22:16:00 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    98
! !
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    99
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   100
!Colormap methodsFor:'accessing'!
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   101
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   102
at:index 
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   103
    "return the color at index - notice, that index is a typically derived
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   104
     from an images pixel value which ranges 0..255; while the index here
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   105
     starts at 1 (to make colormap look more like a collection)."
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   106
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   107
    |r g b|
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   108
    r := redVector at:index.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   109
    g := greenVector at:index.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   110
    b := blueVector at:index.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   111
    ^ Color
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   112
	red:(r * 100 / 255)
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   113
	green:(g * 100 / 255)
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   114
	blue:(b * 100 / 255)
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   115
!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   116
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   117
at:index put:aColor
572
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   118
    "set the color at index to aColor. Return aColor (sigh).
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   119
     - notice, that a color index is a typically derived
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   120
       from an images pixel value which ranges 0..255; 
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   121
       while the index here starts at 1 
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   122
       (to make colormap look more like a collection).
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   123
       Therefore, to modify a colorMap entry for pixel i, change
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   124
       the colorMaps slot at i+1."
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   125
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   126
    |r g b|
572
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   127
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   128
    r := (aColor red * 255 / 100) rounded.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   129
    g := (aColor green * 255 / 100) rounded.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   130
    b := (aColor blue * 255 / 100) rounded.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   131
    redVector at:index put:r.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   132
    greenVector at:index put:g.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   133
    blueVector at:index put:b.
572
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   134
    ^ aColor
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   135
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   136
    "Modified: 19.4.1996 / 11:19:04 / cg"
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
   137
!
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   138
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   139
blueAt:index
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   140
    "return the blue component at some index.
153
claus
parents: 118
diff changeset
   141
     The returned value is scaled from the internal 0.. 255 to
claus
parents: 118
diff changeset
   142
     a percentage value 0..100"
claus
parents: 118
diff changeset
   143
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   144
    ^ (blueVector at:index) * 100 / 255
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   145
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   146
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   147
blueVector
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   148
    "return blueVector"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   149
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   150
    ^ blueVector
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   151
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   152
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   153
blueVector:something
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   154
    "set blueVector"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   155
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   156
    blueVector := something.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   157
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   158
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   159
colors
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   160
    "ST-80 compatibility: return a collection containing the colors I hold"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   161
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   162
    ^ self asArray
153
claus
parents: 118
diff changeset
   163
!
claus
parents: 118
diff changeset
   164
claus
parents: 118
diff changeset
   165
greenAt:index
claus
parents: 118
diff changeset
   166
    "return the green component at some index.
claus
parents: 118
diff changeset
   167
     The returned value is scaled from the internal 0.. 255 to
claus
parents: 118
diff changeset
   168
     a percentage value 0..100"
claus
parents: 118
diff changeset
   169
claus
parents: 118
diff changeset
   170
    ^ (greenVector at:index) * 100 / 255
claus
parents: 118
diff changeset
   171
!
claus
parents: 118
diff changeset
   172
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   173
greenVector
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   174
    "return greenVector"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   175
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   176
    ^ greenVector
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   177
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   178
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   179
greenVector:something
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   180
    "set greenVector"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   181
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   182
    greenVector := something.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   183
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   184
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   185
redAt:index
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   186
    "return the red component at some index.
153
claus
parents: 118
diff changeset
   187
     The returned value is scaled from the internal 0.. 255 to
claus
parents: 118
diff changeset
   188
     a percentage value 0..100"
claus
parents: 118
diff changeset
   189
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   190
    ^ (redVector at:index) * 100 / 255
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   191
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   192
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   193
redVector
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   194
    "return redVector"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   195
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   196
    ^ redVector
153
claus
parents: 118
diff changeset
   197
!
claus
parents: 118
diff changeset
   198
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   199
redVector:something
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   200
    "set redVector"
153
claus
parents: 118
diff changeset
   201
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   202
    redVector := something.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   203
!
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   204
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   205
redVector:r greenVector:g blueVector:b
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   206
    "set the red, green and blueVectors"
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   207
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   208
    redVector := r.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   209
    greenVector := g.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   210
    blueVector := b.
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   211
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   212
    "Modified: 23.4.1996 / 22:13:31 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   213
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   214
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   215
size
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   216
    "return the number of colors in the receiver"
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   217
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   218
    ^ redVector size
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   219
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   220
    "Modified: 23.4.1996 / 22:13:43 / cg"
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   221
! !
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   222
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   223
!Colormap methodsFor:'misc'!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   224
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   225
scaleValuesBy:scaleFactor
153
claus
parents: 118
diff changeset
   226
   "multiply all values by scaleFactor; finally round to integer.
claus
parents: 118
diff changeset
   227
    This can be used to brighten/darken an images colormap"
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   228
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   229
   1 to:redVector size do:[:index |
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   230
	redVector at:index put:((redVector at:index) * scaleFactor) rounded.
153
claus
parents: 118
diff changeset
   231
	greenVector at:index put:((greenVector at:index) * scaleFactor) rounded.
claus
parents: 118
diff changeset
   232
	blueVector at:index put:((blueVector at:index) * scaleFactor) rounded.
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   233
   ]
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   234
! !
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   235
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   236
!Colormap class methodsFor:'documentation'!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   237
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   238
version
603
7e2b1e471427 commentary
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   239
    ^ '$Header: /cvs/stx/stx/libview/Colormap.st,v 1.8 1996-04-23 20:16:35 cg Exp $'
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   240
! !