Пример #1
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);
            //    }
        }