//Generate one banding of a palette
        public void PalGen1DBand(int numBands, Grid pal, ulong color1, ulong color2, int band)
        {
            if (pal == null)
            {
                return;
            }

            double sectionSize = 256.0 / numBands / 2;
            ulong  a           = color1;
            ulong  b           = color2;
            var    offset      = (int)(band * sectionSize * 2);

            for (int i = 0; i <= sectionSize; i++)
            {
                double mux   = i / sectionSize;
                ulong  color = MathLerper.LerpRgba(mux, a, b);
                pal.Plot((i + offset), 0, 0, color);
            }
            for (int i = 0; i <= sectionSize; i++)
            {
                double mux   = i / sectionSize;
                ulong  color = MathLerper.LerpRgba(mux, b, a);
                pal.Plot((int)(i + sectionSize + offset), 0, 0, color);
            }
        }
Beispiel #2
0
 //Linearly interpolate between properties A and B, modulated by mux (0 to 1)
 public void Lerp(double mux, CellProperties propsA, CellProperties propsB)
 {
     if (propsA == null || propsB == null)
     {
         return;
     }
     Rgba      = MathLerper.LerpRgba(mux, propsA.Rgba, propsB.Rgba);
     TextureId = (byte)MathLerper.ThresholdAb(mux, propsA.TextureId, propsB.TextureId);
     ShapeId   = (byte)MathLerper.ThresholdAb(mux, propsA.ShapeId, propsB.ShapeId);
     PhysicsId = (byte)MathLerper.ThresholdAb(mux, propsA.PhysicsId, propsB.PhysicsId);
     GroupId   = (byte)MathLerper.ThresholdAb(mux, propsA.GroupId, propsB.GroupId);
     WorldId   = (ulong)MathLerper.ThresholdAb(mux, propsA.WorldId, propsB.WorldId);
     CalcUnified();
 }
        //Generate a palette from a List of banding rgba
        public void PalGen1DBanded(Grid pal, List <ulong> bandColors)
        {
            if (pal == null || bandColors == null)
            {
                return;
            }

            double sectionSize = 256.0 / (bandColors.Count - 1);

            for (int band = 0; band < bandColors.Count - 1; band++)
            {
                ulong a = bandColors[band];
                ulong b = bandColors[band + 1];
                for (int i = 0; i < sectionSize; i++)
                {
                    double mux   = i / sectionSize;
                    ulong  color = MathLerper.LerpRgba(mux, a, b);
                    pal.Plot((int)(band * sectionSize + i), 0, 0, color);
                }
            }
        }