mirror of
https://git.sleeping.town/mirrors/foxy-moxy
synced 2024-11-24 04:57:42 +00:00
mouth and cancel eyes
This commit is contained in:
parent
b4d13dccc4
commit
9497ef36f7
2 changed files with 35 additions and 4 deletions
15
js/fox.js
15
js/fox.js
|
@ -54,7 +54,8 @@ var Fox = function (IMG_WIDTH, IMG_HEIGHT) {
|
||||||
return {
|
return {
|
||||||
height: eyeHeight,
|
height: eyeHeight,
|
||||||
width: eyeHeight/2,
|
width: eyeHeight/2,
|
||||||
style: chance.pickone(['ellipse', 'smiley']),
|
style: 'ellipse',
|
||||||
|
// 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
|
||||||
|
@ -75,6 +76,16 @@ var Fox = function (IMG_WIDTH, IMG_HEIGHT) {
|
||||||
}
|
}
|
||||||
}(eyes));
|
}(eyes));
|
||||||
|
|
||||||
|
var mouth = (function (nose) {
|
||||||
|
return {
|
||||||
|
x: origin.x + (headWidth/2),
|
||||||
|
y: (nose.y + 0.15 * (origin.y + headHeight - nose.y)),
|
||||||
|
width: 0.08 * headWidth,
|
||||||
|
height: 0.04 * headWidth,
|
||||||
|
style: chance.pickone(['smirk', 'cat'])
|
||||||
|
}
|
||||||
|
}(nose));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
canvas: {
|
canvas: {
|
||||||
height: IMG_HEIGHT,
|
height: IMG_HEIGHT,
|
||||||
|
@ -98,7 +109,7 @@ var Fox = function (IMG_WIDTH, IMG_HEIGHT) {
|
||||||
ears: ears,
|
ears: ears,
|
||||||
eyes: eyes,
|
eyes: eyes,
|
||||||
nose: nose,
|
nose: nose,
|
||||||
// mouth: mouth
|
mouth: mouth
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
24
server.js
24
server.js
|
@ -52,6 +52,7 @@ var renderFox = function (canvas, opts) {
|
||||||
// draw nose
|
// draw nose
|
||||||
renderNose(ctx, opts.nose);
|
renderNose(ctx, opts.nose);
|
||||||
// draw mouth
|
// draw mouth
|
||||||
|
renderMouth(ctx, opts.mouth);
|
||||||
};
|
};
|
||||||
|
|
||||||
function renderHead(ctx, opts) {
|
function renderHead(ctx, opts) {
|
||||||
|
@ -116,10 +117,29 @@ function renderNose(ctx, opts) {
|
||||||
ctx.bezierCurveTo(opts.x - opts.width/2, opts.y - opts.height/2, opts.x, opts.y - opts.height, opts.x + opts.width/2, opts.y - opts.height/2);
|
ctx.bezierCurveTo(opts.x - opts.width/2, opts.y - opts.height/2, opts.x, opts.y - opts.height, opts.x + opts.width/2, opts.y - opts.height/2);
|
||||||
ctx.bezierCurveTo(opts.x + opts.width/2, opts.y - opts.height/2, opts.x + opts.width/2, opts.y + opts.height/2, opts.x, opts.y + opts.height/2);
|
ctx.bezierCurveTo(opts.x + opts.width/2, opts.y - opts.height/2, opts.x + opts.width/2, opts.y + opts.height/2, opts.x, opts.y + opts.height/2);
|
||||||
ctx.bezierCurveTo(opts.x, opts.y + opts.height/2, opts.x - opts.width/2, opts.y + opts.height/2, opts.x - opts.width/2, opts.y - opts.height/2);
|
ctx.bezierCurveTo(opts.x, opts.y + opts.height/2, opts.x - opts.width/2, opts.y + opts.height/2, opts.x - opts.width/2, opts.y - opts.height/2);
|
||||||
// drawEllipseByCenter(ctx, opts.x, opts.y, opts.width, opts.height, "black", null, 0.5);
|
|
||||||
ctx.fillStyle = "black";
|
ctx.fillStyle = "black";
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
//ctx.closePath(); // not used correctly, see comments (use to close off open path)
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderMouth(ctx, opts) {
|
||||||
|
ctx.strokeStyle = "black";
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.beginPath();
|
||||||
|
switch (opts.style) {
|
||||||
|
case "smirk":
|
||||||
|
ctx.moveTo(opts.x - opts.width/2, opts.y - opts.height/2);
|
||||||
|
ctx.bezierCurveTo(opts.x - opts.width/2, opts.y - opts.height/2,
|
||||||
|
opts.x - opts.width/2, opts.y + opts.height/2,
|
||||||
|
opts.x + opts.width/2, opts.y
|
||||||
|
)
|
||||||
|
break;
|
||||||
|
case "cat":
|
||||||
|
ctx.moveTo(opts.x - opts.width/2, opts.y + opts.height/2);
|
||||||
|
ctx.lineTo(opts.x, opts.y - opts.height/2);
|
||||||
|
ctx.lineTo(opts.x + opts.width/2, opts.y + opts.height/2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue