mirror of
https://git.sleeping.town/mirrors/foxy-moxy
synced 2024-11-24 21:17:44 +00:00
Shift the fox heads down a tad.
This commit is contained in:
parent
3e55c8eb7b
commit
3acf93fd81
2 changed files with 12 additions and 1 deletions
|
@ -15,7 +15,7 @@ var Fox = function (IMG_WIDTH, IMG_HEIGHT, seed) {
|
|||
// TODO: head headWidth and height
|
||||
var headWidth = 0.6 * IMG_WIDTH;
|
||||
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: 0.5 * IMG_HEIGHT - headHeight / 2};
|
||||
var kappa = chance.floating({min: 0.2, max: 0.45})
|
||||
|
||||
var hue = chance.integer({min: 5, max: 50});
|
||||
|
|
|
@ -10,8 +10,19 @@ var renderFox = function (canvas, opts) {
|
|||
renderEyes(ctx, opts.eyes);
|
||||
renderNose(ctx, opts.nose);
|
||||
renderMouth(ctx, opts.mouth);
|
||||
|
||||
shift_canvas(ctx, width, height, 0, 0.06 * height);
|
||||
};
|
||||
|
||||
function shift_canvas(ctx, w, h, dx, dy) {
|
||||
var topImage = ctx.getImageData(0, 0, w, h);
|
||||
var bottomImage = ctx.getImageData(0, h - dy, w, h);
|
||||
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
ctx.putImageData(bottomImage, 0, 0);
|
||||
ctx.putImageData(topImage, dx, dy);
|
||||
}
|
||||
|
||||
function renderHead(ctx, opts) {
|
||||
ctx.save();
|
||||
ctx.translate(ctx.canvas.width/2, ctx.canvas.height/2);
|
||||
|
|
Loading…
Reference in a new issue