Convert snapshot to CSV for faster tests and a smaller dist
[convert-color-husl.git] / snapshot-to-csv
1 #!/usr/bin/perl
2 use v5.14;
3 use warnings;
4
5 use File::Slurp;
6 use JSON::MaybeXS;
7
8 open my $fh, '>', 't/snapshot-rev4.csv';
9 select $fh;
10
11 my %tests = %{decode_json read_file 't/snapshot-rev4.json'};
12 my @colors = qw/xyz luv lch husl huslp/;
13
14 say join ',', qw/rgb8 xyz_x xyz_y xyz_z luv_l luv_u luv_v lch_l lch_c lch_h husl_h husl_s husl_l huslp_h husl_s husl_l/;
15 for my $rgb8 (sort keys %tests) {
16 my @cols = map { @{$tests{$rgb8}{$_}} } @colors;
17 say join ',', substr($rgb8, 1), map { sprintf '%.4f', $_ } @cols;
18 }
This page took 0.023137 seconds and 5 git commands to generate.