Merge pull request #6 from Patreon/luke---style-changes

Luke   style changes
This commit is contained in:
Luke Davis 2016-12-16 11:22:54 -08:00 committed by GitHub
commit 71d8f41444
2 changed files with 12 additions and 13 deletions

View file

@ -1,4 +1,3 @@
// TODO: use query params for these
var Chance = require('chance'); var Chance = require('chance');
var hsl = function (h, s, l) { var hsl = function (h, s, l) {
@ -14,8 +13,8 @@ var Fox = function (IMG_WIDTH, IMG_HEIGHT, seed) {
// head top left corner // head top left corner
// TODO: head headWidth and height // TODO: head headWidth and height
var headWidth = 0.65 * IMG_WIDTH; var headWidth = 0.6 * IMG_WIDTH;
var headHeight = 0.65 * IMG_HEIGHT; var headHeight = 0.6 * IMG_HEIGHT;
var origin = {x: IMG_WIDTH / 2 - headWidth / 2, y: IMG_HEIGHT / 2 - headHeight / 2}; var origin = {x: IMG_WIDTH / 2 - headWidth / 2, y: IMG_HEIGHT / 2 - headHeight / 2};
var kappa = chance.floating({min: 0.2, max: 0.45}) var kappa = chance.floating({min: 0.2, max: 0.45})
@ -74,18 +73,18 @@ var Fox = function (IMG_WIDTH, IMG_HEIGHT, seed) {
var nose = (function (eyes) { var nose = (function (eyes) {
return { return {
x: origin.x + (headWidth/2), x: origin.x + (headWidth/2),
y: (eyes.left.y + 0.3 * (origin.y + headHeight - eyes.left.y)), y: (eyes.left.y + chance.floating({min: 0.2, max: 0.4}) * (origin.y + headHeight - eyes.left.y)),
width: 0.04 * headWidth, width: chance.floating({min: 0.03, max: 0.04}) * headWidth,
height: 0.03 * headWidth height: chance.floating({min: 0.03, max: 0.04}) * headWidth
} }
}(eyes)); }(eyes));
var mouth = (function (nose) { var mouth = (function (nose) {
return { return {
x: origin.x + (headWidth/2), x: origin.x + (headWidth/2),
y: (nose.y + 0.15 * (origin.y + headHeight - nose.y)), y: (nose.y + chance.floating({min: 0.2, max: 0.35}) * (origin.y + headHeight - nose.y)),
width: 0.08 * headWidth, width: chance.floating({min: 0.08, max: 0.15}) * headWidth,
height: 0.04 * headWidth, height: chance.floating({min: 0.03, max: 0.06}) * headWidth,
style: chance.pickone(['smirk', 'cat', 'none']) style: chance.pickone(['smirk', 'cat', 'none'])
} }
}(nose)); }(nose));
@ -107,8 +106,8 @@ var Fox = function (IMG_WIDTH, IMG_HEIGHT, seed) {
color: headColor, color: headColor,
kappa: kappa, kappa: kappa,
maskColor: hsl(hue, saturation, 95), maskColor: hsl(hue, saturation, 95),
maskWidth: chance.integer({min: 0.5 * IMG_WIDTH, max: IMG_WIDTH}), maskWidth: chance.floating({min: 0.5 * IMG_WIDTH, max: IMG_WIDTH}),
maskHeight: chance.integer({min: 1.7 * (IMG_HEIGHT - eyes.left.y), max: 1.85 * (IMG_HEIGHT - eyes.left.y)}) maskHeight: chance.floating({min: 1.7 * (IMG_HEIGHT - eyes.left.y), max: 1.85 * (IMG_HEIGHT - eyes.left.y)})
}, },
ears: ears, ears: ears,
eyes: eyes, eyes: eyes,

View file

@ -29,7 +29,7 @@ var app = express();
app.use(express.static(__dirname + '/images')); app.use(express.static(__dirname + '/images'));
app.get('/', function(req, res) { app.get('/', function(req, res) {
var fileNames = writeFoxesToDisk(200, 200, 30); var fileNames = writeFoxesToDisk(400, 400, 30);
var images = fileNames.map(fileName => '<img src="/' + fileName + '"/>'); var images = fileNames.map(fileName => '<img src="/' + fileName + '"/>');
res.send(images.join('')); res.send(images.join(''));
}); });