コード例 #1
0
        public (ImmutableArray <string>, RGBColor) Parse(IReadOnlyList <string> inputs)
        {
            var texts = inputs.Align(4, "0").Select(s => s.RemoveNonDigits()).ToImmutableArray();
            int c = Math.Clamp(texts[0].ParseInt(), 0, 255), m = Math.Clamp(texts[1].ParseInt(), 0, 255), y = Math.Clamp(texts[2].ParseInt(), 0, 255), light = Math.Clamp(255 - texts[3].ParseInt(), 0, 255);

            return(texts, new RGBColor((255 - c) * light / 255, (255 - m) * light / 255, (255 - y) * light / 255));
        }
コード例 #2
0
ファイル: HSLColorModel.cs プロジェクト: RichardBlazek/SIMSA
        public (ImmutableArray <string>, RGBColor) Parse(IReadOnlyList <string> inputs)
        {
            var texts = inputs.Align(3, "0").Select(s => s.RemoveNonDigits()).ToImmutableArray();
            int h = Math.Clamp(texts[0].ParseInt(), 0, 360) % 360, s = Math.Clamp(texts[1].ParseInt(), 0, 255), l = Math.Clamp(texts[2].ParseInt(), 0, 255);
            int chroma = s * (255 - Math.Abs(2 * l - 255)) / 255;

            return(texts, ColorCalculations.RGBColor(chroma, h, l - chroma / 2));
        }
コード例 #3
0
ファイル: RGBColorModel.cs プロジェクト: RichardBlazek/SIMSA
        public (ImmutableArray <string>, RGBColor) Parse(IReadOnlyList <string> inputs)
        {
            var texts = inputs.Align(3, "0").Select(s => s.RemoveNonDigits()).ToImmutableArray();

            return(texts, new RGBColor(Math.Clamp(texts[0].ParseInt(), 0, 255), Math.Clamp(texts[1].ParseInt(), 0, 255), Math.Clamp(texts[2].ParseInt(), 0, 255)));
        }