Added comfy, fixed space, added bidirectional scaling
This commit is contained in:
parent
0ca661d2ab
commit
b9bf08e4cf
3 changed files with 21 additions and 3 deletions
BIN
ComfyTemplate.png
Normal file
BIN
ComfyTemplate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 218 KiB |
|
@ -74,8 +74,24 @@
|
|||
"size": 500
|
||||
},
|
||||
"y": {
|
||||
"position": 0,
|
||||
"offset": 10,
|
||||
"size": 500
|
||||
}
|
||||
}
|
||||
},
|
||||
"comfy": {
|
||||
"template": "./ComfyTemplate.png",
|
||||
"z": 2,
|
||||
"anchor": {
|
||||
"x": {
|
||||
"position": 50,
|
||||
"offset": 300
|
||||
"offset": 250,
|
||||
"size": 380
|
||||
},
|
||||
"y": {
|
||||
"position": 100,
|
||||
"offset": 500
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
6
index.js
6
index.js
|
@ -48,8 +48,10 @@ function render(template, img, size) {
|
|||
}
|
||||
|
||||
const xScale = width / template.anchor.x.size;
|
||||
const yScale = width / template.anchor.y.size;
|
||||
const templateScale = Math.min(xScale || 1, yScale || 1);
|
||||
const yScale = height / template.anchor.y.size;
|
||||
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 templateOffsetY = calculatePosition(templateScale, template.anchor.y, height);
|
||||
|
|
Reference in a new issue