Esempio n. 1
0
        static void DrawLines(NanoVGContext 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 fx, fy;

            float[] pts = new float[8];

            int[] joins = new int[3] {
                (int)NVGlineCap.NVG_MITER, (int)NVGlineCap.NVG_ROUND, (int)NVGlineCap.NVG_BEVEL
            };
            int[] caps = new int[3] {
                (int)NVGlineCap.NVG_BUTT, (int)NVGlineCap.NVG_ROUND, (int)NVGlineCap.NVG_SQUARE
            };
            //NVG_NOTUSED(h);

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

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

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

                    NVG.LineCap(vg, (int)NVGlineCap.NVG_BUTT);
                    NVG.LineJoin(vg, (int)NVGlineCap.NVG_BEVEL);

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


            NVG.Restore(vg);
        }