Game-FaceGenerator
view release on metacpan or search on metacpan
lib/Game/FaceGenerator/Core.pm view on Meta::CPAN
#!/usr/bin/env perl
# Copyright (C) 2015-2018 Alex Schroeder <alex@gnu.org>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
=encoding utf8
=head1 NAME
Game::FaceGenerator::Core - support for the Face Generator application
=head1 DESCRIPTION
Face Generator is a web application which uses random images to create faces.
This module provides the subroutines that L<Game::FaceGenerator> needs.
=cut
package Game::FaceGenerator::Core;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(dir no_flip all_artists random_components all_components all_elements render_components move);
use Modern::Perl;
use File::ShareDir qw(dist_dir);
use File::Slurper qw(read_dir read_text read_binary write_binary);
use List::Util 'any';
use Cwd;
use GD;
sub member {
my $element = shift;
foreach (@_) {
return 1 if $element eq $_;
}
}
sub one {
my $i = int(rand(scalar @_));
return $_[$i];
}
my $dir;
sub dir {
$dir = shift;
}
my $no_flip;
sub no_flip {
my $arg = shift;
if (ref $arg) {
$no_flip = $arg;
} elsif ($arg and $no_flip->{$arg}) {
@{$no_flip->{$arg}};
} else {
();
}
}
=head1 ARTISTS
The F<contrib> directory contains background images like F<empty.png> (default
human), F<elf.png> (narrower), F<dwarf.png> (rounder), F<demon.png> (looking
half left, with horns), F<dragon.png> (looking left), and the artist
directories.
Each artist directory must contain a F<README.md> file. The first Markdown link
of the form C<[name](URL)> is used to name the artist and link to their presence
on the web. The first Markdown emphasized text of the form C<*title*> is used as
the title for the collection. This can be useful if an artist has two different
collections. Take Alex Schroeder, who started out as âalexâ. Then a second
collection is added, and called âalex2â. Itâs still the same person, so the two
F<README.md> files both contain the link C<[Alex
Schroeder](https://alexschroeder.ch/)>, and the first one contains the title
C<*Blau*> and the second one contains the title C<*Tablet*>.
=cut
my %artists;
=head1 METHODS
( run in 0.662 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )