From a90c5c341f0e780dea0b49f0a401257afd7befdd Mon Sep 17 00:00:00 2001 From: AI Lab <129358391+1038lab@users.noreply.github.com> Date: Thu, 1 Jan 2026 19:06:39 -0800 Subject: [PATCH] Add files via upload --- web/js/appearance.js | 8 +++++--- web/js/colorWidget.js | 42 ++++++++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/web/js/appearance.js b/web/js/appearance.js index 2a62f43..8e0adf5 100644 --- a/web/js/appearance.js +++ b/web/js/appearance.js @@ -19,13 +19,16 @@ const NODE_COLORS = { "BiRefNetRMBG": "segment", "SAM2Segment": "segment", "SAM2SegmentDiscovery": "segment", - "SAM3Segment": "segment", "SAM2SegmentDiscoveryAdv": "segment", + "SAM3Segment": "segment", + "AILab_Florence2": "segment", // Utility nodes "AILab_LoadImage": "utility", "AILab_LoadImageSimple": "utility", "AILab_LoadImageAdvanced": "utility", + "AILab_LoadImageBatch": "utility", + "AILab_UnbatchImages": "utility", "AILab_Preview": "utility", "AILab_ImagePreview": "utility", "AILab_MaskPreview": "utility", @@ -78,5 +81,4 @@ const ext = { } }; - -app.registerExtension(ext); +app.registerExtension(ext); \ No newline at end of file diff --git a/web/js/colorWidget.js b/web/js/colorWidget.js index f1f2238..707d5a7 100644 --- a/web/js/colorWidget.js +++ b/web/js/colorWidget.js @@ -10,7 +10,7 @@ import { app } from "/scripts/app.js"; const getContrastTextColor = (hexColor) => { if (typeof hexColor !== 'string' || !/^#?[0-9a-fA-F]{6}$/.test(hexColor)) { - return '#cccccc'; // fallback text color + return '#cccccc'; } const hex = hexColor.replace('#', ''); @@ -28,8 +28,21 @@ const AILabColorWidget = { widget.y = 0; widget.name = key; widget.type = 'COLORCODE'; - widget.options = { default: '#222222' }; - widget.value = typeof val === 'string' ? val : '#222222'; + + const defaultColor = '#222222'; + widget.options = { default: defaultColor }; + + let initialValue = defaultColor; + if (Array.isArray(val) && val.length > 1 && val[1] && val[1].default) { + initialValue = val[1].default; + } + + if (typeof initialValue === 'string' && /^#?[0-9a-fA-F]{6}$/.test(initialValue)) { + widget.value = initialValue; + } else { + widget.value = defaultColor; + } + widget.draw = function (ctx, node, widgetWidth, widgetY, height) { const hide = this.type !== 'COLORCODE' && app.canvas.ds.scale > 0.5; @@ -37,24 +50,25 @@ const AILabColorWidget = { return; } + const drawHeight = 22; const margin = 15; - const radius = 12; + const radius = 10; ctx.fillStyle = this.value; ctx.beginPath(); const x = margin; - const y = widgetY; + const y = widgetY + (height - drawHeight) / 2; const w = widgetWidth - margin * 2; - const h = height; + const h = drawHeight; ctx.moveTo(x + radius, y); ctx.lineTo(x + w - radius, y); - ctx.quadraticCurveTo(x + w, y, x + w, y + radius); + ctx.arcTo(x + w, y, x + w, y + radius, radius); ctx.lineTo(x + w, y + h - radius); - ctx.quadraticCurveTo(x + w, y + h, x + w - radius, y + h); + ctx.arcTo(x + w, y + h, x + w - radius, y + h, radius); ctx.lineTo(x + radius, y + h); - ctx.quadraticCurveTo(x, y + h, x, y + h - radius); + ctx.arcTo(x, y + h, x, y + h - radius, radius); ctx.lineTo(x, y + radius); - ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.arcTo(x, y, x + radius, y, radius); ctx.closePath(); ctx.fill(); @@ -67,7 +81,7 @@ const AILabColorWidget = { ctx.textAlign = 'center'; const text = `${this.name} (${this.value})`; - ctx.fillText(text, widgetWidth * 0.5, widgetY + height * 0.65); + ctx.fillText(text, widgetWidth * 0.5, y + drawHeight * 0.65); }; widget.mouse = function (e, pos, node) { @@ -100,7 +114,7 @@ const AILabColorWidget = { }; widget.computeSize = function (width) { - return [width, 32]; + return [width, 22]; }; return widget; @@ -115,10 +129,10 @@ app.registerExtension({ COLORCODE: (node, inputName, inputData) => { return { widget: node.addCustomWidget( - AILabColorWidget.COLORCODE(inputName, inputData?.[1]?.default || '#222222') + AILabColorWidget.COLORCODE(inputName, inputData) ), minWidth: 150, - minHeight: 32, + minHeight: 22, }; } };