static void DrawGraph(NanoVGContext vg, float x, float y, float w, float h, float t) { NVGPaint bg; float[] samples = new float[6]; float[] sx = new float[6], sy = new float[6]; float dx = w / 5.0f; int i; samples[0] = (1 + (float)Math.Sin(t * 1.2345f + Math.Cos(t * 0.33457f) * 0.44f)) * 0.5f; samples[1] = (1 + (float)Math.Sin(t * 0.68363f + Math.Cos(t * 1.3f) * 1.55f)) * 0.5f; samples[2] = (1 + (float)Math.Sin(t * 1.1642f + Math.Cos(t * 0.33457) * 1.24f)) * 0.5f; samples[3] = (1 + (float)Math.Sin(t * 0.56345f + Math.Cos(t * 1.63f) * 0.14f)) * 0.5f; samples[4] = (1 + (float)Math.Sin(t * 1.6245f + Math.Cos(t * 0.254f) * 0.3f)) * 0.5f; samples[5] = (1 + (float)Math.Sin(t * 0.345f + Math.Cos(t * 0.03f) * 0.6f)) * 0.5f; for (i = 0; i < 6; i++) { sx[i] = x + i * dx; sy[i] = y + h * samples[i] * 0.8f; } // Graph background bg = NVG.LinearGradient(vg, x, y, x, y + h, NVG.RGBA(0, 160, 192, 0), NVG.RGBA(0, 160, 192, 64)); NVG.BeginPath(vg); NVG.MoveTo(vg, sx[0], sy[0]); for (i = 1; i < 6; i++) { NVG.BezierTo(vg, sx[i - 1] + dx * 0.5f, sy[i - 1], sx[i] - dx * 0.5f, sy[i], sx[i], sy[i]); } NVG.LineTo(vg, x + w, y + h); NVG.LineTo(vg, x, y + h); NVG.FillPaint(vg, bg); NVG.Fill(vg); // Graph line NVG.BeginPath(vg); NVG.MoveTo(vg, sx[0], sy[0] + 2); for (i = 1; i < 6; i++) { NVG.BezierTo(vg, sx[i - 1] + dx * 0.5f, sy[i - 1] + 2, sx[i] - dx * 0.5f, sy[i] + 2, sx[i], sy[i] + 2); } NVG.StrokeColor(vg, NVG.RGBA(0, 0, 0, 32)); NVG.StrokeWidth(vg, 3.0f); NVG.Stroke(vg); NVG.BeginPath(vg); NVG.MoveTo(vg, sx[0], sy[0]); for (i = 1; i < 6; i++) { NVG.BezierTo(vg, sx[i - 1] + dx * 0.5f, sy[i - 1], sx[i] - dx * 0.5f, sy[i], sx[i], sy[i]); } NVG.StrokeColor(vg, NVG.RGBA(0, 160, 192, 255)); NVG.StrokeWidth(vg, 3.0f); NVG.Stroke(vg); // Graph sample pos for (i = 0; i < 6; i++) { bg = NVG.RadialGradient(vg, sx[i], sy[i] + 2, 3.0f, 8.0f, NVG.RGBA(0, 0, 0, 32), NVG.RGBA(0, 0, 0, 0)); NVG.BeginPath(vg); NVG.Rect(vg, sx[i] - 10, sy[i] - 10 + 2, 20, 20); NVG.FillPaint(vg, bg); NVG.Fill(vg); } NVG.BeginPath(vg); for (i = 0; i < 6; i++) { NVG.Circle(vg, sx[i], sy[i], 4.0f); } NVG.FillColor(vg, NVG.RGBA(0, 160, 192, 255)); NVG.Fill(vg); NVG.BeginPath(vg); for (i = 0; i < 6; i++) { NVG.Circle(vg, sx[i], sy[i], 2.0f); } NVG.FillColor(vg, NVG.RGBA(220, 220, 220, 255)); NVG.Fill(vg); NVG.StrokeWidth(vg, 1.0f); }