Esempio n. 1
0
        private unsafe void DrawLines(float x, float y, float w, float h, float t)
        {
            float  pad = 5.0f;
            float  s   = w / 9.0f - pad * 2;
            float *pts = stackalloc float[4 * 2];

            LineCap[] joins = { LineCap.Miter, LineCap.Round, LineCap.Bevel };
            LineCap[] caps  = { LineCap.Butt, LineCap.Round, LineCap.Square };

            _nvg.Save();
            pts[0] = -s * 0.25f + MathF.Cos(t * 0.3f) * s * 0.5f;
            pts[1] = MathF.Sin(t * 0.3f) * s * 0.5f;
            pts[2] = -s * 0.25f;
            pts[3] = 0;
            pts[4] = s * 0.25f;
            pts[5] = 0;
            pts[6] = s * 0.25f + MathF.Cos(-t * 0.3f) * s * 0.5f;
            pts[7] = MathF.Sin(-t * 0.3f) * s * 0.5f;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    float fx = x + s * 0.5f + (i * 3 + j) / 9.0f * w + pad;
                    float fy = y - s * 0.5f + pad;

                    _nvg.LineCap(caps[i]);
                    _nvg.LineJoin(joins[j]);

                    _nvg.StrokeWidth(s * 0.3f);
                    _nvg.StrokeColour(new Colour(0, 0, 0, 160));
                    _nvg.BeginPath();
                    _nvg.MoveTo(fx + pts[0], fy + pts[1]);
                    _nvg.LineTo(fx + pts[2], fy + pts[3]);
                    _nvg.LineTo(fx + pts[4], fy + pts[5]);
                    _nvg.LineTo(fx + pts[6], fy + pts[7]);
                    _nvg.Stroke();

                    _nvg.LineCap(LineCap.Butt);
                    _nvg.LineJoin(LineCap.Bevel);

                    _nvg.StrokeWidth(1.0f);
                    _nvg.StrokeColour(new Colour(0, 192, 255, 255));
                    _nvg.BeginPath();
                    _nvg.MoveTo(fx + pts[0], fy + pts[1]);
                    _nvg.LineTo(fx + pts[2], fy + pts[3]);
                    _nvg.LineTo(fx + pts[4], fy + pts[5]);
                    _nvg.LineTo(fx + pts[6], fy + pts[7]);
                    _nvg.Stroke();
                }
            }

            _nvg.Restore();
        }