ImageEditor.st
changeset 1611 2f23751929d6
parent 1603 fda6d834bb40
child 1613 1d4f11252d3b
equal deleted inserted replaced
1610:cb3e093aa6d5 1611:2f23751929d6
  2200 
  2200 
  2201 ! !
  2201 ! !
  2202 
  2202 
  2203 !ImageEditor methodsFor:'data access'!
  2203 !ImageEditor methodsFor:'data access'!
  2204 
  2204 
       
  2205 atColor:aOldColor put:aNewColor
       
  2206     "a color changed to a new color
       
  2207     "
       
  2208     |index list|
       
  2209 
       
  2210     list  := self listOfColors.
       
  2211     index := list identityIndexOf:aOldColor.
       
  2212 
       
  2213     index ~~ 0 ifTrue:[
       
  2214         list at:index put:aNewColor
       
  2215     ] ifFalse:[
       
  2216         self halt:'should not happen'.
       
  2217         list add:aNewColor
       
  2218     ].
       
  2219 !
       
  2220 
  2205 blueAtColor:aColor put:newBlue
  2221 blueAtColor:aColor put:newBlue
  2206     "helper used to return a new row element, when blue is changed"
  2222     "helper used to return a new row element, when blue is changed"
  2207 
  2223 
  2208     |byte|
  2224     |byte|
  2209 
  2225 
  2210     aColor isNil ifTrue:[^ aColor].  "/ mask cannot be changed
  2226     aColor isNil ifTrue:[^ self].       "/ mask cannot be changed
  2211     byte := newBlue clampBetween:0 and:255.
  2227     byte := newBlue clampBetween:0 and:255.
  2212     byte = aColor blueByte ifTrue:[^ aColor].
  2228     byte = aColor blueByte ifTrue:[^ self ].
  2213     ^ Color redByte:(aColor redByte) greenByte:(aColor greenByte) blueByte:byte
  2229 
  2214 
  2230     self atColor:aColor
  2215     "Modified: / 18.8.1998 / 17:00:12 / cg"
  2231              put:(Color redByte:(aColor redByte) greenByte:(aColor greenByte) blueByte:byte).
  2216 !
  2232 !
  2217 
  2233 
  2218 blueFromColor:aColor
  2234 blueFromColor:aColor
  2219     "helper used to access a color as a row in the dataSet view"
  2235     "helper used to access a color as a row in the dataSet view"
  2220 
  2236 
  2249 greenAtColor:aColor put:newGreen
  2265 greenAtColor:aColor put:newGreen
  2250     "helper used to return a new row element, when green is changed"
  2266     "helper used to return a new row element, when green is changed"
  2251 
  2267 
  2252     |byte|
  2268     |byte|
  2253 
  2269 
  2254     aColor isNil ifTrue:[^ aColor].  "/ mask cannot be changed
  2270     aColor isNil ifTrue:[^ self].       "/ mask cannot be changed
  2255     byte := newGreen clampBetween:0 and:255.
  2271     byte := newGreen clampBetween:0 and:255.
  2256     byte = aColor greenByte ifTrue:[^ aColor].
  2272     byte = aColor greenByte ifTrue:[^ self].
  2257     ^ Color redByte:(aColor redByte) greenByte:byte blueByte:(aColor blueByte)
  2273 
  2258 
  2274     self atColor:aColor
  2259     "Modified: / 18.8.1998 / 17:00:38 / cg"
  2275              put:(Color redByte:(aColor redByte) greenByte:byte blueByte:(aColor blueByte)).
  2260 !
  2276 !
  2261 
  2277 
  2262 greenFromColor:aColor
  2278 greenFromColor:aColor
  2263     "helper used to access a color as a row in the dataSet view"
  2279     "helper used to access a color as a row in the dataSet view"
  2264 
  2280 
  2272 redAtColor:aColor put:newRed
  2288 redAtColor:aColor put:newRed
  2273     "helper used to return a new row element, when red is changed"
  2289     "helper used to return a new row element, when red is changed"
  2274 
  2290 
  2275     |byte|
  2291     |byte|
  2276 
  2292 
  2277     aColor isNil ifTrue:[^ aColor].  "/ mask cannot be changed
  2293     aColor isNil ifTrue:[^ self].       "/ mask cannot be changed
  2278     byte := newRed clampBetween:0 and:255.
  2294     byte := newRed clampBetween:0 and:255.
  2279     byte = aColor redByte ifTrue:[^ aColor].
  2295     byte = aColor redByte ifTrue:[^ self].
  2280     ^ Color redByte:byte greenByte:(aColor greenByte) blueByte:(aColor blueByte)
  2296 
  2281 
  2297     self atColor:aColor
  2282     "Modified: / 18.8.1998 / 17:00:49 / cg"
  2298              put:(Color redByte:byte greenByte:(aColor greenByte) blueByte:(aColor blueByte)).
  2283 !
  2299 !
  2284 
  2300 
  2285 redFromColor:aColor
  2301 redFromColor:aColor
  2286     "helper used to access a color as a row in the dataSet view"
  2302     "helper used to access a color as a row in the dataSet view"
  2287 
  2303