/// <summary> /// Draws a rectangle representing a single color key in the gradient. /// </summary> /// <param name="color">Color to display.</param> /// <param name="t">Time at which to draw the rectangle, in range [0, 1].</param> /// <param name="selected">True to draw the rectangle as selected, plain otherwise.</param> private void DrawColor(Color color, float t, bool selected) { int x = TimeToPixel(t); Vector2I a = new Vector2I(x + RECT_WIDTH / 2, 0); Vector2I b = new Vector2I(x + RECT_WIDTH / 2, height - 1); Vector2I c = new Vector2I(x - RECT_WIDTH / 2, 0); Vector2I d = new Vector2I(x - RECT_WIDTH / 2, height - 1); Vector2I[] linePoints = new Vector2I[] { a, b, d, c, a }; Vector2I[] trianglePoints = new Vector2I[] { a, b, c, d }; Color colorNoAlpha = color; colorNoAlpha.a = 1.0f; canvas.DrawTriangleStrip(trianglePoints, colorNoAlpha, 102); canvas.DrawPolyLine(linePoints, selected ? SELECTED_COLOR : PLAIN_COLOR, 100); Vector2I alphaA = new Vector2I(x - 1, height - 1); Vector2I alphaB = new Vector2I(x + RECT_WIDTH / 2, height / 2); Vector2I alphaC = new Vector2I(x + RECT_WIDTH / 2, height - 1); canvas.DrawTriangleList(new [] { alphaA, alphaB, alphaC }, Color.White * color.a, 101); }