Game-FaceGenerator
view release on metacpan or search on metacpan
lib/Game/FaceGenerator.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 - a web app to combine random images into faces
=head1 DESCRIPTION
Face Generator is a web application which uses random images to create faces.
On a technical level, Face Generator is a web app based on the Mojolicious
framework. This class in particular uses L<Mojolicious::Lite>.
See L<Mojolicious::Guides> for more information.
=cut
package Game::FaceGenerator;
our $VERSION = 1.04;
use Modern::Perl;
use Mojolicious::Lite;
use File::ShareDir 'dist_dir';
use Game::FaceGenerator::Core qw(
dir no_flip all_artists random_components all_components
all_elements render_components move);
use Cwd;
# Commands for the command line!
push @{app->commands->namespaces}, 'Game::FaceGenerator::Command';
=head1 CONFIGURATION
As a Mojolicious application, it will read a config file called
F<face-generator.conf> in the current directory, if it exists. As the default
log level is 'debug', one use of the config file is to change the log level
using the C<loglevel> key, and if you're not running the server in a terminal,
using the C<logfile> key to set a file.
The random elements for faces are stored in the F<contrib> directory. You can
change this directory using the C<contrib> key. By default, the directory
included with the distribution is used. Thus, if you're a developer, you
probably want to use something like the following to use the files from the
source directory.
{
loglevel => 'debug',
logfile => undef,
contrib => 'share',
};
If you run Face Generator and you have artists contributing face elements, you
might be interested in granting them access to a simple image editing interface.
There, they shift elements up, down, left and right, and so on. In order to
allow this, you can add users to the config file.
If you run the application in production, you should change the c<secret>. This
is used to protect cookies from tampering. The cookie is where people with a
user account store their username and password, so changing the secret is an
additional protection.
Here's an example of how to set up C<secret> and C<users>:
{
secret => '*a random string*',
users => {
'alex' => '*secret*',
'berta' => '*secret*',
},
}
When these users edit images online, Face Generator adds a background image to
makes it easier for artists to decide where elements need to be placed exactly
in relation to everything else. The default background image is F<empty.png>.
You can specify the background image to use via the URL parameter C<empty>. It
must name an image in the F<contrib> directory.
Example:
https://campaignwiki.org/face/debug/alex/eyes_dragon?empty=dragon.png
( run in 2.535 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )