[CodeHealth] Apply modern standards to LGraphCanvas (#650)

- Prefer template string
- Prefer explicit throw to undefined TypeError
- Remove unnecessary `this` assignment
This commit is contained in:
filtered
2025-03-01 09:08:23 +11:00
committed by GitHub
parent c4faaf4210
commit b36bf3d4a2
10 changed files with 102 additions and 127 deletions

View File

@@ -186,12 +186,9 @@ export class KnobWidget extends BaseWidget implements IKnobWidget {
if (show_text) {
ctx.textAlign = "center"
ctx.fillStyle = this.text_color
const fixedValue = Number(this.value).toFixed(this.options.precision ?? 3)
ctx.fillText(
(this.label || this.name) +
"\n" +
Number(this.value).toFixed(
this.options.precision != null ? this.options.precision : 3,
),
`${this.label || this.name}\n${fixedValue}`,
widget_width * 0.5,
y + effective_height * 0.5,
)

View File

@@ -77,12 +77,9 @@ export class SliderWidget extends BaseWidget implements ISliderWidget {
if (show_text) {
ctx.textAlign = "center"
ctx.fillStyle = this.text_color
const fixedValue = Number(this.value).toFixed(this.options.precision ?? 3)
ctx.fillText(
(this.label || this.name) +
" " +
Number(this.value).toFixed(
this.options.precision != null ? this.options.precision : 3,
),
`${this.label || this.name} ${fixedValue}`,
widget_width * 0.5,
y + H * 0.7,
)