using System.Numerics; namespace Quik { /// /// Enumeration of QUIK commands. /// public enum QuikCommandType { /// /// Nothing. /// /// None, /// /// Set a mask region. /// Mask, /// /// Draw a line. /// /// Line, /// /// Draw multiple lines. /// Lines, /// /// Draw a Bezier curve. /// Bezier, /// /// Draw a rectangle. /// Rectangle, /// /// Draw multiple rectangles. /// Rectangles, /// /// Draw an ellipse. /// Ellipse, /// /// Draw multiple ellipses. /// Ellipses, /// /// Draw a triangle. /// Triangle, /// /// Draw multiple triangles. /// Triangles, /// /// Draw a polygon. /// Polygon, /// /// Put a character. /// PutChar, /// /// Put text. /// PutText, /// /// Flow text in box. /// FlowText, /// /// Clear the image mask. /// StencilMaskClear, /// /// Create an image mask with the following commands. /// StencilMaskBegin, /// /// End the image mask commands. /// StencilMaskEnd, /// /// Draw an image. /// Image, /// /// Begin defining custom commands after this value. /// /// CustomCommandRange = 1024, } /// /// A single QUIK command. /// public abstract class QuikCommand { /// /// The type ID for the QUIK command. /// public abstract QuikCommandType Type { get; } } /// /// Does nothing. /// public sealed class QuikCommandNone : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.None; } public sealed class QuikCommandMask : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Mask; public QuikRectangle Bounds { get; } public QuikCommandMask(QuikRectangle bounds) { Bounds = bounds; } } /// /// Draws a line. /// public sealed class QuikCommandLine : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Line; /// /// The line to draw. /// public QuikLine Line { get; } /// /// Create a draw line command. /// /// The line to draw. public QuikCommandLine(QuikLine line) { Line = line; } } /// /// Draw multiple lines. /// public sealed class QuikCommandLines : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Lines; /// /// The array of lines to draw. /// public QuikLine[] Lines { get; } /// /// Create a draw lines command. /// /// The lines to draw. public QuikCommandLines(QuikLine[] lines) { Lines = lines; } } /// /// Draw a Bezier curve. /// public sealed class QuikCommandBezier : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Bezier; /// /// The Bezier curve segments to draw. /// public QuikBezier[] Segments; /// /// Create a draw Bezier curve command. /// /// The Bezier curve segments to draw. public QuikCommandBezier(QuikBezier[] segments) { Segments = segments; } } /// /// Draw a rectangle. /// public sealed class QuikCommandRectangle : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Rectangle; /// /// The rectangle to draw. /// public QuikRectangle Rectangle { get; } /// /// Create a draw rectangle command. /// /// The rectangle to draw. public QuikCommandRectangle(QuikRectangle rectangle) { Rectangle = rectangle; } } /// /// Draw rectangles. /// public sealed class QuikCommandRectangles : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Rectangles; /// /// The rectangles to draw. /// public QuikRectangle[] Rectangles { get; } /// /// Create a draw rectangles commands. /// /// The rectangles to draw. public QuikCommandRectangles(QuikRectangle[] rectangles) { Rectangles = rectangles; } } /// /// Draw an ellipse. /// public sealed class QuikCommandEllipse : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Ellipse; /// /// The ellipse to draw. /// public QuikEllipse Ellipse { get; } /// /// Create a draw ellipse command. /// /// The ellipse to draw. public QuikCommandEllipse(QuikEllipse ellipse) { Ellipse = ellipse; } } /// /// Draw ellipses. /// public sealed class QuikCommandEllipses : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Ellipses; /// /// The ellipses to draw. /// public QuikEllipse[] Ellipses { get; } /// /// Create a draw ellipses command. /// /// The ellipses to draw. public QuikCommandEllipses(QuikEllipse[] ellipses) { Ellipses = ellipses; } } /// /// Create a draw triangle command. /// public sealed class QuikCommandTriangle : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Triangle; /// /// The triangle to draw. /// public QuikTriangle Triangle { get; } /// /// Create a draw triangle command. /// /// The triangles to draw. public QuikCommandTriangle(QuikTriangle triangle) { Triangle = triangle; } } /// /// Draw triangles. /// public sealed class QuikCommandTriangles : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Triangles; /// /// The triangles to draw. /// public QuikTriangle[] Triangles { get; } /// /// Create a draw triangles command. /// /// The triangles to draw. public QuikCommandTriangles(QuikTriangle[] triangles) { Triangles = triangles; } } /// /// Draw a polygon. /// /// Behavior is defined by rendering backend for concave polygons. public sealed class QuikCommandPolygon : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Polygon; /// /// The vertices that make up the polygon. /// public Vector2[] Polygon { get; } /// /// Create a draw polygon command. /// /// The polygon to draw. public QuikCommandPolygon(Vector2[] polygon) { Polygon = polygon; } } /// /// Put a character. /// public sealed class QuikCommandPutChar : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.PutChar; /// /// The character to put. /// /// This field is integer to accomodate for surrogate pairs. public int Character { get; } /// /// The baseline start position of the character. /// public Vector2 Position { get; } /// /// Create a put character command. /// /// The character to put. /// The baseline start position of the character. public QuikCommandPutChar(int character, Vector2 position) { Character = character; Position = position; } /// /// Create a put character command. /// /// The character to put. /// The baseline start position of the character. public QuikCommandPutChar(char character, Vector2 position) : this((int) character, position) { } } /// /// Put some text. /// public sealed class QuikCommandPutText : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.PutText; /// /// The text to put. /// public string Text { get; } /// /// The baseline start position of the text. /// public Vector2 Position { get; } /// /// Create a put text command. /// /// The text to put. /// The baseline start position of the text. public QuikCommandPutText(string text, Vector2 position) { Text = text; Position = position; } } /// /// Flow text into a box. /// public sealed class QuikCommandFlowText : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.FlowText; /// /// The text to flow. /// public string Text { get; } /// /// The flowing box boundaries. /// public QuikRectangle Bounds { get; } /// /// Create a flow text command. /// /// The text to flow. /// The flowing box boundaries. public QuikCommandFlowText(string text, QuikRectangle bounds) { Text = text; Bounds = bounds; } } /// /// Clear the stencil buffer. /// public sealed class QuikCommandStencilClear : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.StencilMaskClear; } /// /// Begin rendering to the stencil buffer. /// public sealed class QuikCommandStencilBegin : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.StencilMaskBegin; } /// /// End rendering to the stencil buffer. /// public sealed class QuikCommandStencilEnd : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.StencilMaskEnd; } /// /// Draw an image. /// public sealed class QuikCommandImage : QuikCommand { /// public override QuikCommandType Type => QuikCommandType.Image; } }