Exemple #1
0
		public static GuiRenderer.TriangleVertex[] GenerateTrianglesFromCurve(GuiRenderer renderer, Curve curve, float step, Vec2 thickness, ColorValue color)
		{
			float maxTime = curve.Times[curve.Times.Count - 1];
			float end = maxTime + step;

			List<Vec2> points = new List<Vec2>();
			for (float time = 0; time < end; time += step)
			{
				points.Add(curve.CalculateValueByTime(time).ToVec2());
			}

#if DebugDraw
			Vec2 xHalf = new Vec2(thickness.X / 16, 0f);
			Vec2 yHalf = new Vec2(0f, thickness.Y / 16);
			float g = 1f;
			// The green progression here is so we can tell which
			// direction the curve was heading.
			foreach (Vec2 point in points)
			{
				renderer.AddQuad(new Rect(point - xHalf, point + yHalf), new ColorValue(1f, g, 0f));
				g -= 0.05f;
			}
#endif

			return GenerateTriangles(points, thickness, color);
		}