equal
deleted
inserted
replaced
602 |
602 |
603 "Modified: 17.1.1997 / 00:05:36 / cg" |
603 "Modified: 17.1.1997 / 00:05:36 / cg" |
604 ! |
604 ! |
605 |
605 |
606 bgrValue:bgr |
606 bgrValue:bgr |
607 "return a color from a 24bit bgr value; |
607 "return a color from a 24bit BGR value (intentionally not RGB); |
608 The value is composed of b<<16 + g<<8 + r. |
608 The value is composed of b<<16 + g<<8 + r. |
609 (this byte-order is sometimes encountered with windows systems (progs)" |
609 (this byte-order is sometimes encountered with windows systems (progs)" |
610 |
610 |
611 |r g b| |
611 |r g b| |
612 |
612 |
619 |
619 |
620 blue: blue |
620 blue: blue |
621 "return a color from blue value; |
621 "return a color from blue value; |
622 the argument green is interpreted as percent (0..100)" |
622 the argument green is interpreted as percent (0..100)" |
623 |
623 |
624 ^here scaledRed: 0 |
624 ^ here |
625 scaledGreen: 0 |
625 scaledRed:0 scaledGreen:0 scaledBlue:(blue * MaxValue // 100) |
626 scaledBlue: (blue * MaxValue // 100) |
626 |
|
627 " |
|
628 (Color blue:50) inspect |
|
629 " |
|
630 |
627 ! |
631 ! |
628 |
632 |
629 brightness:brightness |
633 brightness:brightness |
630 "create a gray color with given brightness (0..1). |
634 "create a gray color with given brightness (0..1). |
631 ST-80 compatibility." |
635 ST-80 compatibility." |
702 ^ self redPercent:r greenPercent:g bluePercent:b |
706 ^ self redPercent:r greenPercent:g bluePercent:b |
703 |
707 |
704 " |
708 " |
705 Color cyan:100 magenta:0 yellow:0 black:0 - cyan |
709 Color cyan:100 magenta:0 yellow:0 black:0 - cyan |
706 Color cyan:100 magenta:0 yellow:0 black:50 - cyan darkened |
710 Color cyan:100 magenta:0 yellow:0 black:50 - cyan darkened |
707 Color cyan:100 magenta:50 yellow:50 black:0 - cyan darkened |
711 Color cyan:100 magenta:50 yellow:50 black:0 - cyan darkened |
708 Color cyan:0 magenta:0 yellow:0 black:100 - black |
712 Color cyan:0 magenta:0 yellow:0 black:100 - black |
709 " |
713 " |
710 |
714 |
711 "Modified: 11.6.1996 / 18:29:15 / cg" |
715 "Modified: 11.6.1996 / 18:29:15 / cg" |
712 ! |
716 ! |
751 newColor setDitherForm:form. |
755 newColor setDitherForm:form. |
752 newColor setDevice:aDevice colorId:nil. |
756 newColor setDevice:aDevice colorId:nil. |
753 ^ newColor |
757 ^ newColor |
754 |
758 |
755 " |
759 " |
756 |c| |
760 (Color dither:0.25 between:Color red and:Color yellow on:Display) inspect |
757 |
761 (Color dither:0.5 between:Color red and:Color yellow on:Display) inspect |
758 c := Color dither:0.5 between:Color red and:Color yellow on:Display. |
762 (Color dither:0.75 between:Color red and:Color yellow on:Display) inspect |
759 c inspect. |
|
760 " |
763 " |
761 |
764 |
762 "Created: 3.5.1997 / 10:54:32 / cg" |
765 "Created: 3.5.1997 / 10:54:32 / cg" |
763 "Modified: 3.5.1997 / 11:10:51 / cg" |
766 "Modified: 3.5.1997 / 11:10:51 / cg" |
764 ! |
767 ! |
844 |
847 |
845 "Modified: / 31.8.1995 / 01:34:22 / claus" |
848 "Modified: / 31.8.1995 / 01:34:22 / claus" |
846 "Modified: / 9.1.1998 / 20:48:58 / stefan" |
849 "Modified: / 9.1.1998 / 20:48:58 / stefan" |
847 ! |
850 ! |
848 |
851 |
849 green: green |
852 green:green |
850 "return a color from green value; |
853 "return a color from green value; |
851 the argument green is interpreted as percent (0..100)" |
854 the argument green is interpreted as percent (0..100)" |
852 |
855 |
853 ^here scaledRed: 0 |
856 ^ here |
854 scaledGreen: (green * MaxValue // 100) |
857 scaledRed:0 scaledGreen:(green * MaxValue // 100) scaledBlue:0 |
855 scaledBlue: 0 |
858 |
|
859 " |
|
860 (Color green:50) inspect |
|
861 " |
|
862 |
856 ! |
863 ! |
857 |
864 |
858 hue:h light:l saturation:s |
865 hue:h light:l saturation:s |
859 "return a color from hue, light and saturation values. |
866 "return a color from hue, light and saturation values. |
860 Hue is in degrees (0..360); light and sturation are |
867 Hue is in degrees (0..360); light and sturation are |
882 Report an error, if aString is not a valid color name. |
889 Report an error, if aString is not a valid color name. |
883 |
890 |
884 We hereby only guarantee that the 8 basic colors are supported |
891 We hereby only guarantee that the 8 basic colors are supported |
885 on every device (X uses the Xcolor database, so it supports more |
892 on every device (X uses the Xcolor database, so it supports more |
886 names - other devices use a builtIn name table containing only the |
893 names - other devices use a builtIn name table containing only the |
887 common names) - use with special names (such as 'mediumGoldenRod' |
894 common names) |
888 is not recommended). Better use: #name:ifIllegal: and provide a fallBack." |
895 - use with special names (such as 'mediumGoldenRod' is not recommended). |
|
896 Better use: #name:ifIllegal: and provide a fallBack." |
889 |
897 |
890 ^ self |
898 ^ self |
891 name:colorName |
899 name:colorName |
892 ifIllegal:[InvalidColorNameSignal |
900 ifIllegal:[InvalidColorNameSignal |
893 raiseRequestWith:colorName |
901 raiseRequestWith:colorName |
950 ^ Pseudo0 |
958 ^ Pseudo0 |
951 |
959 |
952 "Modified: 17.1.1997 / 00:06:49 / cg" |
960 "Modified: 17.1.1997 / 00:06:49 / cg" |
953 ! |
961 ! |
954 |
962 |
955 red: red |
963 red:red |
956 "return a color from red value; |
964 "return a color from red value; |
957 the argument r is interpreted as percent (0..100)" |
965 the argument r is interpreted as percent (0..100)" |
958 |
966 |
959 ^here scaledRed: (red * MaxValue // 100) |
967 ^ here |
960 scaledGreen: 0 |
968 scaledRed:(red * MaxValue // 100) scaledGreen:0 scaledBlue:0 |
961 scaledBlue: 0 |
969 |
|
970 " |
|
971 (Color red:50) inspect |
|
972 " |
962 ! |
973 ! |
963 |
974 |
964 red:r green:g blue:b |
975 red:r green:g blue:b |
965 "return a color from red, green and blue values; |
976 "return a color from red, green and blue values; |
966 the arguments, r, g and b are interpreted as percent (0..100)" |
977 the arguments, r, g and b are interpreted as percent (0..100)" |
995 scaledGreen:(g * MaxValue // 100) |
1006 scaledGreen:(g * MaxValue // 100) |
996 scaledBlue:(b * MaxValue // 100) |
1007 scaledBlue:(b * MaxValue // 100) |
997 ! |
1008 ! |
998 |
1009 |
999 rgbValue:rgb |
1010 rgbValue:rgb |
1000 "return a color from a 24bit rgb value; |
1011 "return a color from a 24bit RGB value; |
1001 The value is composed of r<<16 + g<<8 + b." |
1012 The value is composed of r<<16 + g<<8 + b." |
1002 |
1013 |
1003 |r g b| |
1014 |r g b| |
1004 |
1015 |
1005 r := (rgb bitShift:-16) bitAnd:16rFF. |
1016 r := (rgb bitShift:-16) bitAnd:16rFF. |
4770 "return the distance of the receiver from some color specified |
4781 "return the distance of the receiver from some color specified |
4771 by r/g/b values" |
4782 by r/g/b values" |
4772 |
4783 |
4773 ^ aColor deltaFromRed:self red green:self green blue:self blue |
4784 ^ aColor deltaFromRed:self red green:self green blue:self blue |
4774 |
4785 |
|
4786 " |
|
4787 Color red deltaFrom:(Color blue) |
|
4788 Color red deltaFrom:(Color yellow) |
|
4789 Color red deltaFrom:(Color red:50) |
|
4790 " |
|
4791 |
4775 "Created: 14.6.1996 / 20:07:22 / cg" |
4792 "Created: 14.6.1996 / 20:07:22 / cg" |
4776 "Modified: 14.6.1996 / 20:49:32 / cg" |
4793 "Modified: 14.6.1996 / 20:49:32 / cg" |
4777 ! |
4794 ! |
4778 |
4795 |
4779 deltaFromRed:r green:g blue:b |
4796 deltaFromRed:r green:g blue:b |
4781 by r/g/b values" |
4798 by r/g/b values" |
4782 |
4799 |
4783 " |
4800 " |
4784 Q: how should component errors be weighted ? |
4801 Q: how should component errors be weighted ? |
4785 " |
4802 " |
4786 ^ (self red - r) abs |
4803 ^ ((self red - r) abs |
4787 + (self green - g) abs |
4804 + (self green - g) abs |
4788 + (self blue - b) abs. |
4805 + (self blue - b) abs) rounded. |
4789 |
4806 |
4790 "Created: 14.6.1996 / 20:03:58 / cg" |
4807 "Created: 14.6.1996 / 20:03:58 / cg" |
4791 "Modified: 14.6.1996 / 20:20:24 / cg" |
4808 "Modified: 14.6.1996 / 20:20:24 / cg" |
4792 ! |
4809 ! |
4793 |
4810 |
4862 |
4879 |
4863 "Created: 10.2.1997 / 22:10:25 / cg" |
4880 "Created: 10.2.1997 / 22:10:25 / cg" |
4864 ! |
4881 ! |
4865 |
4882 |
4866 isGrayColor |
4883 isGrayColor |
4867 "return true, if this color is a gray one - |
4884 "return true, if this color is a gray one (US version ;-) - |
4868 i.e. red = green = blue" |
4885 i.e. red = green = blue" |
4869 |
4886 |
4870 red ~~ green ifTrue:[^ false]. |
4887 red ~~ green ifTrue:[^ false]. |
4871 ^ red == blue |
4888 ^ red == blue |
4872 |
4889 |
4966 ! ! |
4983 ! ! |
4967 |
4984 |
4968 !Color class methodsFor:'documentation'! |
4985 !Color class methodsFor:'documentation'! |
4969 |
4986 |
4970 version |
4987 version |
4971 ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.148 1999-10-27 13:32:05 stefan Exp $' |
4988 ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.149 1999-10-28 07:25:25 stefan Exp $' |
4972 ! ! |
4989 ! ! |
4973 Color initialize! |
4990 Color initialize! |