mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
19 lines
447 B
Zig
19 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
|