mirror of
https://git.sleeping.town/mirrors/foxy-moxy
synced 2024-11-15 00:27:43 +00:00
Chance all the things.
This commit is contained in:
parent
739f2ed2e1
commit
d89133db86
1 changed files with 11 additions and 12 deletions
23
js/fox.js
23
js/fox.js
|
@ -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})
|
||||||
|
|
||||||
|
@ -59,7 +58,7 @@ var Fox = function (IMG_WIDTH, IMG_HEIGHT, seed) {
|
||||||
height: eyeHeight,
|
height: eyeHeight,
|
||||||
width: eyeHeight/2,
|
width: eyeHeight/2,
|
||||||
style: 'ellipse',
|
style: 'ellipse',
|
||||||
// style: chance.pickone(['ellipse', 'smiley']),
|
//style: chance.pickone(['ellipse', 'smiley']),
|
||||||
left: {
|
left: {
|
||||||
x: origin.x + (headWidth/2) - offsetX,
|
x: origin.x + (headWidth/2) - offsetX,
|
||||||
y: origin.y + (headHeight/2) + offsetY
|
y: origin.y + (headHeight/2) + offsetY
|
||||||
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue