Example #1
0
        public void SetVertex(int vertexID, sXYZ loc, sColor col)
        {
            sVertex v = new sVertex(vertexID, loc);

            v.color = col;
            this.vertices.Add(v);
        }
        public static sColor FromWinColor(Color col)
        {
            sColor sc = new sColor();

            sc.a = col.A;
            sc.R = col.R;
            sc.G = col.G;
            sc.B = col.B;
            return(sc);
        }
        public sColor(double h, double s, double v)
        {
            this.a = 255;

            sColor temp = ColorFromHSVA(h, s, v, 255);

            this.R = temp.R;
            this.G = temp.G;
            this.B = temp.B;
        }
        public static sColor BlendColors(sColor col1, sColor col2, double param)
        {
            byte r = (byte)((col2.R * param) + col1.R * (1 - param));
            byte g = (byte)((col2.G * param) + col1.G * (1 - param));
            byte b = (byte)((col2.B * param) + col1.B * (1 - param));

            sColor sc = new sColor();

            sc.a = 255;
            sc.R = (int)r;
            sc.G = (int)g;
            sc.B = (int)b;
            return(sc);
        }
        public sColor ColorAt(double parameter)
        {
            List <sColorRangePair> pairs = new List <sColorRangePair>();

            for (int i = 0; i < this.parameters.Count - 1; ++i)
            {
                sColorRangePair pa = new sColorRangePair();
                pa.range = new sRange(this.parameters[i], this.parameters[i + 1]);

                pa.col1 = this.colors[i];
                pa.col2 = this.colors[i + 1];

                pairs.Add(pa);
            }

            sColor col = new sColor();

            for (int i = 0; i < pairs.Count; ++i)
            {
                if (pairs[i].range.Includes(parameter))
                {
                    col = sColor.BlendColors(pairs[i].col1, pairs[i].col2, pairs[i].range.GetNormalizedAt(parameter));
                    break;
                }
                else
                {
                    if (parameter >= this.parameters.Max())
                    {
                        col = this.colors[this.colors.Count - 1];
                    }
                    if (parameter <= this.parameters.Min())
                    {
                        col = this.colors[0];
                    }
                }
            }

            return(col);
        }
        public sColor DuplicatesColor()
        {
            sColor nc = new sColor(this.a, this.R, this.G, this.B);

            return(nc);
        }