コード例 #1
0
 public ColorCombos(Color c1, Color c2)
 {
     color1 = new ColorEntry(c1);
     color2 = new ColorEntry(c2);
     blends = new List <ColorEntry>();
     used   = 1;
 }
コード例 #2
0
 public ColorCombos()
 {
     color1 = new ColorEntry();
     color2 = new ColorEntry();
     blends = new List <ColorEntry>();
     used   = 0;
 }
コード例 #3
0
        public void AddBlend(ColorEntry newce)
        {
            bool exists = false;

            foreach (ColorEntry ce in this.blends)
            {
                if (ce.color == newce.color)
                {
                    exists = true;
                    ce.occurences++;
                }
            }
            if (!exists)
            {
                this.blends.Add(newce);
            }
        }
コード例 #4
0
        public void CreateBlends(bool alpha, int shades)
        {
            this.blends = new List <ColorEntry>();

            if (shades == -1)
            {
                shades = 255;
            }
            int red   = this.color1.color.R - this.color2.color.R;
            int green = this.color1.color.G - this.color2.color.G;
            int blue  = this.color1.color.B - this.color2.color.B;

            this.AddBlend(new ColorEntry(this.color1.color));

            if (!alpha)
            {
                for (int t = shades - 1; t > 0; t--)
                {
                    int   temp_a   = 255;
                    int   temp_r   = this.color1.color.R - (red * t / shades);
                    int   temp_g   = this.color1.color.G - (green * t / shades);
                    int   temp_b   = this.color1.color.B - (blue * t / shades);
                    Color newcolor = Color.FromArgb(temp_a, temp_r, temp_g, temp_b);

                    this.AddBlend(new ColorEntry(newcolor));
                }
            }

            if (alpha)
            {
                int div = 256 / shades;
                for (int a = 0; a < 256; a += div)
                {
                    Color      alphacolor = BlendAlpha(color1.color, color2.color, a);
                    ColorEntry newce      = new ColorEntry(alphacolor, a, true);
                    this.AddBlend(newce);
                }
            }

            this.AddBlend(new ColorEntry(this.color2.color));
        }