Replace QVec2 with OpenTK.Mathematics.Vector2.

This commit is contained in:
H. Utku Maden 2024-07-28 13:50:33 +03:00
parent 1301868269
commit 42782b8a71
21 changed files with 281 additions and 358 deletions

@ -1,11 +1,12 @@
using BlurgText;
using Dashboard.ImmediateDraw;
using OpenTK.Mathematics;
namespace Dashboard.BlurgText
{
public static class BlurgCommand
{
public static void PutBlurgText(this DrawList list, DashboardBlurg blurg, BlurgResult result, QVec2 origin)
public static void PutBlurgText(this DrawList list, DashboardBlurg blurg, BlurgResult result, Vector2 origin)
{
for (int i = 0; i < result.Count; i++)
{
@ -13,8 +14,8 @@ namespace Dashboard.BlurgText
QRectangle pos = new QRectangle()
{
Min = origin + new QVec2(rect.X, rect.Y),
Size = new QVec2(rect.Width, rect.Height)
Min = origin + new Vector2(rect.X, rect.Y),
Size = new Vector2(rect.Width, rect.Height)
};
QRectangle uv = new QRectangle(rect.U1, rect.V1, rect.U0, rect.V0);

@ -4,6 +4,7 @@ using System.IO;
using ReFuel.FreeType;
using Dashboard.Media.Color;
using Dashboard.Media.Font;
using OpenTK.Mathematics;
namespace Dashboard.Media.Defaults
{
@ -40,10 +41,10 @@ namespace Dashboard.Media.Defaults
ref readonly FTGlyphMetrics ftmetrics = ref face.Glyph.Metrics;
metrics = new QGlyphMetrics(codepoint,
new QVec2(ftmetrics.Width/64f, ftmetrics.Height/64f),
new QVec2(ftmetrics.HorizontalBearingX/64f, ftmetrics.HorizontalBearingY/64f),
new QVec2(ftmetrics.VerticalBearingX/64f, ftmetrics.VerticalBearingY/64f),
new QVec2(ftmetrics.HorizontalAdvance/64f, ftmetrics.VerticalAdvance/64f)
new Vector2(ftmetrics.Width/64f, ftmetrics.Height/64f),
new Vector2(ftmetrics.HorizontalBearingX/64f, ftmetrics.HorizontalBearingY/64f),
new Vector2(ftmetrics.VerticalBearingX/64f, ftmetrics.VerticalBearingY/64f),
new Vector2(ftmetrics.HorizontalAdvance/64f, ftmetrics.VerticalAdvance/64f)
);
FT.RenderGlyph(face.Glyph, options.Sdf ? FTRenderMode.Sdf : FTRenderMode.Normal);

@ -2,6 +2,7 @@ using Dashboard.ImmediateDraw;
using Dashboard.Media;
using Dashboard.PAL;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.GraphicsLibraryFramework;
using System;
@ -68,13 +69,13 @@ namespace Dashboard.OpenTK
public void PortSetTitle(IDashHandle port, string title) => ((OpenTKPort)port).Title = title;
public QVec2 PortGetSize(IDashHandle port) => ((OpenTKPort)port).Size;
public Vector2 PortGetSize(IDashHandle port) => ((OpenTKPort)port).Size;
public void PortSetSize(IDashHandle port, QVec2 size) => ((OpenTKPort)port).Size = size;
public void PortSetSize(IDashHandle port, Vector2 size) => ((OpenTKPort)port).Size = size;
public QVec2 PortGetPosition(IDashHandle port) => ((OpenTKPort)port).Position;
public Vector2 PortGetPosition(IDashHandle port) => ((OpenTKPort)port).Position;
public void PortSetPosition(IDashHandle port, QVec2 position) => ((OpenTKPort)port).Position = position;
public void PortSetPosition(IDashHandle port, Vector2 position) => ((OpenTKPort)port).Position = position;
public bool PortIsValid(IDashHandle port) => ((OpenTKPort)port).IsValid;

@ -21,12 +21,12 @@ namespace Dashboard.OpenTK
set => _window.Title = value;
}
public QVec2 Size
public Vector2 Size
{
get
{
Vector2i size = _window.ClientSize;
return new QVec2(size.X, size.Y);
return new Vector2(size.X, size.Y);
}
set
{
@ -36,12 +36,12 @@ namespace Dashboard.OpenTK
_window.Size = size;
}
}
public QVec2 Position
public Vector2 Position
{
get
{
Vector2i location = _window.Location;
return new QVec2(location.X, location.Y);
return new Vector2(location.X, location.Y);
}
set
{
@ -68,7 +68,7 @@ namespace Dashboard.OpenTK
public void Paint(DrawList queue)
{
QRectangle view = new QRectangle(Size, new QVec2(0, 0));
QRectangle view = new QRectangle(Size, new Vector2(0, 0));
_vertexEngine.Reset();
_vertexEngine.ProcessCommands(view, queue);

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Dashboard.ImmediateDraw;
using OpenTK.Mathematics;
namespace Dashboard.Controls
{
@ -52,16 +53,16 @@ namespace Dashboard.Controls
}
// Flows a row of children.
private void FlowRow(List<Control> line, QVec2 offset, QVec2 size, float packedWidth)
private void FlowRow(List<Control> line, Vector2 offset, Vector2 size, float packedWidth)
{
QVec2 pointer = offset;
Vector2 pointer = offset;
pointer.X += hstart();
foreach (Control child in line)
{
child.Position = pointer;
pointer += new QVec2(child.Size.X + hoffset(child), voffset(child));
pointer += new Vector2(child.Size.X + hoffset(child), voffset(child));
}
float hstart()

@ -1,6 +1,7 @@
using Dashboard.ImmediateDraw;
using Dashboard.Media;
using Dashboard.Typography;
using OpenTK.Mathematics;
namespace Dashboard.Controls
{
@ -15,7 +16,7 @@ namespace Dashboard.Controls
{
if (AutoSize)
{
QVec2 size = Typesetter.MeasureHorizontal(Text, TextSize, Font!);
Vector2 size = Typesetter.MeasureHorizontal(Text, TextSize, Font!);
Size = size;
}
}
@ -23,7 +24,7 @@ namespace Dashboard.Controls
protected override void ValidateVisual(DrawList cmd)
{
float padding = Padding;
QVec2 origin = new QVec2(padding, padding);
Vector2 origin = new Vector2(padding, padding);
cmd.TypesetHorizontalDirect(Text, origin, TextSize, Font!);
}

@ -1,6 +1,7 @@
using System;
using Dashboard.ImmediateDraw;
using OpenTK.Mathematics;
namespace Dashboard.Controls
{
@ -9,7 +10,7 @@ namespace Dashboard.Controls
/// </summary>
public abstract class UIBase
{
private QVec2 size;
private Vector2 size;
public UIBase? Parent { get; protected set; }
public string? Id { get; set; }
@ -23,14 +24,14 @@ namespace Dashboard.Controls
}
}
public QVec2 Position { get; set; }
public Vector2 Position { get; set; }
public QVec2 Size
public Vector2 Size
{
get => size;
set
{
QVec2 oldSize = size;
Vector2 oldSize = size;
size = value;
OnResized(this, new ResizedEventArgs(size, oldSize));
@ -52,11 +53,11 @@ namespace Dashboard.Controls
}
}
public QVec2 MaximumSize { get; set; } = new QVec2(-1, -1);
public QVec2 MinimumSize { get; set; } = new QVec2(-1, -1);
public Vector2 MaximumSize { get; set; } = new Vector2(-1, -1);
public Vector2 MinimumSize { get; set; } = new Vector2(-1, -1);
public bool IsMaximumSizeSet => MaximumSize != new QVec2(-1, -1);
public bool IsMinimumSizeSet => MinimumSize != new QVec2(-1, -1);
public bool IsMaximumSizeSet => MaximumSize != new Vector2(-1, -1);
public bool IsMinimumSizeSet => MinimumSize != new Vector2(-1, -1);
public virtual void NotifyEvent(object? sender, EventArgs args)
{
@ -90,10 +91,10 @@ namespace Dashboard.Controls
public class ResizedEventArgs : EventArgs
{
public QVec2 NewSize { get; }
public QVec2 OldSize { get; }
public Vector2 NewSize { get; }
public Vector2 OldSize { get; }
public ResizedEventArgs(QVec2 newSize, QVec2 oldSize)
public ResizedEventArgs(Vector2 newSize, Vector2 oldSize)
{
NewSize = newSize;
OldSize = oldSize;

@ -1,103 +1,9 @@
using OpenTK.Mathematics;
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
namespace Dashboard
{
/// <summary>
/// A 2 dimensional Vector.
/// </summary>
[DebuggerDisplay("({X}, {Y})")]
public struct QVec2
{
public float X;
public float Y;
public float Magnitude => MathF.Sqrt(X * X + Y * Y);
public QVec2(float x, float y)
{
X = x;
Y = y;
}
public QVec2 Normalize() => this * (1.0f / Magnitude);
public float Atan2() => MathF.Atan2(Y, X);
public static QVec2 operator +(QVec2 a, QVec2 b)
{
return new QVec2()
{
X = a.X + b.X,
Y = a.Y + b.Y
};
}
public static QVec2 operator -(QVec2 a)
{
return new QVec2()
{
X = -a.X,
Y = -a.Y
};
}
public static QVec2 operator -(QVec2 a, QVec2 b)
{
return new QVec2()
{
X = a.X - b.X,
Y = a.Y - b.Y
};
}
public static QVec2 operator *(float a, QVec2 b)
{
return new QVec2()
{
X = a * b.X,
Y = a * b.Y
};
}
public static QVec2 operator *(QVec2 a, float b) => b * a;
public static bool operator ==(QVec2 a, QVec2 b) => a.X == b.X && a.Y == b.Y;
public static bool operator !=(QVec2 a, QVec2 b) => a.X != b.X || a.Y != b.Y;
public override bool Equals(object? obj)
{
if (obj is QVec2)
{
return (QVec2) obj == this;
}
else
{
return false;
}
}
public override int GetHashCode()
{
return 63671 * X.GetHashCode() ^ 81083 * Y.GetHashCode();
}
public static float Dot(QVec2 a, QVec2 b)
{
return a.X * b.X + a.Y * b.Y;
}
public override string ToString()
{
return $"({X}; {Y})";
}
public static readonly QVec2 Zero = new QVec2(0, 0);
public static readonly QVec2 UnitX = new QVec2(1, 0);
public static readonly QVec2 UnitY = new QVec2(0, 1);
}
/// <summary>
/// A RGBA color value.
/// </summary>
@ -213,31 +119,31 @@ namespace Dashboard
/// <summary>
/// Segment start point.
/// </summary>
public QVec2 Start;
public Vector2 Start;
/// <summary>
/// Start point control point.
/// </summary>
public QVec2 ControlA;
public Vector2 ControlA;
/// <summary>
/// End point control point.
/// </summary>
public QVec2 ControlB;
public Vector2 ControlB;
/// <summary>
/// Segment end point.
/// </summary>
public QVec2 End;
public Vector2 End;
/// <summary>
/// An approximation of the arc length of the bezier curve, for calculating rasterization resolution.
/// </summary>
public float RasterizationArc =>
0.5f * (End - Start).Magnitude +
0.5f * ((ControlA - Start).Magnitude + (ControlB - ControlA).Magnitude + (End - ControlB).Magnitude);
0.5f * (End - Start).Length +
0.5f * ((ControlA - Start).Length + (ControlB - ControlA).Length + (End - ControlB).Length);
public QBezier(QVec2 start, QVec2 controlA, QVec2 controlB, QVec2 end)
public QBezier(Vector2 start, Vector2 controlA, Vector2 controlB, Vector2 end)
{
Start = start;
ControlA = controlA;
@ -255,10 +161,10 @@ namespace Dashboard
float endX,
float endY)
: this(
new QVec2(startX, startY),
new QVec2(controlAx, controlAy),
new QVec2(controlBx, controlBy),
new QVec2(endX, endY))
new Vector2(startX, startY),
new Vector2(controlAx, controlAy),
new Vector2(controlBx, controlBy),
new Vector2(endX, endY))
{
}
@ -267,7 +173,7 @@ namespace Dashboard
/// </summary>
/// <param name="t">Control parameter (between 0 and 1)</param>
/// <returns>The point on the curve.</returns>
public QVec2 GetBezierPoint(float t)
public Vector2 GetBezierPoint(float t)
{
float T = 1 - t;
return
@ -282,7 +188,7 @@ namespace Dashboard
/// </summary>
/// <param name="t">Control parameter (between 0 and 1)</param>
/// <returns>The tangent curve.</returns>
public QVec2 GetBezierTangent(float t)
public Vector2 GetBezierTangent(float t)
{
float T = 1 - t;
return
@ -290,13 +196,13 @@ namespace Dashboard
3 * T * T * (ControlA - Start) +
6 * T * t * (ControlB - ControlA) +
3 * t * t * (End - ControlB)
).Normalize();
).Normalized();
}
internal QVec2 GetBezierNormal(float t)
internal Vector2 GetBezierNormal(float t)
{
QVec2 tangent = GetBezierTangent(t);
return new QVec2(-tangent.Y, tangent.X);
Vector2 tangent = GetBezierTangent(t);
return new Vector2(-tangent.Y, tangent.X);
}
}
@ -309,14 +215,14 @@ namespace Dashboard
/// <summary>
/// Start point.
/// </summary>
public QVec2 Start;
public Vector2 Start;
/// <summary>
/// End point.
/// </summary>
public QVec2 End;
public Vector2 End;
public QLine(QVec2 start, QVec2 end)
public QLine(Vector2 start, Vector2 end)
{
Start = start;
End = end;
@ -330,14 +236,14 @@ namespace Dashboard
End.Y = endY;
}
public QVec2 Normal()
public Vector2 Normal()
{
QVec2 tangent = Tangent();
return new QVec2(-tangent.Y, tangent.X);
Vector2 tangent = Tangent();
return new Vector2(-tangent.Y, tangent.X);
}
public QVec2 Tangent()
public Vector2 Tangent()
{
return (End - Start).Normalize();
return (End - Start).Normalized();
}
}
@ -350,12 +256,12 @@ namespace Dashboard
/// <summary>
/// Position maximum point.
/// </summary>
public QVec2 Max;
public Vector2 Max;
/// <summary>
/// Position minimum point.
/// </summary>
public QVec2 Min;
public Vector2 Min;
public float Left
{
@ -381,13 +287,13 @@ namespace Dashboard
set => Max.Y = value;
}
public QVec2 Size
public Vector2 Size
{
get => Max - Min;
set => Max = Min + value;
}
public QRectangle(QVec2 max, QVec2 min)
public QRectangle(Vector2 max, Vector2 min)
{
Max = max;
Min = min;
@ -395,18 +301,18 @@ namespace Dashboard
public QRectangle(float r, float b, float l, float t)
{
Max = new QVec2() {X = r, Y = b};
Min = new QVec2() {X = l, Y = t};
Max = new Vector2(r, b);
Min = new Vector2(l, t);
}
public bool Contains(QVec2 point)
public bool Contains(Vector2 point)
{
return
point.X > Left && point.X < Right &&
point.Y > Bottom && point.Y < Top;
}
internal void Translate(in QVec2 offset)
internal void Translate(in Vector2 offset)
{
Min += offset;
Max += offset;
@ -431,17 +337,17 @@ namespace Dashboard
/// <summary>
/// Ellipse center point.
/// </summary>
public QVec2 Center;
public Vector2 Center;
/// <summary>
/// First ellipse axis.
/// </summary>
public QVec2 AxisA;
public Vector2 AxisA;
/// <summary>
/// Second ellipse axis.
/// </summary>
public QVec2 AxisB;
public Vector2 AxisB;
}
/// <summary>
@ -453,17 +359,17 @@ namespace Dashboard
/// <summary>
/// First vertex.
/// </summary>
public QVec2 A;
public Vector2 A;
/// <summary>
/// Second vertex.
/// </summary>
public QVec2 B;
public Vector2 B;
/// <summary>
/// Third vertex.
/// </summary>
public QVec2 C;
public Vector2 C;
}
[DebuggerDisplay("[{M11} {M12} {M13} {M14}; {M21} {M22} {M23} {M24}; {M31} {M32} {M33} {M34}; {M41} {M42} {M43} {M44}]")]

@ -1,4 +1,5 @@
using Dashboard.Media;
using OpenTK.Mathematics;
using System;
using System.Collections;
using System.Collections.Generic;
@ -221,11 +222,11 @@ namespace Dashboard.ImmediateDraw
}
}
public void Polygon(params QVec2[] polygon)
public void Polygon(params Vector2[] polygon)
{
Enqueue(Command.Polygon);
Enqueue((Frame)polygon.Length);
foreach (QVec2 vertex in polygon)
foreach (Vector2 vertex in polygon)
{
Enqueue(vertex);
}

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using OpenTK.Mathematics;
namespace Dashboard.ImmediateDraw
{
@ -281,7 +282,7 @@ namespace Dashboard.ImmediateDraw
return (Command)frame._i1;
}
public static explicit operator QVec2(in Frame frame)
public static explicit operator Vector2(in Frame frame)
{
switch (frame.Type)
{
@ -290,11 +291,11 @@ namespace Dashboard.ImmediateDraw
case FrameType.IVec2:
case FrameType.IVec3:
case FrameType.IVec4:
return new QVec2(frame._i1, frame._i2);
return new Vector2(frame._i1, frame._i2);
case FrameType.Vec2:
case FrameType.Vec3:
case FrameType.Vec4:
return new QVec2(frame._f1, frame._f2);
return new Vector2(frame._f1, frame._f2);
}
}
@ -336,7 +337,7 @@ namespace Dashboard.ImmediateDraw
public static explicit operator Frame(int i) => new Frame(i);
public static explicit operator Frame(float f) => new Frame(f);
public static implicit operator Frame(Command cmd) => new Frame(cmd);
public static implicit operator Frame(in QVec2 vector) => new Frame(vector.X, vector.Y);
public static implicit operator Frame(in Vector2 vector) => new Frame(vector.X, vector.Y);
public static implicit operator Frame(in QColor color) => new Frame(color.R, color.G, color.B, color.A);
public static implicit operator Frame(in QRectangle rect) => new Frame(rect.Max.X, rect.Max.Y, rect.Min.X, rect.Min.Y);
public static implicit operator Frame(in QLine line) => new Frame(line.Start.X, line.Start.Y, line.End.X, line.Start.Y);

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Dashboard.Media.Color;
using OpenTK.Mathematics;
namespace Dashboard.Media.Font
{
@ -131,8 +132,8 @@ namespace Dashboard.Media.Font
src.CopyTo(dst, PointerX, PointerY);
Image.UnlockBits();
QVec2 min = new QVec2((float)PointerX/Image.Width, (float)PointerY/Image.Height);
QVec2 size = new QVec2((float)src.Width/Image.Width, (float)src.Height/Image.Height);
Vector2 min = new Vector2((float)PointerX/Image.Width, (float)PointerY/Image.Height);
Vector2 size = new Vector2((float)src.Width/Image.Width, (float)src.Height/Image.Height);
prototype.Image = Image;
prototype.UVs = new QRectangle(min + size, min);

@ -1,3 +1,5 @@
using OpenTK.Mathematics;
namespace Dashboard.Media
{
/// <summary>
@ -13,29 +15,29 @@ namespace Dashboard.Media
/// <summary>
/// Size of the glyph in units.
/// </summary>
public QVec2 Size { get; }
public Vector2 Size { get; }
/// <summary>
/// Bearing vector for horizontal layout.
/// </summary>
public QVec2 HorizontalBearing { get; }
public Vector2 HorizontalBearing { get; }
/// <summary>
/// Bearing vector for vertical layout.
/// </summary>
public QVec2 VerticalBearing { get; }
public Vector2 VerticalBearing { get; }
/// <summary>
/// Advance vector for vertical and horizontal layouts.
/// </summary>
public QVec2 Advance { get; }
public Vector2 Advance { get; }
public QGlyphMetrics(
int character,
QVec2 size,
QVec2 horizontalBearing,
QVec2 verticalBearing,
QVec2 advance)
Vector2 size,
Vector2 horizontalBearing,
Vector2 verticalBearing,
Vector2 advance)
{
Rune = character;
Size = size;

@ -1,3 +1,4 @@
using OpenTK.Mathematics;
using System;
namespace Dashboard
@ -16,10 +17,10 @@ namespace Dashboard
public struct MouseState
{
public readonly QVec2 AbsolutePosition;
public readonly Vector2 AbsolutePosition;
public readonly MouseButton ButtonsDown;
public MouseState(QVec2 position, MouseButton down)
public MouseState(Vector2 position, MouseButton down)
{
AbsolutePosition = position;
ButtonsDown = down;
@ -28,16 +29,16 @@ namespace Dashboard
public class MouseButtonEventArgs : EventArgs
{
public QVec2 AbsolutePosition { get; }
public Vector2 AbsolutePosition { get; }
public MouseButton Buttons { get; }
public MouseButtonEventArgs(QVec2 position, MouseButton buttons)
public MouseButtonEventArgs(Vector2 position, MouseButton buttons)
{
AbsolutePosition = position;
Buttons = buttons;
}
public QVec2 RelativePosition(QVec2 origin)
public Vector2 RelativePosition(Vector2 origin)
{
return AbsolutePosition - origin;
}
@ -50,18 +51,18 @@ namespace Dashboard
public class MouseMoveEventArgs : EventArgs
{
public QVec2 AbsolutePosition { get; }
public QVec2 LastPosition { get; }
public QVec2 Motion { get; }
public Vector2 AbsolutePosition { get; }
public Vector2 LastPosition { get; }
public Vector2 Motion { get; }
public MouseMoveEventArgs(QVec2 position, QVec2 lastPosition)
public MouseMoveEventArgs(Vector2 position, Vector2 lastPosition)
{
AbsolutePosition = position;
LastPosition = lastPosition;
Motion = position - lastPosition;
}
public QVec2 RelativePosition(QVec2 origin)
public Vector2 RelativePosition(Vector2 origin)
{
return AbsolutePosition - origin;
}

@ -5,6 +5,7 @@ using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using OpenTK.Mathematics;
namespace Dashboard.OpenGL
{
@ -100,7 +101,7 @@ namespace Dashboard.OpenGL
draw.PrepareFrame();
QVec2 size = view.Size;
Vector2 size = view.Size;
QMat4.Orthographic(out QMat4 viewMatrix, view);
GL.Viewport(0, 0, (int)view.Size.X, (int)view.Size.Y);

@ -1,4 +1,5 @@
using Dashboard.ImmediateDraw;
using OpenTK.Mathematics;
using Dashboard.ImmediateDraw;
using Dashboard.Controls;
using System;
using System.Collections.Generic;
@ -22,13 +23,13 @@ namespace Dashboard.PAL
set => platform.PortSetTitle(handle, value);
}
public QVec2 Size
public Vector2 Size
{
get => platform.PortGetSize(handle);
set => platform.PortSetSize(handle, value);
}
public QVec2 Position
public Vector2 Position
{
get => platform.PortGetPosition(handle);
set => platform.PortSetPosition(handle, value);
@ -78,7 +79,7 @@ namespace Dashboard.PAL
list ??= new DrawList();
list.Clear();
UIElement.Bounds = new QRectangle(Size, new QVec2(0,0));
UIElement.Bounds = new QRectangle(Size, new Vector2(0,0));
UIElement.Paint(list);
platform.PortPaint(handle, list);
}

@ -1,6 +1,7 @@
using System;
using Dashboard.ImmediateDraw;
using Dashboard.Media;
using OpenTK.Mathematics;
using System;
namespace Dashboard.PAL
{
@ -45,10 +46,10 @@ namespace Dashboard.PAL
void DestroyPort(IDashHandle port);
string PortGetTitle(IDashHandle port);
void PortSetTitle(IDashHandle port, string title);
QVec2 PortGetSize(IDashHandle port);
void PortSetSize(IDashHandle port, QVec2 size);
QVec2 PortGetPosition(IDashHandle port);
void PortSetPosition(IDashHandle port, QVec2 position);
Vector2 PortGetSize(IDashHandle port);
void PortSetSize(IDashHandle port, Vector2 size);
Vector2 PortGetPosition(IDashHandle port);
void PortSetPosition(IDashHandle port, Vector2 position);
bool PortIsValid(IDashHandle port);
void PortSubscribeEvent(IDashHandle port, EventHandler handler);
void PortUnsubscribeEvent(IDashHandle port, EventHandler handler);

@ -1,3 +1,4 @@
using OpenTK.Mathematics;
using System;
using System.Collections;
using System.Collections.Generic;
@ -182,7 +183,7 @@ namespace Dashboard.Typography
int index = 0;
bool firstLine = true;
QVec2 pen = new QVec2(0, -PreSpace);
Vector2 pen = new Vector2(0, -PreSpace);
while (index < Blocks.Count)
{
@ -264,9 +265,9 @@ namespace Dashboard.Typography
TypesetGroup group,
Queue<HorizontalTextBlock> line,
float interblockWs,
ref QVec2 pen)
ref Vector2 pen)
{
QVec2 penpal = pen;
Vector2 penpal = pen;
while (line.TryDequeue(out HorizontalTextBlock block))
{
@ -396,7 +397,7 @@ namespace Dashboard.Typography
_count = 0;
}
public void Translate(QVec2 offset)
public void Translate(Vector2 offset)
{
BoundingBox.Translate(offset);

@ -1,4 +1,5 @@
using Dashboard.ImmediateDraw;
using OpenTK.Mathematics;
using Dashboard.ImmediateDraw;
using Dashboard.Media;
using System;
using System.Collections.Generic;
@ -74,7 +75,7 @@ namespace Dashboard.Typography
}
}
public static QVec2 MeasureHorizontal(ReadOnlySpan<char> str, float size, QFont font)
public static Vector2 MeasureHorizontal(ReadOnlySpan<char> str, float size, QFont font)
{
var enumerator = new LineEnumerator(str);
@ -99,15 +100,15 @@ namespace Dashboard.Typography
height += lineHeight;
}
return new QVec2(width, height);
return new Vector2(width, height);
}
public static void TypesetHorizontalDirect(this DrawList list, ReadOnlySpan<char> str, QVec2 origin, float size, QFont font)
public static void TypesetHorizontalDirect(this DrawList list, ReadOnlySpan<char> str, Vector2 origin, float size, QFont font)
{
Dictionary<QImage, FontDrawInfo> drawInfo = new Dictionary<QImage, FontDrawInfo>();
var enumerator = new LineEnumerator(str);
QVec2 pen = origin;
Vector2 pen = origin;
while (enumerator.MoveNext())
{
ReadOnlySpan<char> line = enumerator.Current;
@ -126,7 +127,7 @@ namespace Dashboard.Typography
fall = Math.Max(cfall, fall);
}
pen += new QVec2(0, rise);
pen += new Vector2(0, rise);
foreach (Rune r in line.EnumerateRunes())
{
@ -139,7 +140,7 @@ namespace Dashboard.Typography
if (image == null)
{
pen += new QVec2(metrics.Advance.X, 0);
pen += new Vector2(metrics.Advance.X, 0);
continue;
}
@ -152,8 +153,8 @@ namespace Dashboard.Typography
}
QRectangle dest = new QRectangle(
pen + new QVec2(metrics.HorizontalBearing.X + metrics.Size.X, metrics.Size.Y - metrics.HorizontalBearing.Y),
pen + new QVec2(metrics.HorizontalBearing.X, -metrics.HorizontalBearing.Y));
pen + new Vector2(metrics.HorizontalBearing.X + metrics.Size.X, metrics.Size.Y - metrics.HorizontalBearing.Y),
pen + new Vector2(metrics.HorizontalBearing.X, -metrics.HorizontalBearing.Y));
info.rectangles.Add(dest);
info.rectangles.Add(glyph.UVs);

@ -1,3 +1,4 @@
using OpenTK.Mathematics;
using System.Diagnostics;
namespace Dashboard.VertexGenerator
@ -11,12 +12,12 @@ namespace Dashboard.VertexGenerator
/// <summary>
/// Position value.
/// </summary>
public QVec2 Position;
public Vector2 Position;
/// <summary>
/// Texture Coordinates.
/// </summary>
public QVec2 TextureCoordinates;
public Vector2 TextureCoordinates;
/// <summary>
/// Per vertex color value.
@ -34,8 +35,8 @@ namespace Dashboard.VertexGenerator
public float TextureLayer;
public static int PositionOffset => 0;
public static unsafe int TextureCoordinatesOffset => sizeof(QVec2);
public static unsafe int ColorOffset => 2 * sizeof(QVec2);
public static unsafe int TextureCoordinatesOffset => sizeof(Vector2);
public static unsafe int ColorOffset => 2 * sizeof(Vector2);
public static unsafe int ZIndexOffset => ColorOffset + sizeof(QColor);
public static unsafe int TextureLayerOffset => ZIndexOffset + sizeof(int);
public static unsafe int Stride => sizeof(DbVertex);

@ -3,6 +3,7 @@ using System.Collections.Generic;
using Dashboard.ImmediateDraw;
using Dashboard.Media;
using Dashboard.Typography;
using OpenTK.Mathematics;
namespace Dashboard.VertexGenerator
{
@ -128,7 +129,7 @@ namespace Dashboard.VertexGenerator
{
DbVertex vertex = StrokeVertex;
DbVertex a, b, c, d;
QVec2 normal = line.Normal();
Vector2 normal = line.Normal();
float width = Style.StrokeWidth ?? 1;
a = b = c = d = vertex;
@ -148,20 +149,20 @@ namespace Dashboard.VertexGenerator
}
private void GenerateJoint(
in QVec2 center,
in QVec2 prevNormal,
in QVec2 nextNormal,
in Vector2 center,
in Vector2 prevNormal,
in Vector2 nextNormal,
in LineInfo prevInfo,
in LineInfo nextInfo)
{
// Figure out which side needs the joint.
QVec2 meanNormal = 0.5f * (prevNormal + nextNormal);
QVec2 meanTangent = new QVec2(meanNormal.Y, -meanNormal.X);
QVec2 positiveEdge = ((center + nextNormal) - (center + prevNormal)).Normalize();
QVec2 negativeEdge = ((center - nextNormal) - (center - prevNormal)).Normalize();
Vector2 meanNormal = 0.5f * (prevNormal + nextNormal);
Vector2 meanTangent = new Vector2(meanNormal.Y, -meanNormal.X);
Vector2 positiveEdge = ((center + nextNormal) - (center + prevNormal)).Normalized();
Vector2 negativeEdge = ((center - nextNormal) - (center - prevNormal)).Normalized();
float positive, negative;
positive = QVec2.Dot(meanTangent, positiveEdge);
negative = QVec2.Dot(meanNormal, negativeEdge);
positive = Vector2.Dot(meanTangent, positiveEdge);
negative = Vector2.Dot(meanNormal, negativeEdge);
if (positive == negative)
{
@ -173,7 +174,7 @@ namespace Dashboard.VertexGenerator
DbVertex vertex = StrokeVertex;
float radius = Style.StrokeWidth/2 ?? 0.5f;
float arc = MathF.Acos(QVec2.Dot(prevNormal, nextNormal));
float arc = MathF.Acos(Vector2.Dot(prevNormal, nextNormal));
int resolution = GetRoundingResolution(radius, arc);
bool isNegative = positive < negative;
@ -199,10 +200,10 @@ namespace Dashboard.VertexGenerator
float cos = MathF.Cos(angle);
float sin = MathF.Sin(angle);
QVec2 displacement;
Vector2 displacement;
if (isNegative)
{
displacement = new QVec2()
displacement = new Vector2()
{
X = -prevNormal.X * cos + prevNormal.Y * sin,
Y = -prevNormal.X * sin - prevNormal.Y * cos
@ -210,7 +211,7 @@ namespace Dashboard.VertexGenerator
}
else
{
displacement = new QVec2()
displacement = new Vector2()
{
X = nextNormal.X * cos - nextNormal.Y * sin,
Y = nextNormal.X * sin + nextNormal.Y * cos
@ -234,8 +235,8 @@ namespace Dashboard.VertexGenerator
}
private void GenerateCap(
in QVec2 center,
in QVec2 normal,
in Vector2 center,
in Vector2 normal,
in LineInfo info,
bool endCap)
{
@ -262,10 +263,10 @@ namespace Dashboard.VertexGenerator
float cos = MathF.Cos(angle);
float sin = MathF.Sin(angle);
QVec2 displacement;
Vector2 displacement;
if (endCap)
{
displacement = new QVec2()
displacement = new Vector2()
{
X = normal.X * cos + normal.Y * sin,
Y = -normal.X * sin + normal.Y * cos
@ -273,7 +274,7 @@ namespace Dashboard.VertexGenerator
}
else
{
displacement = new QVec2()
displacement = new Vector2()
{
X = normal.X * cos - normal.Y * sin,
Y = normal.X * sin + normal.Y * cos
@ -292,7 +293,7 @@ namespace Dashboard.VertexGenerator
}
private readonly List<QBezier> BezierList = new List<QBezier>();
private void BezierProc(ImmediateDraw.DrawQueue queue)
private void BezierProc(DrawQueue queue)
{
Frame a = queue.Dequeue();
Frame b;
@ -309,10 +310,10 @@ namespace Dashboard.VertexGenerator
BezierList.Add(
new QBezier(
new QVec2(a.GetF(0), a.GetF(1)),
new QVec2(b.GetF(0), b.GetF(1)),
new QVec2(b.GetF(2), b.GetF(3)),
new QVec2(a.GetF(2), a.GetF(3))
new Vector2(a.GetF(0), a.GetF(1)),
new Vector2(b.GetF(0), b.GetF(1)),
new Vector2(b.GetF(2), b.GetF(3)),
new Vector2(a.GetF(2), a.GetF(3))
)
);
}
@ -323,10 +324,10 @@ namespace Dashboard.VertexGenerator
BezierList.Add(
new QBezier(
new QVec2(a.GetF(0), a.GetF(1)),
new QVec2(b.GetF(0), b.GetF(1)),
new QVec2(b.GetF(2), b.GetF(3)),
new QVec2(a.GetF(2), a.GetF(3))
new Vector2(a.GetF(0), a.GetF(1)),
new Vector2(b.GetF(0), b.GetF(1)),
new Vector2(b.GetF(2), b.GetF(3)),
new Vector2(a.GetF(2), a.GetF(3))
)
);
}
@ -370,10 +371,10 @@ namespace Dashboard.VertexGenerator
private LineInfo GenerateBezierSegment(in QBezier bezier)
{
QVec2 startTangent = bezier.GetBezierTangent(0);
QVec2 endTangent = bezier.GetBezierTangent(1);
QVec2 startNormal = new QVec2(-startTangent.Y, startTangent.X).Normalize();
QVec2 endNormal = new QVec2(-endTangent.Y, endTangent.X).Normalize();
Vector2 startTangent = bezier.GetBezierTangent(0);
Vector2 endTangent = bezier.GetBezierTangent(1);
Vector2 startNormal = new Vector2(-startTangent.Y, startTangent.X).Normalized();
Vector2 endNormal = new Vector2(-endTangent.Y, endTangent.X).Normalized();
float width = Style.StrokeWidth ?? 1;
float radius = 0.5f * width;
@ -392,9 +393,9 @@ namespace Dashboard.VertexGenerator
for (int i = 0; i < resolution; i++, index += 2)
{
float t = (i + 1.0f) / resolution;
QVec2 at = bezier.GetBezierTangent(t).Normalize();
QVec2 a = bezier.GetBezierPoint(t);
QVec2 an = radius * new QVec2(-at.Y, at.X);
Vector2 at = bezier.GetBezierTangent(t).Normalized();
Vector2 a = bezier.GetBezierPoint(t);
Vector2 an = radius * new Vector2(-at.Y, at.X);
v.Position = a + an;
DrawQueue.AddVertex(v);
@ -478,16 +479,16 @@ namespace Dashboard.VertexGenerator
// Draw center rectangle.
QVec2 aPos, bPos, cPos, dPos;
Vector2 aPos, bPos, cPos, dPos;
DbVertex v = FillVertex;
aPos = v.Position = new QVec2(rectangle.Left + radius, rectangle.Bottom - radius);
aPos = v.Position = new Vector2(rectangle.Left + radius, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
bPos = v.Position = new QVec2(rectangle.Right - radius, rectangle.Bottom - radius);
bPos = v.Position = new Vector2(rectangle.Right - radius, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
cPos = v.Position = new QVec2(rectangle.Right - radius, rectangle.Top + radius);
cPos = v.Position = new Vector2(rectangle.Right - radius, rectangle.Top + radius);
DrawQueue.AddVertex(v);
dPos = v.Position = new QVec2(rectangle.Left + radius, rectangle.Top + radius);
dPos = v.Position = new Vector2(rectangle.Left + radius, rectangle.Top + radius);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(0); DrawQueue.AddElement(1); DrawQueue.AddElement(2);
@ -498,9 +499,9 @@ namespace Dashboard.VertexGenerator
// Draw south rectangle.
v.Position = new QVec2(rectangle.Left + radius, rectangle.Bottom);
v.Position = new Vector2(rectangle.Left + radius, rectangle.Bottom);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - radius, rectangle.Bottom);
v.Position = new Vector2(rectangle.Right - radius, rectangle.Bottom);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(4); DrawQueue.AddElement(5); DrawQueue.AddElement(1);
@ -508,9 +509,9 @@ namespace Dashboard.VertexGenerator
// Draw east rectangle.
v.Position = new QVec2(rectangle.Right, rectangle.Bottom - radius);
v.Position = new Vector2(rectangle.Right, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right, rectangle.Top + radius);
v.Position = new Vector2(rectangle.Right, rectangle.Top + radius);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(1); DrawQueue.AddElement(6); DrawQueue.AddElement(7);
@ -518,9 +519,9 @@ namespace Dashboard.VertexGenerator
// Draw north rectangle.
v.Position = new QVec2(rectangle.Right - radius, rectangle.Top);
v.Position = new Vector2(rectangle.Right - radius, rectangle.Top);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + radius, rectangle.Top);
v.Position = new Vector2(rectangle.Left + radius, rectangle.Top);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(3); DrawQueue.AddElement(2); DrawQueue.AddElement(8);
@ -528,9 +529,9 @@ namespace Dashboard.VertexGenerator
// Draw west rectangle.
v.Position = new QVec2(rectangle.Left, rectangle.Top + radius);
v.Position = new Vector2(rectangle.Left, rectangle.Top + radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left, rectangle.Bottom - radius);
v.Position = new Vector2(rectangle.Left, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(11); DrawQueue.AddElement(0); DrawQueue.AddElement(3);
@ -547,7 +548,7 @@ namespace Dashboard.VertexGenerator
float xoff = MathF.Cos(theta) * radius;
float yoff = MathF.Sin(theta) * radius;
v.Position = cPos + new QVec2(xoff, yoff);
v.Position = cPos + new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(2); DrawQueue.AddElement(previous); DrawQueue.AddElement((previous = current++));
}
@ -562,7 +563,7 @@ namespace Dashboard.VertexGenerator
float xoff = -MathF.Sin(theta) * radius;
float yoff = MathF.Cos(theta) * radius;
v.Position = dPos + new QVec2(xoff, yoff);
v.Position = dPos + new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(3); DrawQueue.AddElement(previous); DrawQueue.AddElement((previous = current++));
}
@ -577,7 +578,7 @@ namespace Dashboard.VertexGenerator
float xoff = -MathF.Cos(theta) * radius;
float yoff = -MathF.Sin(theta) * radius;
v.Position = aPos + new QVec2(xoff, yoff);
v.Position = aPos + new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(0); DrawQueue.AddElement(previous); DrawQueue.AddElement((previous = current++));
}
@ -592,7 +593,7 @@ namespace Dashboard.VertexGenerator
float xoff = -MathF.Sin(theta) * radius;
float yoff = MathF.Cos(theta) * radius;
v.Position = bPos + new QVec2(xoff, yoff);
v.Position = bPos + new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(1); DrawQueue.AddElement(previous); DrawQueue.AddElement((previous = current++));
}
@ -621,22 +622,22 @@ namespace Dashboard.VertexGenerator
DrawQueue.RestoreOffset();
v.Position = new QVec2(rectangle.Left + stroke, rectangle.Bottom - stroke);
v.Position = new Vector2(rectangle.Left + stroke, rectangle.Bottom - stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - stroke, rectangle.Bottom - stroke);
v.Position = new Vector2(rectangle.Right - stroke, rectangle.Bottom - stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - stroke, rectangle.Top + stroke);
v.Position = new Vector2(rectangle.Right - stroke, rectangle.Top + stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + stroke, rectangle.Top + stroke);
v.Position = new Vector2(rectangle.Left + stroke, rectangle.Top + stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left, rectangle.Bottom);
v.Position = new Vector2(rectangle.Left, rectangle.Bottom);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right, rectangle.Bottom);
v.Position = new Vector2(rectangle.Right, rectangle.Bottom);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right, rectangle.Top);
v.Position = new Vector2(rectangle.Right, rectangle.Top);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left, rectangle.Top);
v.Position = new Vector2(rectangle.Left, rectangle.Top);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(4); DrawQueue.AddElement(5); DrawQueue.AddElement(1); // SSW
@ -674,73 +675,73 @@ namespace Dashboard.VertexGenerator
20: 0 1 2 3
*/
DbVertex v = StrokeVertex;
QVec2 nPos, qPos, tPos, wPos;
Vector2 nPos, qPos, tPos, wPos;
float stroke = Style.StrokeWidth ?? 1.0f;
DrawQueue.RestoreOffset();
// a-b-c-d
v.Position = new QVec2(rectangle.Left + stroke, rectangle.Bottom - stroke);
v.Position = new Vector2(rectangle.Left + stroke, rectangle.Bottom - stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - stroke, rectangle.Bottom - stroke);
v.Position = new Vector2(rectangle.Right - stroke, rectangle.Bottom - stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - stroke, rectangle.Top + stroke);
v.Position = new Vector2(rectangle.Right - stroke, rectangle.Top + stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + stroke, rectangle.Top + stroke);
v.Position = new Vector2(rectangle.Left + stroke, rectangle.Top + stroke);
DrawQueue.AddVertex(v);
// ef-gh-ij-kl
v.Position = new QVec2(rectangle.Left + stroke, rectangle.Bottom);
v.Position = new Vector2(rectangle.Left + stroke, rectangle.Bottom);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + stroke, rectangle.Bottom);
v.Position = new Vector2(rectangle.Left + stroke, rectangle.Bottom);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right, rectangle.Bottom - stroke);
v.Position = new Vector2(rectangle.Right, rectangle.Bottom - stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right, rectangle.Top + stroke);
v.Position = new Vector2(rectangle.Right, rectangle.Top + stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - stroke, rectangle.Top);
v.Position = new Vector2(rectangle.Right - stroke, rectangle.Top);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - stroke, rectangle.Top);
v.Position = new Vector2(rectangle.Right - stroke, rectangle.Top);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left, rectangle.Top + stroke);
v.Position = new Vector2(rectangle.Left, rectangle.Top + stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left, rectangle.Bottom - stroke);
v.Position = new Vector2(rectangle.Left, rectangle.Bottom - stroke);
DrawQueue.AddVertex(v);
// mno
v.Position = new QVec2(rectangle.Left, rectangle.Bottom - radius);
v.Position = new Vector2(rectangle.Left, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
nPos = v.Position = new QVec2(rectangle.Left + radius, rectangle.Bottom - radius);
nPos = v.Position = new Vector2(rectangle.Left + radius, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + radius, rectangle.Bottom);
v.Position = new Vector2(rectangle.Left + radius, rectangle.Bottom);
DrawQueue.AddVertex(v);
// pqr
v.Position = new QVec2(rectangle.Right - radius, rectangle.Bottom);
v.Position = new Vector2(rectangle.Right - radius, rectangle.Bottom);
DrawQueue.AddVertex(v);
qPos = v.Position = new QVec2(rectangle.Right - radius, rectangle.Bottom - radius);
qPos = v.Position = new Vector2(rectangle.Right - radius, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right, rectangle.Bottom - radius);
v.Position = new Vector2(rectangle.Right, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
// stu
v.Position = new QVec2(rectangle.Right, rectangle.Top + radius);
v.Position = new Vector2(rectangle.Right, rectangle.Top + radius);
DrawQueue.AddVertex(v);
tPos = v.Position = new QVec2(rectangle.Right - radius, rectangle.Top + radius);
tPos = v.Position = new Vector2(rectangle.Right - radius, rectangle.Top + radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - radius, rectangle.Top);
v.Position = new Vector2(rectangle.Right - radius, rectangle.Top);
DrawQueue.AddVertex(v);
// vwx
v.Position = new QVec2(rectangle.Left + radius, rectangle.Top);
v.Position = new Vector2(rectangle.Left + radius, rectangle.Top);
DrawQueue.AddVertex(v);
wPos = v.Position = new QVec2(rectangle.Left + radius, rectangle.Top + radius);
wPos = v.Position = new Vector2(rectangle.Left + radius, rectangle.Top + radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left, rectangle.Top + radius);
v.Position = new Vector2(rectangle.Left, rectangle.Top + radius);
DrawQueue.AddVertex(v);
// E
@ -791,7 +792,7 @@ namespace Dashboard.VertexGenerator
float xoff = MathF.Cos(theta) * radius;
float yoff = MathF.Sin(theta) * radius;
v.Position = tPos + new QVec2(xoff, yoff);
v.Position = tPos + new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(19); DrawQueue.AddElement(previous); DrawQueue.AddElement((previous = current++));
}
@ -806,7 +807,7 @@ namespace Dashboard.VertexGenerator
float xoff = -MathF.Sin(theta) * radius;
float yoff = MathF.Cos(theta) * radius;
v.Position = wPos + new QVec2(xoff, yoff);
v.Position = wPos + new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(22); DrawQueue.AddElement(previous); DrawQueue.AddElement((previous = current++));
}
@ -821,7 +822,7 @@ namespace Dashboard.VertexGenerator
float xoff = -MathF.Cos(theta) * radius;
float yoff = -MathF.Sin(theta) * radius;
v.Position = nPos + new QVec2(xoff, yoff);
v.Position = nPos + new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(23); DrawQueue.AddElement(previous); DrawQueue.AddElement((previous = current++));
}
@ -836,7 +837,7 @@ namespace Dashboard.VertexGenerator
float xoff = -MathF.Sin(theta) * radius;
float yoff = MathF.Cos(theta) * radius;
v.Position = qPos + new QVec2(xoff, yoff);
v.Position = qPos + new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(16); DrawQueue.AddElement(previous); DrawQueue.AddElement((previous = current++));
}
@ -867,40 +868,40 @@ namespace Dashboard.VertexGenerator
float innerRadius = radius - stroke;
DrawQueue.RestoreOffset();
v.Position = new QVec2(rectangle.Left + radius, rectangle.Bottom);
v.Position = new Vector2(rectangle.Left + radius, rectangle.Bottom);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - radius, rectangle.Bottom);
v.Position = new Vector2(rectangle.Right - radius, rectangle.Bottom);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - radius, rectangle.Bottom - stroke);
v.Position = new Vector2(rectangle.Right - radius, rectangle.Bottom - stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + radius, rectangle.Bottom - stroke);
v.Position = new Vector2(rectangle.Left + radius, rectangle.Bottom - stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - stroke, rectangle.Bottom - radius);
v.Position = new Vector2(rectangle.Right - stroke, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right, rectangle.Top + radius);
v.Position = new Vector2(rectangle.Right, rectangle.Top + radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right, rectangle.Top + radius);
v.Position = new Vector2(rectangle.Right, rectangle.Top + radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - stroke, rectangle.Bottom - radius);
v.Position = new Vector2(rectangle.Right - stroke, rectangle.Bottom - radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + radius, rectangle.Top + stroke);
v.Position = new Vector2(rectangle.Left + radius, rectangle.Top + stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - radius, rectangle.Top + stroke);
v.Position = new Vector2(rectangle.Right - radius, rectangle.Top + stroke);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Right - radius, rectangle.Top);
v.Position = new Vector2(rectangle.Right - radius, rectangle.Top);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + radius, rectangle.Top);
v.Position = new Vector2(rectangle.Left + radius, rectangle.Top);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left, rectangle.Bottom + radius);
v.Position = new Vector2(rectangle.Left, rectangle.Bottom + radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + stroke, rectangle.Top + radius);
v.Position = new Vector2(rectangle.Left + stroke, rectangle.Top + radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left + stroke, rectangle.Top + radius);
v.Position = new Vector2(rectangle.Left + stroke, rectangle.Top + radius);
DrawQueue.AddVertex(v);
v.Position = new QVec2(rectangle.Left, rectangle.Bottom + radius);
v.Position = new Vector2(rectangle.Left, rectangle.Bottom + radius);
DrawQueue.AddVertex(v);
// S
@ -920,7 +921,7 @@ namespace Dashboard.VertexGenerator
int resolution = GetRoundingResolution(radius, 0.5f * MathF.PI);
int current = 16;
QVec2 center = new QVec2(rectangle.Right - radius, rectangle.Top - radius);
Vector2 center = new Vector2(rectangle.Right - radius, rectangle.Top - radius);
int s1 = 7, s2 = 6;
for (int i = 0; i < resolution - 1; i++)
{
@ -928,9 +929,9 @@ namespace Dashboard.VertexGenerator
float xoff = MathF.Cos(theta);
float yoff = MathF.Sin(theta);
v.Position = center + radius * new QVec2(xoff, yoff);
v.Position = center + radius * new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
v.Position = center + innerRadius * new QVec2(xoff, yoff);
v.Position = center + innerRadius * new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(s1); DrawQueue.AddElement(s2); DrawQueue.AddElement(current + 0);
@ -943,7 +944,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.AddElement(s1); DrawQueue.AddElement(s2); DrawQueue.AddElement(9);
// Draw NW arc
center = new QVec2(rectangle.Left + radius, rectangle.Top - radius);
center = new Vector2(rectangle.Left + radius, rectangle.Top - radius);
s1 = 8; s2 = 11;
for (int i = 0; i < resolution - 1; i++)
{
@ -951,9 +952,9 @@ namespace Dashboard.VertexGenerator
float xoff = -MathF.Sin(theta);
float yoff = MathF.Cos(theta);
v.Position = center + radius * new QVec2(xoff, yoff);
v.Position = center + radius * new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
v.Position = center + innerRadius * new QVec2(xoff, yoff);
v.Position = center + innerRadius * new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(s1); DrawQueue.AddElement(s2); DrawQueue.AddElement(current + 0);
@ -966,7 +967,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.AddElement(s1); DrawQueue.AddElement(s2); DrawQueue.AddElement(14);
// Draw SW arc
center = new QVec2(rectangle.Left + radius, rectangle.Bottom + radius);
center = new Vector2(rectangle.Left + radius, rectangle.Bottom + radius);
s1 = 13; s2 = 12;
for (int i = 0; i < resolution - 1; i++)
{
@ -974,9 +975,9 @@ namespace Dashboard.VertexGenerator
float xoff = -MathF.Cos(theta);
float yoff = -MathF.Sin(theta);
v.Position = center + radius * new QVec2(xoff, yoff);
v.Position = center + radius * new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
v.Position = center + innerRadius * new QVec2(xoff, yoff);
v.Position = center + innerRadius * new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(s1); DrawQueue.AddElement(s2); DrawQueue.AddElement(current + 0);
@ -989,7 +990,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.AddElement(s1); DrawQueue.AddElement(s2); DrawQueue.AddElement(3);
// Draw SW arc
center = new QVec2(rectangle.Right - radius, rectangle.Bottom + radius);
center = new Vector2(rectangle.Right - radius, rectangle.Bottom + radius);
s1 = 2; s2 = 1;
for (int i = 0; i < resolution - 1; i++)
{
@ -997,9 +998,9 @@ namespace Dashboard.VertexGenerator
float xoff = MathF.Sin(theta);
float yoff = -MathF.Cos(theta);
v.Position = center + radius * new QVec2(xoff, yoff);
v.Position = center + radius * new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
v.Position = center + innerRadius * new QVec2(xoff, yoff);
v.Position = center + innerRadius * new Vector2(xoff, yoff);
DrawQueue.AddVertex(v);
DrawQueue.AddElement(s1); DrawQueue.AddElement(s2); DrawQueue.AddElement(current + 0);
@ -1050,20 +1051,20 @@ namespace Dashboard.VertexGenerator
DrawQueue.RestoreOffset();
DbVertex vertex = ImageVertex;
vertex.Position = new QVec2(rect.Left, rect.Top);
vertex.TextureCoordinates = new QVec2(uvs.Left, uvs.Top);
vertex.Position = new Vector2(rect.Left, rect.Top);
vertex.TextureCoordinates = new Vector2(uvs.Left, uvs.Top);
DrawQueue.AddVertex(vertex);
vertex.Position = new QVec2(rect.Left, rect.Bottom);
vertex.TextureCoordinates = new QVec2(uvs.Left, uvs.Bottom);
vertex.Position = new Vector2(rect.Left, rect.Bottom);
vertex.TextureCoordinates = new Vector2(uvs.Left, uvs.Bottom);
DrawQueue.AddVertex(vertex);
vertex.Position = new QVec2(rect.Right, rect.Bottom);
vertex.TextureCoordinates = new QVec2(uvs.Right, uvs.Bottom);
vertex.Position = new Vector2(rect.Right, rect.Bottom);
vertex.TextureCoordinates = new Vector2(uvs.Right, uvs.Bottom);
DrawQueue.AddVertex(vertex);
vertex.Position = new QVec2(rect.Right, rect.Top);
vertex.TextureCoordinates = new QVec2(uvs.Right, uvs.Top);
vertex.Position = new Vector2(rect.Right, rect.Top);
vertex.TextureCoordinates = new Vector2(uvs.Right, uvs.Top);
DrawQueue.AddVertex(vertex);
DrawQueue.AddElement(0); DrawQueue.AddElement(2); DrawQueue.AddElement(3);
@ -1073,7 +1074,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.EndDrawCall();
}
private void Image3d(ImmediateDraw.DrawQueue queue, QImage image, int count)
private void Image3d(DrawQueue queue, QImage image, int count)
{
DrawQueue.StartDrawCall(Viewport, image);
@ -1087,20 +1088,20 @@ namespace Dashboard.VertexGenerator
DbVertex vertex = ImageVertex;
vertex.TextureLayer = layer;
vertex.Position = new QVec2(rect.Top, rect.Left);
vertex.TextureCoordinates = new QVec2(uvs.Top, uvs.Left);
vertex.Position = new Vector2(rect.Top, rect.Left);
vertex.TextureCoordinates = new Vector2(uvs.Top, uvs.Left);
DrawQueue.AddVertex(vertex);
vertex.Position = new QVec2(rect.Bottom, rect.Left);
vertex.TextureCoordinates = new QVec2(uvs.Bottom, uvs.Left);
vertex.Position = new Vector2(rect.Bottom, rect.Left);
vertex.TextureCoordinates = new Vector2(uvs.Bottom, uvs.Left);
DrawQueue.AddVertex(vertex);
vertex.Position = new QVec2(rect.Bottom, rect.Right);
vertex.TextureCoordinates = new QVec2(uvs.Bottom, uvs.Right);
vertex.Position = new Vector2(rect.Bottom, rect.Right);
vertex.TextureCoordinates = new Vector2(uvs.Bottom, uvs.Right);
DrawQueue.AddVertex(vertex);
vertex.Position = new QVec2(rect.Top, rect.Right);
vertex.TextureCoordinates = new QVec2(uvs.Top, uvs.Right);
vertex.Position = new Vector2(rect.Top, rect.Right);
vertex.TextureCoordinates = new Vector2(uvs.Top, uvs.Right);
DrawQueue.AddVertex(vertex);
DrawQueue.AddElement(0); DrawQueue.AddElement(2); DrawQueue.AddElement(3);

@ -1,12 +1,10 @@
using Dashboard;
using Dashboard.ImmediateDraw;
using Dashboard.ImmediateDraw;
using Dashboard.Controls;
using Dashboard.OpenTK;
using Dashboard.Media.Defaults;
using Dashboard.Media;
using Dashboard.PAL;
using Dashboard.BlurgText;
using BlurgText;
using OpenTK.Mathematics;
namespace Dashboard.Demo
{
@ -44,7 +42,7 @@ namespace Dashboard.Demo
result = dblurg.Blurg.BuildString(font!, 12, BlurgColor.White, "Hello World");
}
cmd.PutBlurgText(dblurg, result!, new QVec2(300, 300));
cmd.PutBlurgText(dblurg, result!, new Vector2(300, 300));
cmd.Rectangle(new QRectangle(16, 16, 0, 0));
// Label.Paint(cmd);
}