Exemple #1
0
 public Colour32(Colour256 colour)
 {
     this.R = (byte)(colour.R * MaxValue);
     this.G = (byte)(colour.G * MaxValue);
     this.B = (byte)(colour.B * MaxValue);
     this.A = (byte)(colour.A * MaxValue);
 }
Exemple #2
0
        public static Colour256 Lerp(Colour256 a, Colour256 b, double t)
        {
            t = Clamp(t, 0.0D, 1.0D);

            return(new Colour256(
                       a.R + (b.R - a.R) * t,
                       a.G + (b.G - a.G) * t,
                       a.B + (b.B - a.B) * t,
                       a.A + (b.A - a.A) * t
                       ));
        }
Exemple #3
0
        public static Colour32 Combine(Colour32 a, Colour32 b)
        {
            Colour256 c0 = a;
            Colour256 c1 = b;

            double a01 = (1D - c0.A) * c1.A + c0.A;

            return(new Colour256(
                       ((1D - c0.A) * c1.A * c1.R + c0.A * c0.R) / a01,
                       ((1D - c0.A) * c1.A * c1.G + c0.A * c0.G) / a01,
                       ((1D - c0.A) * c1.A * c1.B + c0.A * c0.B) / a01,
                       a01
                       ));
        }
Exemple #4
0
        public static Voxel GenerateDebug(int3 size)
        {
            Voxel voxel = new Voxel(size);

            for (int z = 0; z < size.z; z++)
            {
                for (int y = 0; y < size.y; y++)
                {
                    for (int x = 0; x < size.x; x++)
                    {
                        Colour256 col256 = new Colour256(
                            r: x / ((double)size.x - 1),
                            g: 1.0D - (y / ((double)size.y - 1)),
                            b: z / ((double)size.z - 1),
                            a: 1.0D//(z % 2.0F == 0 ? 1.0D : 0.0D)

                            );

                        if (x % 2 == 0)
                        {
                            col256.A = 0.0D;
                        }
                        if (y % 2 == 0)
                        {
                            col256.A = 0.0D;
                        }
                        if (z % 2 == 0)
                        {
                            col256.A = 0.0D;
                        }

                        Colour32 col32 = (Colour32)col256;

                        voxel[x, y, z] = col256;
                    }
                }
            }

            return(voxel);
        }