authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 22:22:50 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 22:22:50 -07:00
loge7c110f1e082f3e68e25f454d5fd8fb41b8c794b
tree017f58d5ddde5dff4a976cb227ddf53017495c75
parent14e9e3945fb550b52f98f7aae667b7609c5c63f5
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

use extras.parseDigits


3 files changed, 9 insertions(+), 6 deletions(-)

licenses.txt+1
......@@ -2,3 +2,4 @@ MIT:
22= https://spdx.org/licenses/MIT
33- This
44- git https://github.com/nektro/zig-expect
5- git https://github.com/nektro/zig-extras
sRGB.zig+7-6
......@@ -1,6 +1,7 @@
11//! object representing a single color in the sRGB colorspace with channel values from 0-255
22
33const std = @import("std");
4const extras = @import("extras");
45const Self = @This();
56const color = @import("./mod.zig");
67const _x = @import("./_x.zig");
......@@ -27,9 +28,9 @@ pub fn initRGB(r: u8, g: u8, b: u8) Self {
2728pub fn parseHexConst(comptime input: *const [7:0]u8) Self {
2829 comptime std.debug.assert(input[0] == '#');
2930 return comptime initRGB(
30 std.fmt.parseInt(u8, input[1..3], 16) catch unreachable,
31 std.fmt.parseInt(u8, input[3..5], 16) catch unreachable,
32 std.fmt.parseInt(u8, input[5..7], 16) catch unreachable,
31 extras.parseDigits(u8, input[1..3], 16) catch unreachable,
32 extras.parseDigits(u8, input[3..5], 16) catch unreachable,
33 extras.parseDigits(u8, input[5..7], 16) catch unreachable,
3334 );
3435}
3536
......@@ -37,9 +38,9 @@ pub fn parseHex(input: []const u8) Self {
3738 std.debug.assert(input.len == 7);
3839 std.debug.assert(input[0] == '#');
3940 return initRGB(
40 std.fmt.parseInt(u8, input[1..3], 16) catch unreachable,
41 std.fmt.parseInt(u8, input[3..5], 16) catch unreachable,
42 std.fmt.parseInt(u8, input[5..7], 16) catch unreachable,
41 extras.parseDigits(u8, input[1..3], 16) catch unreachable,
42 extras.parseDigits(u8, input[3..5], 16) catch unreachable,
43 extras.parseDigits(u8, input[5..7], 16) catch unreachable,
4344 );
4445}
4546
zigmod.yml+1
......@@ -4,5 +4,6 @@ main: mod.zig
44license: MIT
55description: Color init and transformation library for Zig
66dependencies:
7 - src: git https://github.com/nektro/zig-extras
78root_dependencies:
89 - src: git https://github.com/nektro/zig-expect