Files

70 lines
2.0 KiB
JavaScript

/*"Augment Vectorize — AI PNG to SVG Vectorizer for ComfyUI."
# Copyright 2026 Augment Studio
Augmentstudio.app */
import { app } from "../../../scripts/app.js";
const TITLE_BG = "#443322";
const NODE_BG = "#665533";
const PAID_NODES = [
"AugmentPNGToSVGPro",
];
const BADGE_FONT = "bold 9px sans-serif";
const BADGE_RADIUS = 4;
const BADGE_PAD_X = 6;
app.registerExtension({
name: "augment-vectorize.NodeStyle",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (!PAID_NODES.includes(nodeData.name)) return;
const origCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
origCreated?.apply(this, arguments);
if (this.widgets) {
this.widgets = this.widgets.filter(w => w.name !== "Get Tokens");
}
this.addWidget("button", "Get Tokens", null, () => {
window.open("https://augmentstudio.app/pricing", "_blank");
});
this.outputs?.forEach(o => {
if (o.name === "json_result") {
o.hidden = true;
}
});
};
const origDraw = nodeType.prototype.onDrawForeground;
nodeType.prototype.onDrawForeground = function (ctx) {
this.color = TITLE_BG;
this.bgcolor = NODE_BG;
origDraw?.apply(this, arguments);
ctx.save();
ctx.font = BADGE_FONT;
const creditsText = "🔸 1 export / run";
const creditsW = ctx.measureText(creditsText).width + BADGE_PAD_X * 2;
const creditsX = this.size[0] - creditsW - 6;
const y = -22;
ctx.beginPath();
ctx.roundRect(creditsX, y, creditsW, 14, BADGE_RADIUS);
ctx.fillStyle = "#8d6932";
ctx.fill();
ctx.fillStyle = "#ffffff";
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillText(creditsText, creditsX + BADGE_PAD_X, y + 7);
ctx.restore();
};
},
});