Merge branch 'main' of https://github.com/pythongosssss/ComfyUI-Custom-Scripts
This commit is contained in:
@@ -97,11 +97,16 @@ const ext = {
|
||||
}
|
||||
});
|
||||
|
||||
const alwaysSnapToGrid = () =>
|
||||
app.ui.settings.getSettingValue("pysssss.SnapToGrid", /* default=*/ false);
|
||||
const snapToGridEnabled = () =>
|
||||
app.shiftDown || alwaysSnapToGrid();
|
||||
|
||||
// Override drag-and-drop behavior to show orthogonal guide lines around selected node(s) and preview of where the node(s) will be placed
|
||||
const origDrawNode = LGraphCanvas.prototype.drawNode
|
||||
const origDrawNode = LGraphCanvas.prototype.drawNode;
|
||||
LGraphCanvas.prototype.drawNode = function (node, ctx) {
|
||||
const enabled = guide_config.lines.enabled || guide_config.block.enabled;
|
||||
if (enabled && app.shiftDown && this.node_dragged && node.id in this.selected_nodes) {
|
||||
if (enabled && this.node_dragged && node.id in this.selected_nodes && snapToGridEnabled()) {
|
||||
// discretize the canvas into grid
|
||||
let x = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.pos[0] / LiteGraph.CANVAS_GRID_SIZE);
|
||||
let y = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.pos[1] / LiteGraph.CANVAS_GRID_SIZE);
|
||||
|
||||
@@ -50,10 +50,12 @@ class WorkflowImage {
|
||||
}
|
||||
|
||||
updateView(bounds) {
|
||||
const scale = window.devicePixelRatio || 1;
|
||||
app.canvas.ds.scale = 1;
|
||||
app.canvas.canvas.width = bounds[2] - bounds[0];
|
||||
app.canvas.canvas.height = bounds[3] - bounds[1];
|
||||
app.canvas.canvas.width = (bounds[2] - bounds[0]) * scale;
|
||||
app.canvas.canvas.height = (bounds[3] - bounds[1]) * scale;
|
||||
app.canvas.ds.offset = [-bounds[0], -bounds[1]];
|
||||
app.canvas.canvas.getContext("2d").setTransform(scale, 0, 0, scale, 0, 0);
|
||||
}
|
||||
|
||||
getDrawTextConfig(_, widget) {
|
||||
|
||||
Reference in New Issue
Block a user