Better seed randomizer

This commit is contained in:
space-nuko
2023-04-25 07:34:27 -07:00
parent cd0fde0f55
commit f0a520b9a1
11 changed files with 108 additions and 92 deletions

View File

@@ -4,12 +4,6 @@ import { LGraphNode } from "@litegraph-ts/core";
export default class ComfyGraphNode extends LGraphNode {
isVirtualNode: boolean = false;
/*
* Widgets that aren't a part of the graph, but are used for rendering
* purposes only.
*/
virtualWidgets: ComfyWidget[] = [];
onExecuting?(): void;
afterQueued?(): void;
onExecuted?(output: any): void;
}

View File

@@ -20,7 +20,7 @@ class ComfyImageNode extends ComfyGraphNode {
constructor(title?: any) {
super(title)
this._galleryWidget = new ComfyGalleryWidget("Images", [], this);
this.virtualWidgets.push(this._galleryWidget)
this.addCustomWidget(this._galleryWidget);
}
override onExecuted(output: ComfyImageExecOutput) {

View File

@@ -1,34 +0,0 @@
import { get } from 'svelte/store';
import ComfyGraphNode from "./ComfyGraphNode";
import widgetState from "$lib/stores/widgetState"
/*
* Autorefreshes seed (until bangs/main inlets are implemented)
*/
class ComfyBaseKSamplerNode extends ComfyGraphNode {
constructor(title?: any) {
super(title)
}
override onExecuting() {
console.log(this);
const widget = widgetState.findWidgetByName(this.id, "seed")
if (!widget)
return;
// TODO cleanup&remove
let min = widget.widget.options.min;
let max = widget.widget.options.max;
// limit to something that javascript can handle
max = Math.min(1125899906842624, max);
min = Math.max(-1125899906842624, min);
const range = (max - min) / (widget.widget.options.step);
const v = Math.floor(Math.floor(Math.random() * range) * (widget.widget.options.step) + min);
widget.widget.value = v;
widgetState.widgetStateChanged(this.id, widget.widget);
}
}
export class ComfyKSamplerNode extends ComfyBaseKSamplerNode {}
export class ComfyKSamplerAdvancedNode extends ComfyBaseKSamplerNode {}

View File

@@ -1,3 +1,2 @@
export { default as ComfyReroute } from "./ComfyReroute"
export { ComfySaveImageNode, ComfyPreviewImageNode } from "./ComfyImageNodes"
export { ComfyKSamplerNode, ComfyKSamplerAdvancedNode } from "./ComfyKSamplerNodes"