37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System;
|
|
using OpenTK.Graphics;
|
|
using OpenTK;
|
|
namespace RecrownedGTK.Types {
|
|
public static class Color4Extensions {
|
|
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 class Vector4Extensions {
|
|
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);
|
|
}
|
|
|
|
}
|
|
} |