Files renamed to RecrownedGTK.

This commit is contained in:
2020-02-16 21:44:21 -05:00
parent 2c62be1c6b
commit dee5f96ea7
69 changed files with 5891 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
using System;
using OpenTK.Graphics;
using OpenTK;
namespace RecrownedGTK.Types {
public static class Color4Ext {
public static byte GetRedAsByte(this Color4 color) {
return (byte) (color.R * Byte.MaxValue);
}
public static byte GetGreenAsByte(this Color4 color) {
return (byte) (color.G * Byte.MaxValue);
}
public static byte GetBlueAsByte(this Color4 color) {
return (byte) (color.B * Byte.MaxValue);
}
public static byte GetAlphaAsByte(this Color4 color) {
return (byte) (color.A * Byte.MaxValue);
}
public static void MultiplyByFloat(this Color4 color, float val) {
color.A *= val;
color.R *= val;
color.G *= val;
color.B *= val;
}
public static Color4 ReturnMultipliedByFloat(this Color4 color, float val) {
Color4 output = new Color4(color.R * val, color.G * val, color.B * val, color.A * val);
return output;
}
public static void FromNonPremultiplied(ref Vector4 vector) {
//Premultiplied.
vector = new Vector4(vector.W * vector.X, vector.W * vector.Y, vector.W * vector.Z, vector.W);
}
}
}

View File

@@ -0,0 +1,17 @@
using RecrownedGTK.Graphics.Render;
namespace RecrownedGTK.Types
{
/// <summary>
/// A wrapper that makes sure anything implementing can be drawn with options.
/// </summary>
public interface IRectangleDrawable
{
byte[] ColorData {
get;
}
float[] vertices {
get;
}
}
}

View File

@@ -0,0 +1,24 @@
namespace RecrownedGTK.Types
{
public struct Rectangle
{
public int Width {set; get;}
public int Height {set; get;}
public int X {set; get;}
public int Y {set; get;}
public int Area {
get {
return Width * Height;
}
}
public Rectangle(int x, int y, int width, int height) {
Width = width;
Height = height;
X = x;
Y = y;
}
}
}

View File

@@ -0,0 +1,54 @@
using System;
namespace RecrownedGTK.Types
{
/// <summary>
/// Holds a width and height while allowing for easier comparison between other <see cref="Resolution"/>s.
/// </summary>
public struct Resolution : IComparable<Resolution>
{
/// <summary>
/// Dimensions of resolution.
/// </summary>
public int Width, Height;
/// <summary>
/// Constructs resolution given the dimensions.
/// </summary>
/// <param name="width">Width of resolution.</param>
/// <param name="height">Height of resolution.</param>
public Resolution(int width, int height)
{
Width = width;
Height = height;
}
/// <summary>
/// Compares area of this resolution to another.
/// </summary>
/// <param name="other">The other resolution to compare to.</param>
/// <returns>A value less than 0 for this being the smaller resolution, 0 for the two being the same in area, and larger for this being the larger in area.</returns>
public int CompareTo(Resolution other)
{
return Area() - other.Area();
}
/// <summary>
/// Gets a string representation of this resolution.
/// </summary>
/// <returns>"WidthxHeight"</returns>
public override string ToString()
{
return Width + "x" + Height;
}
/// <summary>
/// Calculates area of resolution.
/// </summary>
/// <returns>Area of resolution.</returns>
public int Area()
{
return Width * Height;
}
}
}