Exemple #1
0
        private void FillImages()
        {
            // fill the source images
            // create some interesting color backgrounds in the source images
            for (var ypos = 0; ypos < 2 * Height; ypos++)
            {
                for (var xpos = 0; xpos < 2 * Width; xpos++)
                {
                    double distance;
                    int    dx, dy;
                    double red, green, blue;

                    dx       = xpos - Width / 2;
                    dy       = ypos - Height / 2;
                    distance = Math.Sqrt(dx * dx + dy * dy);

                    red   = Math.Sin(distance / 21.0);
                    green = Math.Sin(distance / 10.0);
                    blue  = Math.Sin(distance / 16.0);
                    ScaleColor(ref red, ref green, ref blue);
                    img1.SetPixel(xpos, ypos, (byte)red, (byte)green, (byte)blue);

                    red   = Math.Cos(distance / 48.0 + 2 * Math.Sin(distance / 28.0));
                    green = Math.Cos(2 * distance / 31.0 - 3 * Math.Sin(distance / 45.0));
                    blue  = Math.Sin(1.1 - distance / 24.0);
                    ScaleColor(ref red, ref green, ref blue);
                    img2.SetPixel(xpos, ypos, (byte)red, (byte)green, (byte)blue);

                    red   = Math.Sin(distance / 20.0 + 3 * Math.Sin(distance / 25.0));
                    green = Math.Cos(2 * distance / 31.0);
                    blue  = Math.Sin(0.1 - 1.1 * distance / 12.0);
                    ScaleColor(ref red, ref green, ref blue);
                    img3.SetPixel(xpos, ypos, (byte)red, (byte)green, (byte)blue);
                }
            }
        } // FillImages
Exemple #2
0
        private void MakeBackground()
        {
            sw = new Surface(Width, Height);

            sw.Fill(0, 0, 128);

            var top    = new Vector3D(0, 0, 64);
            var bottom = new Vector3D(64, 64, 255);

            // gradient
            for (var j = 0; j < Height; j++)
            {
                var a     = (double)j / Height;
                var color = bottom * a + top * (1 - a);
                var r     = (int)color.X;
                var g     = (int)color.Y;
                var b     = (int)color.Z;
                sw.DrawLine(0, j, Width - 1, j, r, g, b);
            }

#if false
            var font = new FontController();

            int curPos = 0;

            var xpos = curPos;
            var ypos = Height / 2 - font.Font.LineHeight / 2;
            var gap  = (Height - font.Font.LineHeight) * 0.4;

            font.Render(ref xpos, ref ypos, "Hypnocube!",
                        Width, Height,
                        (i, j, r, g, b, a) =>
            {
                if (a != 0)
                {
                    i += 5;
                    int r1, g1, b1;
                    var j2 = (int)(j + Math.Sin(frame / 8.0 + i * 9.0 / Width) * gap);
                    sw.GetPixel(i, j2, out r1, out g1, out b1);

                    //j2 = j;
                    r1 = a * r / 255 + (255 - a) * r1 / 255;
                    g1 = a * g / 255 + (255 - a) * g1 / 255;
                    b1 = a * b / 255 + (255 - a) * b1 / 255;
                    sw.SetPixel(i, j2, r1, g1, b1);
                }
            }
                        );
#endif

            // checkerboard
            //for (var i = 0; i < Width; ++i)
            //    for (var j = 0; j < Height; ++j)
            //    {
            //        var c = (j/16 + i/16) & 1;
            //        int r, g, b;
            //        r = g = b = 255;
            //        if (c==1)
            //            r = g = 0;
            //        sw.SetPixel(i, j, r, g, b);
            //    }
        }