X-Git-Url: http://git.shiar.nl/wormy.git/blobdiff_plain/2bceba75b8f2b6a2b5b235689bf1e1741845ad77..5b16db3a9d109027d02c3281c8e2b61ec32c13ca:/parse-wormedit diff --git a/parse-wormedit b/parse-wormedit index 721cec8..aa22051 100755 --- a/parse-wormedit +++ b/parse-wormedit @@ -54,7 +54,7 @@ else { if ($opt{output}) {{ # derive format from file extension - if ($opt{output} =~ /\.(yaml|txt)$/) { + if ($opt{output} =~ /\.(yaml|json|txt)$/) { $opt{format} //= $1 } else { @@ -70,6 +70,10 @@ if ($opt{output}) {{ # output with user-preferred formatting given ($opt{format}) { +when ('json') { + require JSON; + say JSON->new->encode($data); +} when ('yaml') { # full data in yaml (human-readable) formatting require YAML; @@ -162,6 +166,10 @@ default { my $img = Games::Wormy::Render->composite( map { $data->{levels}->[$_] } @request ) or die "empty result for levels\n"; + if ($opt{format} ~~ 'pbm') { + $img = $img->to_paletted({make_colors => 'mono'}); + $opt{format} = 'pnm'; + } $img->write( $opt{output} ? (file => $opt{output}) : (fh => \*STDOUT), type => $opt{format} // 'pnm', @@ -197,6 +205,10 @@ Plain text summary of levelpack contents. All parsed data in YAML syntax. +=item json + +Parsed data in JSON syntax. + =item pnm, png, bmp, ... Image drawing of rendered levels.