recrownedgtk/RecrownedGTK/Types/Extensions.cs

37 lines
1.3 KiB
C#
Raw Normal View History

2020-02-17 02:44:21 +00:00
using System;
using OpenTK.Graphics;
using OpenTK;
namespace RecrownedGTK.Types {
2020-02-22 05:01:43 +00:00
public static class Color4Extensions {
2020-02-17 02:44:21 +00:00
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;
}
2020-02-22 05:01:43 +00:00
}
public static class Vector4Extensions {
2020-02-17 02:44:21 +00:00
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);
}
2020-02-22 05:01:43 +00:00
2020-02-17 02:44:21 +00:00
}
}