ColorValue.st
author Claus Gittinger <cg@exept.de>
Wed, 12 Jun 1996 14:17:14 +0200
changeset 300 97f6b30e8a50
parent 277 7833361c76a2
child 301 9d63572bb1e2
permissions -rw-r--r--
Color changed to use integer r/g/b components internally (0..16rFFFF)

"
 COPYRIGHT (c) 1995 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

Color subclass:#ColorValue
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Graphics-Support'
!

!ColorValue class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1995 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    ColorValue is provided for ST-80 compatibility.
    read the section on compatibility issues in the Color class's documentation.

    [author:]
        Claus Gittinger
"
! !

!ColorValue class methodsFor:'instance creation'!

brightness:grey
    "return a grey color.
     The grey value is given in 0..1 instead of percent"

    ^ self scaledGray:(grey * MaxValue) rounded

    "
     ColorValue brightness:0.5
    "

    "Modified: 28.5.1996 / 20:53:52 / cg"
!

doesNotUnderstand:aMessage
    "catch other instance creation messages"

    |clr|

    (clr := self name:aMessage selector asString) notNil ifTrue:[
	^ clr
    ].
    ^ super doesNotUnderstand:aMessage

    "
     ColorValue royalBlue
     ColorValue funnyGreen
    "
!

hue:hue saturation:sat brightness:light 
    "return a color.
     The hue, saturation and brightness values are given in 0..1 instead of 
     degrees / percent"

    ^ self hue:hue*360 light:light*100 saturation:sat*100 

    "
     ColorValue hue:0 saturation:1 brightness:0.5 
    "
!

red:r green:g blue:b
    "return a color from red, green and blue values.
     The arguments, r, g and b must be in the range (0..1)"

    ^ self 
	scaledRed:(r * MaxValue) rounded
	scaledGreen:(g * MaxValue) rounded
        scaledBlue:(b * MaxValue) rounded

    "
     ColorValue red:0 green:1 blue:0
     ColorValue red:0 green:0.5 blue:0
    "
! !

!ColorValue methodsFor:'accessing'!

red
    "return the red component in 0..1"

    ^ red / MaxValue
!

green
    "return the green component in 0..1"

    ^ green / MaxValue
!

blue
    "return the blue component in 0..1"

    ^ blue / MaxValue
! !

!ColorValue class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/ColorValue.st,v 1.11 1996-06-12 12:17:14 cg Exp $'
! !