mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 03:57:29 +00:00
Color member functions
This commit is contained in:
parent
2578dceb42
commit
9e908b3925
@ -105,7 +105,7 @@ pub fn main() anyerror!void {
|
||||
rl.drawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, rl.Color.red);
|
||||
rl.drawRectangle(0, screenHeight - 5, screenWidth, 5, rl.Color.red);
|
||||
|
||||
rl.drawRectangle(10, 10, 250, 113, rl.fade(rl.Color.sky_blue, 0.5));
|
||||
rl.drawRectangle(10, 10, 250, 113, rl.Color.sky_blue.fade(0.5));
|
||||
rl.drawRectangleLines(10, 10, 250, 113, rl.Color.blue);
|
||||
|
||||
rl.drawText("Free 2d camera controls:", 20, 20, 10, rl.Color.black);
|
||||
|
@ -64,7 +64,7 @@ pub fn main() anyerror!void {
|
||||
|
||||
camera.end();
|
||||
|
||||
rl.drawRectangle(10, 10, 220, 70, rl.fade(rl.Color.sky_blue, 0.5));
|
||||
rl.drawRectangle(10, 10, 220, 70, rl.Color.sky_blue.fade(0.5));
|
||||
rl.drawRectangleLines(10, 10, 220, 70, rl.Color.blue);
|
||||
|
||||
rl.drawText("First person camera default controls:", 20, 20, 10, rl.Color.black);
|
||||
|
@ -14,7 +14,7 @@ pub fn main() anyerror!void {
|
||||
|
||||
rl.initWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an outline to a texture");
|
||||
|
||||
const texture: rl.Texture2D = rl.loadTexture("resources/textures/fudesumi.png");
|
||||
const texture: rl.Texture = rl.Texture.init("resources/textures/fudesumi.png");
|
||||
|
||||
const shdrOutline: rl.Shader = rl.loadShader(null, "resources/shaders/glsl330/outline.fs");
|
||||
|
||||
|
@ -16,7 +16,7 @@ pub fn main() anyerror!void {
|
||||
rl.initWindow(screenWidth, screenHeight, "raylib [texture] example - sprite anim");
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
const scarfy: rl.Texture2D = rl.loadTexture("resources/textures/scarfy.png"); // Texture loading
|
||||
const scarfy: rl.Texture = rl.Texture.init("resources/textures/scarfy.png"); // Texture loading
|
||||
|
||||
const position = rl.Vector2.init(350.0, 280.0);
|
||||
var frameRec = rl.Rectangle{ .x = 0.0, .y = 0.0, .width = @intToFloat(f32, @divFloor(scarfy.width, 6)), .height = @intToFloat(f32, scarfy.height) };
|
||||
|
@ -89,6 +89,50 @@ pub const Color = extern struct {
|
||||
pub fn init(r: u8, g: u8, b: u8, a: u8) Color {
|
||||
return Color{ .r = r, .g = g, .b = b, .a = a };
|
||||
}
|
||||
|
||||
pub fn fromNormalized(normalized: Vector4) Color {
|
||||
return rl.colorFromNormalized(normalized);
|
||||
}
|
||||
|
||||
pub fn fromHSV(hue: f32, saturation: f32, value: f32) Color {
|
||||
return rl.colorFromHSV(hue, saturation, value);
|
||||
}
|
||||
|
||||
pub fn fromInt(hexValue: u32) Color {
|
||||
return rl.getColor(hexValue);
|
||||
}
|
||||
|
||||
pub fn fade(self: Color, a: f32) Color {
|
||||
return rl.fade(self, a);
|
||||
}
|
||||
|
||||
pub fn tint(self: Color, t: Color) Color {
|
||||
return rl.colorTint(self, t);
|
||||
}
|
||||
|
||||
pub fn normalize(self: Color) Vector4 {
|
||||
return rl.colorNormalize(self);
|
||||
}
|
||||
|
||||
pub fn brightness(self: Color, factor: f32) Color {
|
||||
return rl.colorBrightness(self, factor);
|
||||
}
|
||||
|
||||
pub fn constrast(self: Color, c: f32) Color {
|
||||
return rl.colorConstrast(self, c);
|
||||
}
|
||||
|
||||
pub fn alpha(self: Color, a: f32) Color {
|
||||
return rl.colorAlpha(self, a);
|
||||
}
|
||||
|
||||
pub fn toInt(self: Color) Color {
|
||||
return rl.colorToInt(self);
|
||||
}
|
||||
|
||||
pub fn toHSV(self: Color) Vector3 {
|
||||
return rl.colorToHSV(self);
|
||||
}
|
||||
};
|
||||
|
||||
pub const Rectangle = extern struct {
|
||||
|
@ -89,6 +89,50 @@ pub const Color = extern struct {
|
||||
pub fn init(r: u8, g: u8, b: u8, a: u8) Color {
|
||||
return Color{ .r = r, .g = g, .b = b, .a = a };
|
||||
}
|
||||
|
||||
pub fn fromNormalized(normalized: Vector4) Color {
|
||||
return rl.colorFromNormalized(normalized);
|
||||
}
|
||||
|
||||
pub fn fromHSV(hue: f32, saturation: f32, value: f32) Color {
|
||||
return rl.colorFromHSV(hue, saturation, value);
|
||||
}
|
||||
|
||||
pub fn fromInt(hexValue: u32) Color {
|
||||
return rl.getColor(hexValue);
|
||||
}
|
||||
|
||||
pub fn fade(self: Color, a: f32) Color {
|
||||
return rl.fade(self, a);
|
||||
}
|
||||
|
||||
pub fn tint(self: Color, t: Color) Color {
|
||||
return rl.colorTint(self, t);
|
||||
}
|
||||
|
||||
pub fn normalize(self: Color) Vector4 {
|
||||
return rl.colorNormalize(self);
|
||||
}
|
||||
|
||||
pub fn brightness(self: Color, factor: f32) Color {
|
||||
return rl.colorBrightness(self, factor);
|
||||
}
|
||||
|
||||
pub fn constrast(self: Color, c: f32) Color {
|
||||
return rl.colorConstrast(self, c);
|
||||
}
|
||||
|
||||
pub fn alpha(self: Color, a: f32) Color {
|
||||
return rl.colorAlpha(self, a);
|
||||
}
|
||||
|
||||
pub fn toInt(self: Color) Color {
|
||||
return rl.colorToInt(self);
|
||||
}
|
||||
|
||||
pub fn toHSV(self: Color) Vector3 {
|
||||
return rl.colorToHSV(self);
|
||||
}
|
||||
};
|
||||
|
||||
pub const Rectangle = extern struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user