Color.st
changeset 2778 3ef64f104266
parent 2455 9d61d6c0d0f9
child 2779 d04cef21e0b6
equal deleted inserted replaced
2777:60ba83db1fab 2778:3ef64f104266
  3737 
  3737 
  3738 !Color methodsFor:'converting'!
  3738 !Color methodsFor:'converting'!
  3739 
  3739 
  3740 fromLiteralArrayEncoding:encoding
  3740 fromLiteralArrayEncoding:encoding
  3741     "read my values from an encoding.
  3741     "read my values from an encoding.
  3742      The encoding is supposed to be of the form: 
  3742      The encoding is supposed to be either of the form: 
  3743         (#Color redPart greenPart bluePart)
  3743         (#Color redPart greenPart bluePart)
       
  3744      or:
       
  3745         (#Color constantColorSymbol)
  3744      This is the reverse operation to #literalArrayEncoding."
  3746      This is the reverse operation to #literalArrayEncoding."
  3745 
  3747 
  3746     red := ((encoding at:2) / 100.0 * MaxValue) rounded.
  3748     |clr|
  3747     green := ((encoding at:3) / 100.0 * MaxValue) rounded.
  3749 
  3748     blue := ((encoding at:4) / 100.0 * MaxValue) rounded.
  3750     encoding size == 2 ifTrue:[
       
  3751         clr := Color perform:(encoding at:2).
       
  3752         red := clr red.
       
  3753         green := clr green.
       
  3754         blue := clr blue
       
  3755     ] ifFalse:[
       
  3756         red := ((encoding at:2) / 100.0 * MaxValue) rounded.
       
  3757         green := ((encoding at:3) / 100.0 * MaxValue) rounded.
       
  3758         blue := ((encoding at:4) / 100.0 * MaxValue) rounded.
       
  3759     ].
  3749 
  3760 
  3750     "
  3761     "
  3751       Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
  3762       Color new fromLiteralArrayEncoding:#(#Color 50 25 25)
  3752     "
  3763     "
  3753 !
  3764 !
  4608 ! !
  4619 ! !
  4609 
  4620 
  4610 !Color class methodsFor:'documentation'!
  4621 !Color class methodsFor:'documentation'!
  4611 
  4622 
  4612 version
  4623 version
  4613     ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.124 1999-02-15 23:20:15 cg Exp $'
  4624     ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.125 1999-06-25 15:51:41 cg Exp $'
  4614 ! !
  4625 ! !
  4615 Color initialize!
  4626 Color initialize!