Added comfy, fixed space, added bidirectional scaling

This commit is contained in:
CBenni 2017-12-13 00:00:38 +01:00
parent 0ca661d2ab
commit b9bf08e4cf
3 changed files with 21 additions and 3 deletions

BIN
ComfyTemplate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

View file

@ -74,8 +74,24 @@
"size": 500 "size": 500
}, },
"y": { "y": {
"position": 0,
"offset": 10,
"size": 500
}
}
},
"comfy": {
"template": "./ComfyTemplate.png",
"z": 2,
"anchor": {
"x": {
"position": 50, "position": 50,
"offset": 300 "offset": 250,
"size": 380
},
"y": {
"position": 100,
"offset": 500
} }
} }
} }

View file

@ -48,8 +48,10 @@ function render(template, img, size) {
} }
const xScale = width / template.anchor.x.size; const xScale = width / template.anchor.x.size;
const yScale = width / template.anchor.y.size; const yScale = height / template.anchor.y.size;
const templateScale = Math.min(xScale || 1, yScale || 1); const templateScale = Math.max(0, Math.min(10, Math.max(xScale || 0, yScale || 0)));
console.log("templateScale",templateScale)
let templateOffsetX = calculatePosition(templateScale, template.anchor.x, width); let templateOffsetX = calculatePosition(templateScale, template.anchor.x, width);
let templateOffsetY = calculatePosition(templateScale, template.anchor.y, height); let templateOffsetY = calculatePosition(templateScale, template.anchor.y, height);