diff --git a/DotSDL.sln.DotSettings b/DotSDL.sln.DotSettings
index 46398f0..e3eb136 100644
--- a/DotSDL.sln.DotSettings
+++ b/DotSDL.sln.DotSettings
@@ -108,4 +108,5 @@
True
True
True
- True
\ No newline at end of file
+ True
+ True
\ No newline at end of file
diff --git a/DotSDL/DotSDL.csproj b/DotSDL/DotSDL.csproj
index b27a387..31f203e 100644
--- a/DotSDL/DotSDL.csproj
+++ b/DotSDL/DotSDL.csproj
@@ -16,7 +16,4 @@
True
-
-
-
\ No newline at end of file
diff --git a/DotSDL/Exceptions/InvalidTypeException.cs b/DotSDL/Exceptions/InvalidTypeException.cs
new file mode 100644
index 0000000..1a0c51f
--- /dev/null
+++ b/DotSDL/Exceptions/InvalidTypeException.cs
@@ -0,0 +1,18 @@
+using System;
+
+namespace DotSDL.Exceptions {
+ ///
+ /// This is thrown when an invalid type is used for
+ /// a genetic class or method.
+ ///
+ public class InvalidTypeException : Exception {
+ ///
+ /// Initializes an .
+ ///
+ /// The class or method that was called.
+ /// The invalid type that was passed.
+ /// A message that should be appended to the base message.
+ public InvalidTypeException(string objectName, Type invalidType, string message = "")
+ : base($"{objectName} cannot accept the type {nameof(invalidType)}" + message != "" ? $" ({message})" : "") { }
+ }
+}
diff --git a/DotSDL/Graphics/Canvas.cs b/DotSDL/Graphics/Canvas.cs
index 18ce637..06e41d9 100644
--- a/DotSDL/Graphics/Canvas.cs
+++ b/DotSDL/Graphics/Canvas.cs
@@ -15,6 +15,12 @@ namespace DotSDL.Graphics {
///
protected bool HasTexture { get; set; }
+ ///
+ /// The scaling type that should be used to draw this . This field should not be
+ /// manipulated directly--use instead.
+ ///
+ protected ScalingQuality ScalingQualityValue;
+
///
/// The SDL_Texture that this maintains.
///
@@ -62,6 +68,20 @@ namespace DotSDL.Graphics {
}
}
+ ///
+ /// Determines the method that will be used to scale this sprite when it is plotted to the
+ /// screen.
+ ///
+ public virtual ScalingQuality ScalingQuality {
+ get => ScalingQualityValue;
+ set {
+ ScalingQualityValue = value;
+
+ if(HasTexture)
+ CreateTexture();
+ }
+ }
+
///
/// Sets the section of the that should be drawn. If the size values are set to 0, the
/// will fill as much of its containing object as possible.
@@ -114,6 +134,7 @@ namespace DotSDL.Graphics {
if(Renderer == IntPtr.Zero) return;
DestroyTexture();
+ Hints.SetHint(Hints.RenderScaleQuality, ScalingQuality.ToString());
Texture = Render.CreateTexture(Renderer, SdlPixels.PixelFormatArgb8888, textureAccess, Width, Height);
HasTexture = true;
diff --git a/DotSDL/Graphics/Point.cs b/DotSDL/Graphics/Point.cs
index 657294c..766ac23 100644
--- a/DotSDL/Graphics/Point.cs
+++ b/DotSDL/Graphics/Point.cs
@@ -1,61 +1,67 @@
using DotSDL.Interop.Core;
+using DotSDL.Math.Vector;
namespace DotSDL.Graphics {
///
/// Represents a point in 2D space.
///
- public class Point {
+ public class Point : Vector2 {
///
/// The base structure that this class wraps around.
///
- internal Rect.SdlPoint SdlPoint;
+ internal Rect.SdlPoint SdlPoint => new Rect.SdlPoint { X = X, Y = Y };
///
/// Returns a with the coordinates (1, 1).
///
- public static Point One => new Point(1, 1);
+ public new static Point One => new Point(1, 1);
///
/// Returns a with the coordinates (1, 0).
///
- public static Point UnitX => new Point(1, 0);
+ public new static Point UnitX => new Point(1, 0);
///
/// Returns a with the coordinates (0, 1).
///
- public static Point UnitY => new Point(0, 1);
+ public new static Point UnitY => new Point(0, 1);
///
/// Returns a with the coordinates (0, 0).
///
- public static Point Zero => new Point(0, 0);
+ public new static Point Zero => new Point(0, 0);
///
- /// The X coordinate of the point.
+ /// Creates a new with the coordinates (0, 0).
///
- public int X {
- get => SdlPoint.X;
- set => SdlPoint.X = value;
+ public Point() : this(Zero) { }
+
+ ///
+ /// Creates a new based on an existing .
+ ///
+ /// The to base this new object on.
+ public Point(Point point) {
+ X = point.X;
+ Y = point.Y;
}
///
- /// The Y coordinate of the point.
+ /// Creates a new based on an existing .
///
- public int Y {
- get => SdlPoint.Y;
- set => SdlPoint.Y = value;
+ /// The to based this new object on.
+ public Point(Vector2 vec) {
+ X = vec.X;
+ Y = vec.Y;
}
///
- /// Creates a new .
+ /// Creates a new based on integer coordinates.
///
- /// The X value of the new .
- /// The Y value of the new .
- public Point(int x = 0, int y = 0) {
- SdlPoint = new Rect.SdlPoint {
- X = x,
- Y = y
- };
+ /// The X coordinate of the new .
+ /// The Y coordinate of the new .
+ public Point(int x, int y) {
+ X = x;
+ Y = y;
}
}
}
diff --git a/DotSDL/Graphics/Rectangle.cs b/DotSDL/Graphics/Rectangle.cs
index 432a7cd..879754c 100644
--- a/DotSDL/Graphics/Rectangle.cs
+++ b/DotSDL/Graphics/Rectangle.cs
@@ -52,15 +52,8 @@ namespace DotSDL.Graphics {
/// The width of the new .
/// The height of the new .
public Rectangle(int x, int y, int width, int height) {
- _position = new Point {
- X = x,
- Y = y,
- };
-
- _size = new Point {
- X = width,
- Y = height
- };
+ _position = new Point(x, y);
+ _size = new Point(width, height);
}
}
}
diff --git a/DotSDL/Graphics/SdlWindow.cs b/DotSDL/Graphics/SdlWindow.cs
index 79a1855..6738570 100644
--- a/DotSDL/Graphics/SdlWindow.cs
+++ b/DotSDL/Graphics/SdlWindow.cs
@@ -2,9 +2,7 @@
using DotSDL.Input;
using DotSDL.Interop.Core;
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Runtime.InteropServices;
namespace DotSDL.Graphics {
///
@@ -16,7 +14,8 @@ namespace DotSDL.Graphics {
private readonly IntPtr _window;
private readonly IntPtr _renderer;
- private readonly IntPtr _texture;
+ private IntPtr _texture;
+ private bool _hasTexture;
public readonly Canvas Background;
@@ -25,6 +24,8 @@ namespace DotSDL.Graphics {
private uint _nextVideoUpdate;
private uint _nextGameUpdate;
+ private ScalingQuality _scalingQuality = ScalingQuality.Nearest;
+
/// true if this instance has been destroyed, othersize false.
public bool IsDestroyed { get; set; }
@@ -56,7 +57,7 @@ namespace DotSDL.Graphics {
/// Indicates that the window manager should position the window. To place the window on a specific display, use the function.
public const int WindowPosUndefined = 0x1FFF0000;
- /// Fired when the window's close button is clicked.
+ /// Fired when tboolhe window's close button is clicked.
public event EventHandler Closed;
/// Fired when a key is pressed.
@@ -71,6 +72,16 @@ namespace DotSDL.Graphics {
/// Fired when the window is restored.
public event EventHandler Restored;
+ public ScalingQuality ScalingQuality {
+ get => _scalingQuality;
+ set {
+ _scalingQuality = value;
+
+ if(_hasTexture)
+ CreateTexture();
+ }
+ }
+
///
/// Calculates a value that allows the window to be placed on a specific display, with its exact position determined by the window manager.
///
@@ -95,7 +106,7 @@ namespace DotSDL.Graphics {
}
///
- /// Creates a new .
+ /// Creates a new .readonly
///
/// The text that is displayed on the window's title bar.
/// A representing the starting position of the window. The X and Y coordinates of the Point can be set to or .
@@ -140,20 +151,18 @@ namespace DotSDL.Graphics {
_window = Video.CreateWindow(title, position.X, position.Y, windowWidth, windowHeight, Video.WindowFlags.Hidden);
_renderer = Render.CreateRenderer(_window, -1, Render.RendererFlags.Accelerated);
- // Everything should be kept as nearest *except* for the target texture.
- SetScalingQuality(scalingQuality);
- _texture = Render.CreateTexture(_renderer, Pixels.PixelFormatArgb8888, Render.TextureAccess.Target, textureWidth, textureHeight);
- SetScalingQuality(ScalingQuality.Nearest);
-
- Background = new Canvas(textureWidth, textureHeight) { Renderer = _renderer };
- Background.CreateTexture();
-
WindowWidth = windowWidth;
WindowHeight = windowHeight;
TextureWidth = textureWidth;
TextureHeight = textureHeight;
+ ScalingQuality = scalingQuality;
+ CreateTexture();
+
+ Background = new Canvas(textureWidth, textureHeight) { Renderer = _renderer };
+ Background.CreateTexture();
+
Sprites = new SpriteList(_renderer);
IsDestroyed = false;
@@ -211,6 +220,16 @@ namespace DotSDL.Graphics {
OnUpdate(); // Call the overridden Update function.
}
+ ///
+ /// Creates the rendering target that all of the layers will be drawn to prior to rendering.
+ ///
+ private void CreateTexture() {
+ DestroyTexture();
+ Hints.SetHint(Hints.RenderScaleQuality, ScalingQuality.ToString());
+ _texture = Render.CreateTexture(_renderer, Pixels.PixelFormatArgb8888, Render.TextureAccess.Target, TextureWidth, TextureHeight);
+ _hasTexture = true;
+ }
+
///
/// Destroys this .
///
@@ -219,6 +238,16 @@ namespace DotSDL.Graphics {
IsDestroyed = true;
}
+ ///
+ /// Destroys the render target associated with this .
+ ///
+ private void DestroyTexture() {
+ if(!_hasTexture) return;
+
+ Render.DestroyTexture(_texture);
+ _hasTexture = false;
+ }
+
///
/// Plots the sprites stored in to the screen. Please note that this method is called by
/// DotSDL's drawing routines and does not need to be called manually. Additionally, this method will not be
@@ -227,8 +256,6 @@ namespace DotSDL.Graphics {
public virtual void DrawSprites() {
Render.SetRenderTarget(_renderer, _texture);
foreach(var sprite in Sprites.Where(e => e.Shown).OrderBy(e => e.ZOrder)) {
- SetScalingQuality(sprite.ScalingQuality);
-
var srcRect = sprite.Clipping.SdlRect;
var drawSize = new Point(
(int)(srcRect.W * sprite.Scale.X),
@@ -360,15 +387,6 @@ namespace DotSDL.Graphics {
///
protected virtual void OnUpdate() { }
- ///
- /// Sets the scaling/filter quality. This is set globally within SDL, so
- /// for correctness sake it should be called before every texture is created.
- ///
- ///
- private void SetScalingQuality(ScalingQuality quality) {
- Hints.SetHint(Hints.RenderScaleQuality, quality.ToString());
- }
-
///
/// Displays the window and begins executing code that's associated with it.
///
diff --git a/DotSDL/Graphics/Sprite.cs b/DotSDL/Graphics/Sprite.cs
index 678d331..2bf2ecb 100644
--- a/DotSDL/Graphics/Sprite.cs
+++ b/DotSDL/Graphics/Sprite.cs
@@ -1,6 +1,6 @@
using DotSDL.Interop.Core;
+using DotSDL.Math.Vector;
using SdlPixels = DotSDL.Interop.Core.Pixels;
-using System.Numerics;
namespace DotSDL.Graphics {
///
@@ -16,7 +16,7 @@ namespace DotSDL.Graphics {
/// The angle that the sprite is drawn, in degrees. Incrementing this will rotate the
/// sprite clockwise.
///
- public double Rotation { get; set; }
+ public float Rotation { get; set; }
///
/// The point around which the sprite will be rotated. By default, this will be set to
@@ -32,13 +32,20 @@ namespace DotSDL.Graphics {
///
/// The scale of the . 1.0f is 100%.
///
- public Vector2 Scale { get; set; }
+ public Vector2 Scale { get; set; }
- ///
- /// Determines the method that will be used to scale this sprite when it is plotted to the
- /// screen.
- ///
- public ScalingQuality ScalingQuality { get; set; }
+ ///
+ public override ScalingQuality ScalingQuality {
+ get => ScalingQualityValue;
+ set {
+ ScalingQualityValue = value;
+
+ if(HasTexture) {
+ CreateTexture();
+ UpdateTexture();
+ }
+ }
+ }
///
/// true if the sprite should be drawn to the screen, otherwise false.
@@ -56,15 +63,15 @@ namespace DotSDL.Graphics {
///
/// The width of the new .
/// The height of the new .
- public Sprite(int width, int height) : this(width, height, Point.Zero, Vector2.One, 0) { }
+ public Sprite(int width, int height) : this(width, height, Point.Zero, Vector2.One, 0) { }
///
/// Initializes a new .
///
/// The width of the new .
/// The height of the new .
- /// A representing the initial position of the new .
- public Sprite(int width, int height, Point position) : this(width, height, position, Vector2.One, 0) { }
+ /// A representing the initial position of the new .
+ public Sprite(int width, int height, Point position) : this(width, height, position, Vector2.One, 0) { }
///
/// Initializes a new .
@@ -73,37 +80,37 @@ namespace DotSDL.Graphics {
/// The height of the new .
/// A value indicating the order in which this is drawn. Higher numbered
/// sprites are drawn on top of other sprites and, thus, will appear above them.
- public Sprite(int width, int height, int zOrder) : this(width, height, Point.Zero, Vector2.One, zOrder) { }
+ public Sprite(int width, int height, int zOrder) : this(width, height, Point.Zero, Vector2.One, zOrder) { }
///
/// Initializes a new .
///
/// The width of the new .
/// The height of the new .
- /// A representing the initial position of the new .
- /// A representing the initial scaling of the new .
- public Sprite(int width, int height, Point position, Vector2 scale) : this(width, height, position, scale, 0) { }
+ /// A representing the initial position of the new .
+ /// A representing the initial scaling of the new .
+ public Sprite(int width, int height, Point position, Vector2 scale) : this(width, height, position, scale, 0) { }
///
/// Initializes a new .
///
/// The width of the new .
/// The height of the new .
- /// A representing the initial position of the new .
+ /// A representing the initial position of the new .
/// A value indicating the order in which this is drawn. Higher numbered
/// sprites are drawn on top of other sprites and, thus, will appear above them.
- public Sprite(int width, int height, Point position, int zOrder) : this(width, height, position, Vector2.One, 0) { }
+ public Sprite(int width, int height, Point position, int zOrder) : this(width, height, position, Vector2.One, 0) { }
///
/// Initializes a new .
///
/// The width of the new .
/// The height of the new .
- /// A representing the initial position of the new .
- /// A representing the initial scaling of the new .
+ /// A representing the initial position of the new .
+ /// A representing the initial scaling of the new .
/// A value indicating the order in which this is drawn. Higher numbered
/// sprites are drawn on top of other sprites and, thus, will appear above them.
- public Sprite(int width, int height, Point position, Vector2 scale, int zOrder)
+ public Sprite(int width, int height, Point position, Vector2 scale, int zOrder)
: this(width, height, position, new Rectangle(0, 0, width, height), scale, zOrder) { }
///
@@ -111,12 +118,12 @@ namespace DotSDL.Graphics {
///
/// The width of the new .
/// The height of the new .
- /// A representing the initial position of the new .
- /// A representing the initial scaling of the new .
+ /// A representing the initial position of the new .
+ /// A representing the initial scaling of the new .
/// A rectangle specifying which part of this should be drawn.
/// A value indicating the order in which this is drawn. Higher numbered
/// sprites are drawn on top of other sprites and, thus, will appear above them.
- public Sprite(int width, int height, Point position, Rectangle clipping, Vector2 scale, int zOrder) : base(width, height, clipping) {
+ public Sprite(int width, int height, Point position, Rectangle clipping, Vector2 scale, int zOrder) : base(width, height, clipping) {
Position = position;
Scale = scale;
ZOrder = zOrder;
diff --git a/DotSDL/Math/Vector/Vector2.cs b/DotSDL/Math/Vector/Vector2.cs
new file mode 100644
index 0000000..d16779b
--- /dev/null
+++ b/DotSDL/Math/Vector/Vector2.cs
@@ -0,0 +1,112 @@
+using DotSDL.Exceptions;
+using System;
+using System.Collections.Generic;
+
+namespace DotSDL.Math.Vector {
+ ///
+ /// Represents a generic vector type.
+ ///
+ public class Vector2 : IEquatable> {
+ public T X { get; set; }
+ public T Y { get; set; }
+
+ ///
+ /// Initializes a new object.
+ ///
+ /// Thrown if this is created with an unsupported type.
+ public Vector2() {
+ if(!VectorBase.IsNumericType())
+ throw new InvalidTypeException(GetType().ToString(), typeof(T));
+ }
+
+ ///
+ /// Initializes a new object using the values from another .
+ ///
+ /// The that should be used to initialize the new object.
+ /// Thrown if this is created with an unsupported type.
+ public Vector2(Vector2 initialValue) : this() {
+ X = initialValue.X;
+ Y = initialValue.Y;
+ }
+
+ ///
+ /// Initializes a new object with the X and Y values both set to a given value.
+ ///
+ /// The value to initialize the X and Y values to.
+ /// Thrown if this is created with an unsupported type.
+ public Vector2(T initialValue) : this() {
+ X = Y = initialValue;
+ }
+
+ ///
+ /// Initializes a new object with preset X and Y values.
+ ///
+ /// The initial value to set the X component to.
+ /// The initial value to set the Y component to.
+ /// Thrown if this is created with an unsupported type.
+ public Vector2(T initialX, T initialY) : this() {
+ X = initialX;
+ Y = initialY;
+ }
+
+ ///
+ /// Checks to see if two objects are equal.
+ ///
+ /// The first in the comparison.
+ /// The second in the comparison.
+ /// true if the two objects are equal, otherwise false.
+ public static bool operator ==(Vector2 left, Vector2 right) {
+ if(left is null && right is null) return true;
+ if(left is null || right is null) return false;
+ if(left.GetType() != right.GetType()) return false;
+
+ return left.X.Equals(right.X) && left.Y.Equals(right.Y);
+ }
+
+ ///
+ /// Checks to see if two objects are different.
+ ///
+ /// The first in the comparison.
+ /// The second in the comparison.
+ /// true if the two objects are different, otherwise false.
+ public static bool operator !=(Vector2 left, Vector2 right) {
+ return !(left == right);
+ }
+
+ /// Returns a new with both X and Y set to 1.
+ public static Vector2 One => new Vector2(VectorBase.GetOne());
+
+ /// Returns a new containing (1, 0).
+ public static Vector2 UnitX => new Vector2(VectorBase.GetOne(), VectorBase.GetZero());
+
+ /// Returns a new containing (0, 1).
+ public static Vector2 UnitY => new Vector2(VectorBase.GetZero(), VectorBase.GetOne());
+
+ /// Returns a new with both X and Y set to 0.
+ public static Vector2 Zero => new Vector2(VectorBase.GetZero());
+
+ ///
+ public bool Equals(Vector2 other) {
+ if(ReferenceEquals(null, other)) return false;
+ if(ReferenceEquals(this, other)) return true;
+ return EqualityComparer.Default.Equals(X, other.X) && EqualityComparer.Default.Equals(Y, other.Y);
+ }
+
+ ///
+ /// Determines whether this is equal to another one.
+ ///
+ /// Another to compare this instance to.
+ /// true if the two objects are equal, otherwise false.
+ public override bool Equals(object obj) {
+ if(!(obj is Vector2)) return false;
+ return this == (Vector2)obj;
+ }
+
+ ///
+ public override int GetHashCode() {
+ unchecked {
+ return (EqualityComparer.Default.GetHashCode(X) * 397) ^ EqualityComparer.Default.GetHashCode(Y);
+ }
+ }
+ }
+}
diff --git a/DotSDL/Math/Vector/VectorSupport.cs b/DotSDL/Math/Vector/VectorSupport.cs
new file mode 100644
index 0000000..156e548
--- /dev/null
+++ b/DotSDL/Math/Vector/VectorSupport.cs
@@ -0,0 +1,158 @@
+using DotSDL.Exceptions;
+using System.Runtime.CompilerServices;
+
+namespace DotSDL.Math.Vector {
+ ///
+ /// A class containing static functions that support the implemented vector types.
+ ///
+ /// The type of the vector that should be supported..
+ internal static class VectorBase {
+ ///
+ /// Retrieves a one value in one of the supported types.
+ ///
+ /// A one value in one of the supported types.
+ /// Thrown if a non-numeric or unsupported type is passed.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal static T GetOne() {
+ if(typeof(T) == typeof(sbyte)) {
+ const sbyte val = 1;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(byte)) {
+ const byte val = 1;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(short)) {
+ const short val = 1;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(ushort)) {
+ const ushort val = 1;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(int)) {
+ const int val = 1;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(uint)) {
+ const uint val = 1;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(long)) {
+ const long val = 1;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(ulong)) {
+ const ulong val = 1;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(float)) {
+ const float val = 1.0f;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(double)) {
+ const double val = 1.0d;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(decimal)) {
+ const decimal val = 1.0m;
+ return (T)(object)val;
+ }
+
+ throw new InvalidTypeException("VectorBase.GetOne()", typeof(T));
+ }
+
+ ///
+ /// Retrieves a zero value in one of the supported types.
+ ///
+ /// A zero value in one of the supported types.
+ /// Thrown if a non-numeric or unsupported type is passed.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal static T GetZero() {
+ if(typeof(T) == typeof(sbyte)) {
+ const sbyte val = 0;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(byte)) {
+ const byte val = 0;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(short)) {
+ const short val = 0;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(ushort)) {
+ const ushort val = 0;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(int)) {
+ const int val = 0;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(uint)) {
+ const uint val = 0;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(long)) {
+ const long val = 0;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(ulong)) {
+ const ulong val = 0;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(float)) {
+ const float val = 0.0f;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(double)) {
+ const double val = 0.0d;
+ return (T)(object)val;
+ }
+
+ if(typeof(T) == typeof(decimal)) {
+ const decimal val = 0.0m;
+ return (T)(object)val;
+ }
+
+ throw new InvalidTypeException("VectorBase.GetZero()", typeof(T));
+ }
+
+ ///
+ /// Determines whether or not the desired type is a valid and supported numeric type.
+ ///
+ /// type if the value is a supported numeric type, otherwise false.
+ internal static bool IsNumericType() {
+ return typeof(T) == typeof(sbyte)
+ || typeof(T) == typeof(byte)
+ || typeof(T) == typeof(short)
+ || typeof(T) == typeof(ushort)
+ || typeof(T) == typeof(int)
+ || typeof(T) == typeof(uint)
+ || typeof(T) == typeof(long)
+ || typeof(T) == typeof(ulong)
+ || typeof(T) == typeof(float)
+ || typeof(T) == typeof(double)
+ || typeof(T) == typeof(decimal);
+ }
+ }
+}
diff --git a/Samples/Sample.Sprites/Window.cs b/Samples/Sample.Sprites/Window.cs
index 79c7719..626c253 100644
--- a/Samples/Sample.Sprites/Window.cs
+++ b/Samples/Sample.Sprites/Window.cs
@@ -2,6 +2,7 @@
using DotSDL.Graphics;
using DotSDL.Input.Keyboard;
using System;
+using System.Numerics;
namespace Sample.Sprites {
public class Window : SdlWindow {
@@ -10,7 +11,7 @@ namespace Sample.Sprites {
private Point _player1Delta, _player2Delta;
public Window(int scale) : base("Sprites Test",
- new Point { X = WindowPosUndefined, Y = WindowPosUndefined },
+ new Point(WindowPosUndefined, WindowPosUndefined),
256 * scale, 196 * scale,
256, 196) {
KeyPressed += OnKeyPressed;
@@ -87,6 +88,11 @@ namespace Sample.Sprites {
_player2.Position.Y = 24;
_player2Delta = new Point();
+ _player1.Scale.X = 1.5f;
+
+ _player2.ScalingQuality = ScalingQuality.Linear;
+ _player2.Scale.Y = 2.0f;
+
Sprites.Add(_player1);
Sprites.Add(_player2);
}