Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use v5.14;
- use strict;
- use warnings;
- use List::Util qw(all);
- $/ = '';
- # Read in points and folds
- my @Points = map { my @p = split /,/; {x => $p[0], y => $p[1]} } split(/\n/, <>);
- my @Folds = map { [m#([xy])=(\d+)#] } split(/\n/, <>);
- my %SIZE = (x => 40, y => 6);
- # Prepare (NOT) Space Image Format data
- my @sif = map { [(' ') x $SIZE{x}] } (1 .. $SIZE{y});
- foreach my $pt (@Points) {
- # Transform point until in final image box
- foreach my $fold (@Folds) {
- last if (all { $pt->{$_} < $SIZE{$_} } ('x','y'));
- my ($axis, $line) = @$fold;
- $pt->{$axis} = 2 * $line - $pt->{$axis} if ($pt->{$axis} > $line);
- }
- # Set pixel in SIF file
- $sif[$pt->{y}][$pt->{x}] = '#';
- }
- say @$_ foreach (@sif);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement