GradientPicker.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. //********************************** Banshee Engine (www.banshee4d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Collections.Generic;
  5. using bs;
  6. namespace bs.Editor
  7. {
  8. /** @addtogroup Windows
  9. * @{
  10. */
  11. /// <summary>
  12. /// A color gradient editor window that allows the user to add or modify colors from a color gradient.
  13. /// </summary>
  14. public class GradientPicker : ModalWindow
  15. {
  16. private const int EDITOR_HORZ_PADDING = 10;
  17. private const int TEX_WIDTH = 256;
  18. private const int TEX_HEIGHT = 4;
  19. private ColorGradient gradient;
  20. private GradientKeyEditor editor;
  21. private GUITexture guiGradientTexture;
  22. private GUICanvas overlayCanvas;
  23. private GUIPanel editorPanel;
  24. private GUIButton guiOK;
  25. private GUIButton guiCancel;
  26. private Texture texture;
  27. private SpriteTexture spriteTexture;
  28. private Action<bool, ColorGradient> closedCallback;
  29. /// <summary>
  30. /// Shows the gradient picker window.
  31. /// </summary>
  32. /// <param name="closedCallback">Optional callback to trigger when the user finishes editing the gradient or
  33. /// cancels out of the dialog.</param>
  34. /// <returns>An instance of the gradient picker window.</returns>
  35. public static GradientPicker Show(Action<bool, ColorGradient> closedCallback = null)
  36. {
  37. GradientPicker picker = new GradientPicker(new ColorGradient(), closedCallback);
  38. return picker;
  39. }
  40. /// <summary>
  41. /// Shows the gradient picker window and sets the initial gradient to show.
  42. /// </summary>
  43. /// <param name="gradient">Gradient to initially display in the window.</param>
  44. /// <param name="closedCallback">Optional callback to trigger when the user finishes editing the gradient or
  45. /// cancels out of the dialog.</param>
  46. /// <returns>A. instance of the gradient picker window.</returns>
  47. public static GradientPicker Show(ColorGradient gradient, Action<bool, ColorGradient> closedCallback = null)
  48. {
  49. GradientPicker picker = new GradientPicker(gradient, closedCallback);
  50. return picker;
  51. }
  52. /// <summary>
  53. /// Constructs a new gradient picker window.
  54. /// </summary>
  55. /// <param name="gradient">Gradient to initially display in the window.</param>
  56. /// <param name="closedCallback">Optional callback to trigger when the user finishes editing the gradient or
  57. /// cancels out of the dialog.</param>
  58. protected GradientPicker(ColorGradient gradient, Action<bool, ColorGradient> closedCallback = null)
  59. : base(false)
  60. {
  61. Title = new LocEdString("Gradient Picker");
  62. Width = 270;
  63. Height = 135;
  64. this.gradient = gradient;
  65. this.closedCallback = closedCallback;
  66. }
  67. private void OnInitialize()
  68. {
  69. guiOK = new GUIButton(new LocEdString("OK"));
  70. guiCancel = new GUIButton(new LocEdString("Cancel"));
  71. guiOK.OnClick += OnOK;
  72. guiCancel.OnClick += OnCancel;
  73. GUILayout mainVertLayout = GUI.AddLayoutY();
  74. mainVertLayout.AddSpace(10);
  75. GUILayout editorHorzLayout = mainVertLayout.AddLayoutX();
  76. editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);
  77. GUIPanel gradientEditorPanel = editorHorzLayout.AddPanel();
  78. editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);
  79. mainVertLayout.AddSpace(15);
  80. GUILayout buttonHorzLayout = mainVertLayout.AddLayoutX();
  81. buttonHorzLayout.AddFlexibleSpace();
  82. buttonHorzLayout.AddElement(guiOK);
  83. buttonHorzLayout.AddSpace(10);
  84. buttonHorzLayout.AddElement(guiCancel);
  85. buttonHorzLayout.AddFlexibleSpace();
  86. mainVertLayout.AddFlexibleSpace();
  87. editorPanel = gradientEditorPanel.AddPanel(0);
  88. GUIPanel editorOverlay = gradientEditorPanel.AddPanel(-1);
  89. overlayCanvas = new GUICanvas();
  90. editorOverlay.AddElement(overlayCanvas);
  91. GUILayout editorVertLayout = editorPanel.AddLayoutY();
  92. GUILayout guiGradientLayout = editorVertLayout.AddLayoutX();
  93. guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);
  94. texture = Texture.Create2D(TEX_WIDTH, TEX_HEIGHT);
  95. spriteTexture = new SpriteTexture(texture);
  96. guiGradientTexture = new GUITexture(spriteTexture, GUITextureScaleMode.StretchToFit);
  97. guiGradientTexture.SetHeight(30);
  98. UpdateTexture();
  99. guiGradientLayout.AddElement(guiGradientTexture);
  100. guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);
  101. editorVertLayout.AddSpace(10);
  102. editor = new GradientKeyEditor(editorVertLayout, gradient.GetKeys(), Width - EDITOR_HORZ_PADDING * 2, 20);
  103. editor.OnGradientModified += colorGradient =>
  104. {
  105. gradient = colorGradient;
  106. UpdateTexture();
  107. UpdateKeyLines();
  108. };
  109. editorVertLayout.AddFlexibleSpace();
  110. GUITexture containerBg = new GUITexture(null, EditorStylesInternal.ContainerBg);
  111. Rect2I containerBounds = editor.GetBounds(GUI);
  112. containerBounds.x -= 2;
  113. containerBounds.y -= 2;
  114. containerBounds.width += 4;
  115. containerBounds.height += 6;
  116. containerBg.Bounds = containerBounds;
  117. GUIPanel editorUnderlay = GUI.AddPanel(1);
  118. editorUnderlay.AddElement(containerBg);
  119. UpdateKeyLines();
  120. EditorInput.OnPointerPressed += OnPointerPressed;
  121. EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked;
  122. EditorInput.OnPointerMoved += OnPointerMoved;
  123. EditorInput.OnPointerReleased += OnPointerReleased;
  124. EditorInput.OnButtonUp += OnButtonUp;
  125. }
  126. private void OnDestroy()
  127. {
  128. EditorInput.OnPointerPressed -= OnPointerPressed;
  129. EditorInput.OnPointerDoubleClick -= OnPointerDoubleClicked;
  130. EditorInput.OnPointerMoved -= OnPointerMoved;
  131. EditorInput.OnPointerReleased -= OnPointerReleased;
  132. EditorInput.OnButtonUp -= OnButtonUp;
  133. }
  134. /// <summary>
  135. /// Draws lines connecting the individual key color over the gradient itself.
  136. /// </summary>
  137. private void UpdateKeyLines()
  138. {
  139. overlayCanvas.Clear();
  140. ColorGradientKey[] keys = gradient.GetKeys();
  141. for (int i = 0; i < keys.Length; i++)
  142. {
  143. int pixel = editor.TimeToPixel(keys[i].time);
  144. overlayCanvas.DrawLine(new Vector2I(pixel, 0), new Vector2I(pixel, 40), Color.DarkGray);
  145. }
  146. }
  147. /// <summary>
  148. /// Updates the gradient texture.
  149. /// </summary>
  150. public void UpdateTexture()
  151. {
  152. const int width = 256;
  153. const int height = 4;
  154. Color[] colors = new Color[width * height];
  155. float halfPixel = 0.5f / width;
  156. if (gradient.NumKeys > 0)
  157. {
  158. for (int x = 0; x < width; x++)
  159. {
  160. Color color = gradient.Evaluate(x / (float) width + halfPixel);
  161. for (int y = 0; y < height; y++)
  162. colors[y * width + x] = color;
  163. }
  164. }
  165. else
  166. {
  167. for (int x = 0; x < width; x++)
  168. {
  169. for (int y = 0; y < height; y++)
  170. colors[y * width + x] = Color.Black;
  171. }
  172. }
  173. texture.SetPixels(colors);
  174. guiGradientTexture.SetTexture(spriteTexture);
  175. }
  176. /// <summary>
  177. /// Triggered when the user selects a gradient and closes the dialog.
  178. /// </summary>
  179. void OnOK()
  180. {
  181. closedCallback?.Invoke(true, gradient);
  182. Close();
  183. }
  184. /// <summary>
  185. /// Triggered when the user cancels gradient editing and closes the dialog.
  186. /// </summary>
  187. void OnCancel()
  188. {
  189. closedCallback?.Invoke(false, gradient);
  190. Close();
  191. }
  192. #region Input callbacks
  193. /// <summary>
  194. /// Triggered when the user presses a mouse button.
  195. /// </summary>
  196. /// <param name="ev">Information about the mouse press event.</param>
  197. private void OnPointerPressed(PointerEvent ev)
  198. {
  199. if (ev.IsUsed)
  200. return;
  201. editor.OnPointerPressed(ScreenToKeyEditorPos(ev.ScreenPos), ev.Button);
  202. }
  203. /// <summary>
  204. /// Triggered when the user double clicks the left mouse button.
  205. /// </summary>
  206. /// <param name="ev">Information about the mouse event.</param>
  207. private void OnPointerDoubleClicked(PointerEvent ev)
  208. {
  209. if (ev.IsUsed)
  210. return;
  211. Vector2I panelPos = ScreenToKeyEditorPos(ev.ScreenPos);
  212. Rect2I guiGradientBounds = guiGradientTexture.Bounds;
  213. if (guiGradientBounds.Contains(panelPos))
  214. {
  215. Vector2I canvasPos = panelPos - new Vector2I(guiGradientBounds.x, guiGradientBounds.y);
  216. float time = canvasPos.x / (float) Math.Max(guiGradientBounds.width - 1, 1);
  217. if (time >= 0.0f && time <= 1.0f)
  218. {
  219. List<ColorGradientKey> keys = new List<ColorGradientKey>(gradient.GetKeys());
  220. keys.Add(new ColorGradientKey(Color.Black, time));
  221. keys.Sort((lhs, rhs) => lhs.time.CompareTo(rhs.time));
  222. gradient = new ColorGradient(keys.ToArray());
  223. UpdateTexture();
  224. editor.Rebuild(keys);
  225. UpdateKeyLines();
  226. }
  227. }
  228. else
  229. editor.OnPointerDoubleClicked(panelPos, ev.Button);
  230. }
  231. /// <summary>
  232. /// Triggered when the user moves the mouse.
  233. /// </summary>
  234. /// <param name="ev">Information about the mouse move event.</param>
  235. private void OnPointerMoved(PointerEvent ev)
  236. {
  237. if (ev.IsUsed)
  238. return;
  239. editor.OnPointerMoved(ScreenToKeyEditorPos(ev.ScreenPos), ev.Button);
  240. }
  241. /// <summary>
  242. /// Triggered when the user releases a mouse button.
  243. /// </summary>
  244. /// <param name="ev">Information about the mouse release event.</param>
  245. private void OnPointerReleased(PointerEvent ev)
  246. {
  247. if (ev.IsUsed)
  248. return;
  249. editor.OnPointerReleased(ScreenToKeyEditorPos(ev.ScreenPos));
  250. }
  251. /// <summary>
  252. /// Triggered when the user releases a keyboard button.
  253. /// </summary>
  254. /// <param name="ev">Information about the keyboard release event.</param>
  255. private void OnButtonUp(ButtonEvent ev)
  256. {
  257. editor.OnButtonUp(ev);
  258. }
  259. /// <summary>
  260. /// Converts screen coordinates in coordinates relative to the panel containing the key editor control.
  261. /// </summary>
  262. /// <param name="screenPos">Coordinates in screen space.</param>
  263. /// <returns>Coordinates relative to the key editor control.</returns>
  264. private Vector2I ScreenToKeyEditorPos(Vector2I screenPos)
  265. {
  266. Vector2I windowPos = ScreenToWindowPos(screenPos);
  267. Rect2I elementBounds = GUIUtility.CalculateBounds(editorPanel, GUI);
  268. return windowPos - new Vector2I(elementBounds.x, elementBounds.y);
  269. }
  270. #endregion
  271. /// <summary>
  272. /// Handles drawing and editing of individual keys present on the color gradient.
  273. /// </summary>
  274. public class GradientKeyEditor
  275. {
  276. public const int RECT_WIDTH = 14;
  277. private static readonly Color SELECTED_COLOR = Color.BansheeOrange;
  278. private static readonly Color PLAIN_COLOR = Color.DarkGray;
  279. private const int DRAG_START_DISTANCE = 3;
  280. private GUICanvas canvas;
  281. private List<ColorGradientKey> keys = new List<ColorGradientKey>();
  282. private int width;
  283. private int height;
  284. private int selectedIdx = -1;
  285. private bool isMousePressedOverKey;
  286. private bool isDragInProgress;
  287. private Vector2I dragStart;
  288. /// <summary>
  289. /// Triggered whenever keyframe in a gradient is modified (added, removed or edited).
  290. /// </summary>
  291. public Action<ColorGradient> OnGradientModified;
  292. /// <summary>
  293. /// Constructs a new gradient key editor control.
  294. /// </summary>
  295. /// <param name="parent">GUI layout to attach the child GUI controls to.</param>
  296. /// <param name="keys">Set of keys to initially display on the editor.</param>
  297. /// <param name="width">Width of the editor in pixels.</param>
  298. /// <param name="height">Height of the editor in pixels.</param>
  299. public GradientKeyEditor(GUILayout parent, ColorGradientKey[] keys, int width, int height)
  300. {
  301. canvas = new GUICanvas();
  302. parent.AddElement(canvas);
  303. Rebuild(new List<ColorGradientKey>(keys), width, height);
  304. }
  305. /// <summary>
  306. /// Rebuilds the editor display using the provided color keys.
  307. /// </summary>
  308. /// <param name="keys">Set of keys to initially display on the editor.</param>
  309. public void Rebuild(List<ColorGradientKey> keys)
  310. {
  311. this.keys = keys;
  312. canvas.Clear();
  313. for (int i = 0; i < keys.Count; i++)
  314. DrawColor(keys[i].color, MathEx.Clamp01(keys[i].time), i == selectedIdx);
  315. }
  316. /// <summary>
  317. /// Returns the bounds of the GUI element relative to the provided panel.
  318. /// </summary>
  319. public Rect2I GetBounds(GUIPanel relativeTo)
  320. {
  321. return GUIUtility.CalculateBounds(canvas, relativeTo);
  322. }
  323. /// <summary>
  324. /// Rebuilds the editor display using the provided size and color keys.
  325. /// </summary>
  326. /// <param name="keys">Set of keys to initially display on the editor.</param>
  327. /// <param name="width">Width of the editor in pixels.</param>
  328. /// <param name="height">Height of the editor in pixels.</param>
  329. private void Rebuild(List<ColorGradientKey> keys, int width, int height)
  330. {
  331. this.width = width;
  332. this.height = height;
  333. canvas.SetWidth(width);
  334. canvas.SetHeight(height);
  335. Rebuild(keys);
  336. }
  337. /// <summary>
  338. /// Rebuilds the editor display using the currently set properties.
  339. /// </summary>
  340. private void Rebuild()
  341. {
  342. Rebuild(keys, width, height);
  343. }
  344. /// <summary>
  345. /// Attempts to find a color key rectangle at the specified location.
  346. /// </summary>
  347. /// <param name="pixelCoords">Pixel position to look at, relative to the canvas element.</param>
  348. /// <param name="keyIdx">Index of the color key, if any was found.</param>
  349. /// <returns>True if the key was found under the provided position, false otherwise.</returns>
  350. public bool FindKey(Vector2I pixelCoords, out int keyIdx)
  351. {
  352. keyIdx = -1;
  353. if (pixelCoords.y < 0 || pixelCoords.y >= height)
  354. return false;
  355. for (int i = 0; i < keys.Count; i++)
  356. {
  357. float t = MathEx.Clamp01(keys[i].time);
  358. int x = (int)(t * Math.Max(width - RECT_WIDTH, 0));
  359. if (pixelCoords.x >= x & pixelCoords.x < (x + RECT_WIDTH))
  360. {
  361. keyIdx = i;
  362. return true;
  363. }
  364. }
  365. return false;
  366. }
  367. /// <summary>
  368. /// Handles input. Should be called by the owning window whenever a pointer is pressed.
  369. /// </summary>
  370. /// <param name="panelPos">Position of the pointer relative to the panel parent to this element.</param>
  371. /// <param name="button">Pointer button involved in the event.</param>
  372. internal void OnPointerPressed(Vector2I panelPos, PointerButton button)
  373. {
  374. Rect2I canvasBounds = canvas.Bounds;
  375. Vector2I canvasPos = panelPos - new Vector2I(canvasBounds.x, canvasBounds.y);
  376. if (button == PointerButton.Left)
  377. {
  378. int keyIdx;
  379. if (FindKey(canvasPos, out keyIdx))
  380. {
  381. selectedIdx = keyIdx;
  382. isMousePressedOverKey = true;
  383. dragStart = canvasPos;
  384. }
  385. else
  386. selectedIdx = -1;
  387. Rebuild();
  388. }
  389. }
  390. /// <summary>
  391. /// Handles input. Should be called by the owning window whenever a pointer is double-clicked.
  392. /// </summary>
  393. /// <param name="panelPos">Position of the pointer relative to the panel parent to this element.</param>
  394. /// <param name="button">Pointer button involved in the event.</param>
  395. internal void OnPointerDoubleClicked(Vector2I panelPos, PointerButton button)
  396. {
  397. Rect2I canvasBounds = canvas.Bounds;
  398. if (!canvasBounds.Contains(panelPos))
  399. return;
  400. Vector2I canvasPos = panelPos - new Vector2I(canvasBounds.x, canvasBounds.y);
  401. int keyIdx;
  402. if (FindKey(canvasPos, out keyIdx))
  403. {
  404. ColorPicker.Show(keys[keyIdx].color, false,
  405. (b, color) =>
  406. {
  407. if (b)
  408. {
  409. ColorGradientKey key = keys[keyIdx];
  410. key.color = color;
  411. keys[keyIdx] = key;
  412. OnGradientModified?.Invoke(new ColorGradient(keys.ToArray()));
  413. Rebuild();
  414. }
  415. });
  416. }
  417. else
  418. {
  419. float time = PixelToTime(canvasPos.x);
  420. if (time >= 0.0f && time <= 1.0f)
  421. {
  422. keys.Add(new ColorGradientKey(Color.Black, time));
  423. keys.Sort((lhs, rhs) => lhs.time.CompareTo(rhs.time));
  424. OnGradientModified?.Invoke(new ColorGradient(keys.ToArray()));
  425. }
  426. Rebuild();
  427. }
  428. }
  429. /// <summary>
  430. /// Handles input. Should be called by the owning window whenever a pointer is moved.
  431. /// </summary>
  432. /// <param name="panelPos">Position of the pointer relative to the panel parent to this element.</param>
  433. /// <param name="button">Pointer button involved in the event.</param>
  434. internal void OnPointerMoved(Vector2I panelPos, PointerButton button)
  435. {
  436. if (button != PointerButton.Left)
  437. return;
  438. if (isMousePressedOverKey)
  439. {
  440. Rect2I canvasBounds = canvas.Bounds;
  441. Vector2I canvasPos = panelPos - new Vector2I(canvasBounds.x, canvasBounds.y);
  442. if (!isDragInProgress)
  443. {
  444. int distance = Vector2I.Distance(canvasPos, dragStart);
  445. if (distance >= DRAG_START_DISTANCE)
  446. isDragInProgress = true;
  447. }
  448. if (isDragInProgress)
  449. {
  450. float time = PixelToTime(canvasPos.x);
  451. if (time >= 0.0f && time <= 1.0f)
  452. {
  453. ColorGradientKey key = keys[selectedIdx];
  454. key.time = time;
  455. keys[selectedIdx] = key;
  456. OnGradientModified?.Invoke(new ColorGradient(keys.ToArray()));
  457. }
  458. Rebuild();
  459. }
  460. }
  461. }
  462. /// <summary>
  463. /// Handles input. Should be called by the owning window whenever a pointer is released.
  464. /// </summary>
  465. /// <param name="panelPos">Position of the pointer relative to the panel parent to this element.</param>
  466. internal void OnPointerReleased(Vector2I panelPos)
  467. {
  468. isDragInProgress = false;
  469. isMousePressedOverKey = false;
  470. }
  471. /// <summary>
  472. /// Handles input. Should be called by the owning window whenever a button is released.
  473. /// </summary>
  474. /// <param name="ev">Object containing button release event information.</param>
  475. internal void OnButtonUp(ButtonEvent ev)
  476. {
  477. if (ev.Button == ButtonCode.Delete && selectedIdx != -1 && !isMousePressedOverKey)
  478. {
  479. if (selectedIdx < keys.Count)
  480. {
  481. keys.RemoveAt(selectedIdx);
  482. OnGradientModified?.Invoke(new ColorGradient(keys.ToArray()));
  483. }
  484. selectedIdx = -1;
  485. Rebuild();
  486. }
  487. }
  488. /** Converts a pixel position over the editor (on x axis) to a time in range [0, 1]. */
  489. internal float PixelToTime(int x)
  490. {
  491. x -= RECT_WIDTH / 2;
  492. return x / (float) Math.Max(this.width - RECT_WIDTH, 0);
  493. }
  494. /** Converts a time in range [0, 1] to a pixel position over the editor (on x axis). */
  495. internal int TimeToPixel(float t)
  496. {
  497. return (int) Math.Min(t * Math.Max(width - RECT_WIDTH, 0), width - RECT_WIDTH - 1) + RECT_WIDTH / 2;
  498. }
  499. /// <summary>
  500. /// Draws a rectangle representing a single color key in the gradient.
  501. /// </summary>
  502. /// <param name="color">Color to display.</param>
  503. /// <param name="t">Time at which to draw the rectangle, in range [0, 1].</param>
  504. /// <param name="selected">True to draw the rectangle as selected, plain otherwise.</param>
  505. private void DrawColor(Color color, float t, bool selected)
  506. {
  507. int x = TimeToPixel(t);
  508. Vector2I a = new Vector2I(x + RECT_WIDTH / 2, 0);
  509. Vector2I b = new Vector2I(x + RECT_WIDTH / 2, height - 1);
  510. Vector2I c = new Vector2I(x - RECT_WIDTH / 2, 0);
  511. Vector2I d = new Vector2I(x - RECT_WIDTH / 2, height - 1);
  512. Vector2I[] linePoints = new Vector2I[] { a, b, d, c, a };
  513. Vector2I[] trianglePoints = new Vector2I[] { a, b, c, d };
  514. Color colorNoAlpha = color;
  515. colorNoAlpha.a = 1.0f;
  516. canvas.DrawTriangleStrip(trianglePoints, colorNoAlpha, 102);
  517. canvas.DrawPolyLine(linePoints, selected ? SELECTED_COLOR : PLAIN_COLOR, 100);
  518. Vector2I alphaA = new Vector2I(x - 1, height - 1);
  519. Vector2I alphaB = new Vector2I(x + RECT_WIDTH / 2, height / 2);
  520. Vector2I alphaC = new Vector2I(x + RECT_WIDTH / 2, height - 1);
  521. canvas.DrawTriangleList(new [] { alphaA, alphaB, alphaC }, Color.White * color.a, 101);
  522. }
  523. };
  524. }
  525. /** @} */
  526. }