public static Color GetColor(double _p, FrameCurve _r, FrameCurve _g, FrameCurve _b) { Color @out = Color.Black; @out.DR = _r.GetValue(_p); @out.DG = _g.GetValue(_p); @out.DB = _b.GetValue(_p); return(@out); }
public static VertexArray DrawMultiple(Vector[] _points, double _thickness, FrameCurve _curve, FrameCurve _r, FrameCurve _g, FrameCurve _b) { Bunch <Vector>[] npoints = new Bunch <Vector>[] { new Bunch <Vector>(), new Bunch <Vector>() }; for (int i = 0; i < _points.Length - 1; i++) { double a = (_points[i + 1] - _points[i]).Angle; for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { npoints[y].Add(_points[i + x] + Vector.FromAngle(a + Meth.Tau / 4 + Meth.Tau / 2 * y, _curve.GetValue((i + x) / (double)(_points.Length - 1)) / 2 * _thickness)); } } } //VertexArray v = new VertexArray(VertexArrayType.Quads); //for (int i = 0; i < npoints[0].LastIndex; i++) //{ // Color c1 = GetColor(i / (double)npoints[0].LastIndex, _r, _g, _b); // Color c2 = GetColor((i + 1) / (double)npoints[0].LastIndex, _r, _g, _b); // v.Add(npoints[0][i], c1); // v.Add(npoints[1][i], c1); // v.Add(npoints[1][i + 1], c2); // v.Add(npoints[0][i + 1], c2); //} VertexArray v = new VertexArray(VertexArrayType.Triangles) { Color = Color.Black }; for (int i = 0; i < npoints[0].LastIndex; i++) { Color c1 = GetColor(i / (double)npoints[0].LastIndex, _r, _g, _b); Color c2 = GetColor((i + 1) / (double)npoints[0].LastIndex, _r, _g, _b); v.Add(npoints[0][i], c1); v.Add(npoints[1][i], c1); v.Add(npoints[1][i + 1], c2); v.Add(npoints[1][i + 1], c2); v.Add(npoints[0][i + 1], c2); v.Add(npoints[0][i], c1); } if (_points.Length > 1) { for (int n = 0; n < 2; n++) { Vector p = _points[n * (_points.Length - 1)]; int q = Meth.Up(_points.Length / 2.0); Color c = GetColor(n, _r, _g, _b); double t = _thickness * _curve.GetValue(n) / 2; double a = ((n == 0) ? (_points[0] - _points[1]).Angle : (_points[_points.Length - 1] - _points[_points.Length - 2]).Angle) - Meth.Tau / 4; for (int i = 0; i < q; i++) { v.Add(p, c); v.Add(p + Vector.FromAngle(a + i / (double)q * Meth.Tau / 2, t), c); v.Add(p + Vector.FromAngle(a + (i + 1) / (double)q * Meth.Tau / 2, t), c); } } } return(v); }