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:...@@ -2,3 +2,4 @@ MIT:
2= https://spdx.org/licenses/MIT2= https://spdx.org/licenses/MIT
3- This3- This
4- git https://github.com/nektro/zig-expect4- git https://github.com/nektro/zig-expect
5- git https://github.com/nektro/zig-extras
sRGB.zig+7-6
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1//! object representing a single color in the sRGB colorspace with channel values from 0-2551//! object representing a single color in the sRGB colorspace with channel values from 0-255
22
3const std = @import("std");3const std = @import("std");
4const extras = @import("extras");
4const Self = @This();5const Self = @This();
5const color = @import("./mod.zig");6const color = @import("./mod.zig");
6const _x = @import("./_x.zig");7const _x = @import("./_x.zig");
...@@ -27,9 +28,9 @@ pub fn initRGB(r: u8, g: u8, b: u8) Self {...@@ -27,9 +28,9 @@ pub fn initRGB(r: u8, g: u8, b: u8) Self {
27pub fn parseHexConst(comptime input: *const [7:0]u8) Self {28pub fn parseHexConst(comptime input: *const [7:0]u8) Self {
28 comptime std.debug.assert(input[0] == '#');29 comptime std.debug.assert(input[0] == '#');
29 return comptime initRGB(30 return comptime initRGB(
30 std.fmt.parseInt(u8, input[1..3], 16) catch unreachable,31 extras.parseDigits(u8, input[1..3], 16) catch unreachable,
31 std.fmt.parseInt(u8, input[3..5], 16) catch unreachable,32 extras.parseDigits(u8, input[3..5], 16) catch unreachable,
32 std.fmt.parseInt(u8, input[5..7], 16) catch unreachable,33 extras.parseDigits(u8, input[5..7], 16) catch unreachable,
33 );34 );
34}35}
3536
...@@ -37,9 +38,9 @@ pub fn parseHex(input: []const u8) Self {...@@ -37,9 +38,9 @@ pub fn parseHex(input: []const u8) Self {
37 std.debug.assert(input.len == 7);38 std.debug.assert(input.len == 7);
38 std.debug.assert(input[0] == '#');39 std.debug.assert(input[0] == '#');
39 return initRGB(40 return initRGB(
40 std.fmt.parseInt(u8, input[1..3], 16) catch unreachable,41 extras.parseDigits(u8, input[1..3], 16) catch unreachable,
41 std.fmt.parseInt(u8, input[3..5], 16) catch unreachable,42 extras.parseDigits(u8, input[3..5], 16) catch unreachable,
42 std.fmt.parseInt(u8, input[5..7], 16) catch unreachable,43 extras.parseDigits(u8, input[5..7], 16) catch unreachable,
43 );44 );
44}45}
4546
zigmod.yml+1
...@@ -4,5 +4,6 @@ main: mod.zig...@@ -4,5 +4,6 @@ main: mod.zig
4license: MIT4license: MIT
5description: Color init and transformation library for Zig5description: Color init and transformation library for Zig
6dependencies:6dependencies:
7 - src: git https://github.com/nektro/zig-extras
7root_dependencies:8root_dependencies:
8 - src: git https://github.com/nektro/zig-expect9 - src: git https://github.com/nektro/zig-expect