Better seed randomizer
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {}
|
||||
@@ -1,3 +1,2 @@
|
||||
export { default as ComfyReroute } from "./ComfyReroute"
|
||||
export { ComfySaveImageNode, ComfyPreviewImageNode } from "./ComfyImageNodes"
|
||||
export { ComfyKSamplerNode, ComfyKSamplerAdvancedNode } from "./ComfyKSamplerNodes"
|
||||
|
||||
Reference in New Issue
Block a user