Exemple #1
0
        public static SimpleColor Blend(SimpleColor a, SimpleColor b)
        {
            int    rval, gval, bval;
            double aval;

            rval = RGBClamp((int)(a.GetA() * (a.GetR() - b.GetR()) + b.GetR()));
            gval = RGBClamp((int)(a.GetA() * (a.GetG() - b.GetG()) + b.GetG()));
            bval = RGBClamp((int)(a.GetA() * (a.GetB() - b.GetB()) + b.GetB()));
            aval = a.GetA() + b.GetA() * (1 - a.GetA());

            return(new SimpleColor(rval, gval, bval, aval));
        }
Exemple #2
0
        public Gene(FastImage src, int minx, int miny, int maxx, int maxy, int minsz, int maxsz)
        {
            x  = _rnd.Next(minx, maxx);
            y  = _rnd.Next(miny, maxy);
            sz = _rnd.Next(minsz, maxsz);
            //color = new SimpleColor(_rnd.Next(0, 256), _rnd.Next(0, 256), _rnd.Next(0, 256));
            SimpleColor sc = src.GetPixel(_rnd.Next(0, src.width), _rnd.Next(0, src.height));

            color = new SimpleColor(sc.GetR(), sc.GetG(), sc.GetB());
        }
Exemple #3
0
        public Gene Clone()
        {
            Gene g = new Gene();

            g.x     = x;
            g.y     = y;
            g.sz    = sz;
            g.color = new SimpleColor(color.GetR(), color.GetG(), color.GetB());

            return(g);
        }
Exemple #4
0
        public static long Error(FastImage a, FastImage b)
        {
            long error = 0;

            for (int x = 0; x < a.width; x++)
            {
                for (int y = 0; y < a.height; y++)
                {
                    SimpleColor old    = a.GetPixel(x, y);
                    SimpleColor srcCol = b.GetPixel(x, y);

                    error += (long)Math.Sqrt(
                        Math.Pow(old.GetR() - srcCol.GetR(), 2) +
                        Math.Pow(old.GetG() - srcCol.GetG(), 2) +
                        Math.Pow(old.GetB() - srcCol.GetB(), 2));
                }
            }

            return(error);
        }