mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-28 02:02:08 +00:00
[Refactor] Remove redundant code (#1001)
Removes redundant code. After being refactored out of LGraphCanvas, the class methods were being passed their own properties as params.
This commit is contained in:
@@ -43,10 +43,8 @@ export class KnobWidget extends BaseWidget implements IKnobWidget {
|
||||
drawWidget(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
{
|
||||
y,
|
||||
width,
|
||||
show_text = true,
|
||||
margin = BaseWidget.margin,
|
||||
showText = true,
|
||||
}: DrawWidgetOptions,
|
||||
): void {
|
||||
// Store original context attributes
|
||||
@@ -54,6 +52,9 @@ export class KnobWidget extends BaseWidget implements IKnobWidget {
|
||||
const originalStrokeStyle = ctx.strokeStyle
|
||||
const originalFillStyle = ctx.fillStyle
|
||||
|
||||
const { y } = this
|
||||
const { margin } = BaseWidget
|
||||
|
||||
const { gradient_stops = "rgb(14, 182, 201); rgb(0, 216, 72)" } = this.options
|
||||
const effective_height = this.computedHeight || this.height
|
||||
// Draw background
|
||||
@@ -155,7 +156,7 @@ export class KnobWidget extends BaseWidget implements IKnobWidget {
|
||||
ctx.closePath()
|
||||
|
||||
// Draw outline if not disabled
|
||||
if (show_text && !this.computedDisabled) {
|
||||
if (showText && !this.computedDisabled) {
|
||||
ctx.strokeStyle = this.outline_color
|
||||
// Draw value
|
||||
ctx.beginPath()
|
||||
@@ -177,7 +178,7 @@ export class KnobWidget extends BaseWidget implements IKnobWidget {
|
||||
// TODO: TBD later when options work
|
||||
|
||||
// Draw text
|
||||
if (show_text) {
|
||||
if (showText) {
|
||||
ctx.textAlign = "center"
|
||||
ctx.fillStyle = this.text_color
|
||||
const fixedValue = Number(this.value).toFixed(this.options.precision ?? 3)
|
||||
|
||||
Reference in New Issue
Block a user