Пример #1
0
 public RGBA_Doubles(RGBA_Doubles c, double a_)
 {
     m_r = c.m_r;
     m_g = c.m_g;
     m_b = c.m_b;
     m_a = a_;
 }
Пример #2
0
 //--------------------------------------------------------------------
 public RGBA_Doubles(RGBA_Doubles c)
     : this(c, 1)
 {
 }
Пример #3
0
 public RGBA_Bytes(RGBA_Doubles c)
 {
     m_R = ((byte)agg_basics.uround(c.m_r * (double)base_mask));
     m_G = ((byte)agg_basics.uround(c.m_g * (double)base_mask));
     m_B = ((byte)agg_basics.uround(c.m_b * (double)base_mask));
     m_A = ((byte)agg_basics.uround(c.m_a * (double)base_mask));
 }
Пример #4
0
        public static RGBA_Doubles GetTweenColor(RGBA_Doubles Color1, RGBA_Doubles Color2, double RatioOf2)
        {
            if (RatioOf2 <= 0)
            {
                return new RGBA_Doubles(Color1);
            }

            if (RatioOf2 >= 1.0)
            {
                return new RGBA_Doubles(Color2);
            }

            // figure out how much of each color we should be.
            double RatioOf1 = 1.0 - RatioOf2;
            return new RGBA_Doubles(
                Color1.m_r * RatioOf1 + Color2.m_r * RatioOf2,
                Color1.m_g * RatioOf1 + Color2.m_g * RatioOf2,
                Color1.m_b * RatioOf1 + Color2.m_b * RatioOf2);
        }
Пример #5
0
 public static RGBA_Doubles rgba_pre(RGBA_Doubles c, double a)
 {
     return new RGBA_Doubles(c, a).premultiply();
 }
Пример #6
0
        public static RGBA_Doubles from_wavelength(double wl, double gamma)
        {
            RGBA_Doubles t = new RGBA_Doubles(0.0, 0.0, 0.0);

            if (wl >= 380.0 && wl <= 440.0)
            {
                t.m_r = -1.0 * (wl - 440.0) / (440.0 - 380.0);
                t.m_b = 1.0;
            }
            else
                if (wl >= 440.0 && wl <= 490.0)
                {
                    t.m_g = (wl - 440.0) / (490.0 - 440.0);
                    t.m_b = 1.0;
                }
                else
                    if (wl >= 490.0 && wl <= 510.0)
                    {
                        t.m_g = 1.0;
                        t.m_b = -1.0 * (wl - 510.0) / (510.0 - 490.0);
                    }
                    else
                        if (wl >= 510.0 && wl <= 580.0)
                        {
                            t.m_r = (wl - 510.0) / (580.0 - 510.0);
                            t.m_g = 1.0;
                        }
                        else
                            if (wl >= 580.0 && wl <= 645.0)
                            {
                                t.m_r = 1.0;
                                t.m_g = -1.0 * (wl - 645.0) / (645.0 - 580.0);
                            }
                            else
                                if (wl >= 645.0 && wl <= 780.0)
                                {
                                    t.m_r = 1.0;
                                }

            double s = 1.0;
            if (wl > 700.0) s = 0.3 + 0.7 * (780.0 - wl) / (780.0 - 700.0);
            else if (wl < 420.0) s = 0.3 + 0.7 * (wl - 380.0) / (420.0 - 380.0);

            t.m_r = Math.Pow(t.m_r * s, gamma);
            t.m_g = Math.Pow(t.m_g * s, gamma);
            t.m_b = Math.Pow(t.m_b * s, gamma);
            return t;
        }