| 1 | const print = @import("std").debug.print; |
| 2 | |
| 3 | fn swizzleRgbaToBgra(rgba: [4]u8) [4]u8 { |
| 4 | // readable swizzling by destructuring |
| 5 | const r, const g, const b, const a = rgba; |
| 6 | return .{ b, g, r, a }; |
| 7 | } |
| 8 | |
| 9 | pub fn main() void { |
| 10 | const pos = [_]i32{ 1, 2 }; |
| 11 | const x, const y = pos; |
| 12 | print("x = {}, y = {}\n", .{x, y}); |
| 13 | |
| 14 | const orange: [4]u8 = .{ 255, 165, 0, 255 }; |
| 15 | print("{any}\n", .{swizzleRgbaToBgra(orange)}); |
| 16 | } |
| 17 | |
| 18 | // exe=succeed |