mirror of
https://git.sleeping.town/mirrors/foxy-moxy
synced 2024-11-21 11:37:43 +00:00
americanize fox colors
This commit is contained in:
parent
8e7aef421a
commit
5f34b2af88
2 changed files with 29 additions and 9 deletions
16
js/constants/colors.js
Normal file
16
js/constants/colors.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
var head = {
|
||||
brick: [0, 62, 53],
|
||||
yellow: [48, 100, 64]
|
||||
}
|
||||
var bg = {
|
||||
forest: '#006375',
|
||||
green: '#63D6A3',
|
||||
blue: '#358EFF',
|
||||
salmon: '#FF9B7A',
|
||||
coral: '#F96854',
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
head: head,
|
||||
bg: bg
|
||||
};
|
22
js/fox.js
22
js/fox.js
|
@ -1,4 +1,5 @@
|
|||
const Chance = require('chance');
|
||||
const colors = require('./constants/colors.js');
|
||||
|
||||
const hsl = function (h, s, l) {
|
||||
return "hsl(" + h + "," + s + "%, " + l + "%)";
|
||||
|
@ -14,15 +15,22 @@ const Fox = function (IMG_WIDTH, IMG_HEIGHT, seed) {
|
|||
// origin: head top left corner
|
||||
const kappa = chance.floating({min: 0.2, max: 0.45})
|
||||
|
||||
const hue = chance.integer({min: 5, max: 50});
|
||||
const saturation = chance.integer({min: 70, max: 90});
|
||||
const lightness = chance.integer({min: 40, max: 60});
|
||||
const headColor = (function () {
|
||||
const level = chance.floating({min: 0, max: 1});
|
||||
const result = [];
|
||||
const min = colors.head.brick;
|
||||
const max = colors.head.yellow;
|
||||
for (let i=0; i<min.length; i++) {
|
||||
result.push(min[i] + (max[i] - min[i]) * level)
|
||||
}
|
||||
return hsl.apply(null, result)
|
||||
}) ()
|
||||
|
||||
const head = {
|
||||
width: 0.6 * IMG_WIDTH,
|
||||
height: 0.6 * IMG_HEIGHT,
|
||||
kappa: kappa,
|
||||
color: hsl(hue, saturation, lightness)
|
||||
color: headColor,
|
||||
}
|
||||
|
||||
const origin = {x: IMG_WIDTH / 2 - head.width / 2, y: 0.5 * IMG_HEIGHT - head.height / 2};
|
||||
|
@ -98,11 +106,7 @@ const Fox = function (IMG_WIDTH, IMG_HEIGHT, seed) {
|
|||
canvas: {
|
||||
height: IMG_HEIGHT,
|
||||
width: IMG_WIDTH,
|
||||
color: hsl(
|
||||
chance.integer({min:0, max:360}),
|
||||
chance.integer({min:0, max:100}),
|
||||
chance.integer({min:10, max:100})
|
||||
),
|
||||
color: chance.pickone(Object.keys(colors.bg).map(function (key) {return colors.bg[key];}))
|
||||
},
|
||||
head: head,
|
||||
ears: ears,
|
||||
|
|
Loading…
Reference in a new issue