mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 22:04:21 +00:00
18 lines
447 B
Zig
18 lines
447 B
Zig
const print = @import("std").debug.print;
|
|
|
|
fn swizzleRgbaToBgra(rgba: [4]u8) [4]u8 {
|
|
// readable swizzling by destructuring
|
|
const r, const g, const b, const a = rgba;
|
|
return .{ b, g, r, a };
|
|
}
|
|
|
|
pub fn main() void {
|
|
const pos = [_]i32{ 1, 2 };
|
|
const x, const y = pos;
|
|
print("x = {}, y = {}\n", .{x, y});
|
|
|
|
const orange: [4]u8 = .{ 255, 165, 0, 255 };
|
|
print("{any}\n", .{swizzleRgbaToBgra(orange)});
|
|
}
|
|
|
|
// exe=succeed
|