Example #1
0
        public static void drawLines(NvgContext vg, float x, float y, float w, float h, float t)
        {
            int   i, j;
            float pad = 5.0f, s = w / 9.0f - pad * 2;

            float[] pts = new float[4 * 2];
            float   fx, fy;

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

            vg.Save();
            pts[0] = -s * 0.25f + (float)Math.Cos(t * 0.3f) * s * 0.5f;
            pts[1] = (float)Math.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 + (float)Math.Cos(-t * 0.3f) * s * 0.5f;
            pts[7] = (float)Math.Sin(-t * 0.3f) * s * 0.5f;

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

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

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

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

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

            vg.Restore();
        }