NAME
Game::FaceGenerator - a web app to combine random images into faces
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 Mojolicious::Lite.
See Mojolicious::Guides for more information.
CONFIGURATION
As a Mojolicious application, it will read a config file called 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 loglevel
key, and if you're not running the server in a terminal, using the logfile
key to set a file.
The random elements for faces are stored in the contrib directory. You can change this directory using the 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 secret
and 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 empty.png.
You can specify the background image to use via the URL parameter empty
. It must name an image in the contrib directory.
Example:
https://campaignwiki.org/face/debug/alex/eyes_dragon?empty=dragon.png
You can specify the background image via the config file, too. There, a given type is assigned a background image:
{
secret => '*a random string*',
users => {
'alex' => '*secret*',
'tuiren' => '*secret*',
},
empty => {
tuiren => {
gnome => 'dwarf.png',
},
alex => {
dragon => 'dragon.png',
elf => 'elf.png',
dwarf => 'dwarf.png',
gnome => 'dwarf.png',
demon => 'demon.png',
},
},
}
As you can see, in a few cases the artists are using a different background image.
Usually, Face Generator uses all the image elements provided both as-is and flipped horizontally. Sometimes, that doesn't work. The dragon
and demon
images, for example, face sideways. You can't just flip elements for these images. Flipping can be prevented using the no_flip
key in the config file.
{
secret => '*a random string*',
users => {
'alex' => '*secret*',
'tuiren' => '*secret*',
},
empty => {
alex => {
dragon => 'dragon.png',
elf => 'elf.png',
dwarf => 'dwarf.png',
gnome => 'dwarf.png',
demon => 'demon.png',
},
tuiren => {
gnome => 'dwarf.png',
},
},
no_flip => {
alex => [
'dragon',
'demon'
],
},
}
For both the empty
and no_flip
key, the value is again a hash reference with the keys being the users specified for the users
key. In the examples above, alex
and tuiren
are users, and both use a different background image for some of their image elements, and one of them has image elements that cannot be flipped.
SEE ALSO
Game::FaceGenerator::Core for the subroutines required.