New conversion operators and make some explicit.

This commit is contained in:
H. Utku Maden 2023-05-14 23:30:26 +03:00
parent fc1cc6a1ba
commit 3de9de4e2d

@ -180,21 +180,33 @@ namespace Quik.CommandQueue
_f4 = f4;
}
public T As<T>() where T : class
public T As<T>()
{
return (T)_object;
}
public static implicit operator int(in Frame frame) => frame._i1;
public static implicit operator float(in Frame frame) => frame._f1;
public static implicit operator Command(in Frame frame) => (Command)frame._i1;
public static explicit operator int(in Frame frame) => frame._i1;
public static explicit operator float(in Frame frame) => frame._f1;
public static explicit operator Command(in Frame frame) => (Command)frame._i1;
public static explicit operator QuikVec2(in Frame frame) =>
frame.IsFloat ? new QuikVec2(frame._f1, frame._f2) : new QuikVec2(frame._i1, frame._i2);
public static explicit operator QuikColor(in Frame frame) =>
new QuikColor((byte)frame._i1, (byte)frame._i2, (byte)frame._i3, (byte)frame._i4);
public static explicit operator QuikRectangle(in Frame frame) =>
frame.IsFloat ?
new QuikRectangle(frame._f1, frame._f2, frame._f3, frame._f4) :
new QuikRectangle(frame._i1, frame._i2, frame._i3, frame._i4);
public static explicit operator QuikLine(in Frame frame) =>
frame.IsFloat ?
new QuikLine(frame._f1, frame._f2, frame._f3, frame._f4) :
new QuikLine(frame._i1, frame._i2, frame._i3, frame._i4);
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 QuikVec2 vector) => new Frame(vector.X, vector.Y);
public static implicit operator Frame(in QuikColor color) => new Frame(color.R, color.G, color.B, color.A);
public static implicit operator Frame(in QuikRectangle rect) => new Frame(rect.Min.X, rect.Min.Y, rect.Max.X, rect.Max.Y);
public static implicit operator Frame(in QuikRectangle rect) => new Frame(rect.Max.X, rect.Max.Y, rect.Min.X, rect.Min.Y);
public static implicit operator Frame(in QuikLine line) => new Frame(line.Start.X, line.Start.Y, line.End.X, line.Start.Y);
public static void Create(in QuikBezier bezier, out Frame a, out Frame b)