* Renders the node's title bar background
(ctx: CanvasRenderingContext2D, {
scale,
title_height = LiteGraph.NODE_TITLE_HEIGHT,
low_quality = false,
}: DrawTitleOptions)
| 3257 | * Renders the node's title bar background |
| 3258 | */ |
| 3259 | drawTitleBarBackground(ctx: CanvasRenderingContext2D, { |
| 3260 | scale, |
| 3261 | title_height = LiteGraph.NODE_TITLE_HEIGHT, |
| 3262 | low_quality = false, |
| 3263 | }: DrawTitleOptions): void { |
| 3264 | const fgcolor = this.renderingColor |
| 3265 | const shape = this.renderingShape |
| 3266 | const size = this.renderingSize |
| 3267 | |
| 3268 | if (this.onDrawTitleBar) { |
| 3269 | this.onDrawTitleBar(ctx, title_height, size, scale, fgcolor) |
| 3270 | return |
| 3271 | } |
| 3272 | |
| 3273 | if (this.title_mode === TitleMode.TRANSPARENT_TITLE) { |
| 3274 | return |
| 3275 | } |
| 3276 | |
| 3277 | if (this.collapsed) { |
| 3278 | ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR |
| 3279 | } |
| 3280 | |
| 3281 | ctx.fillStyle = this.constructor.title_color || fgcolor |
| 3282 | ctx.beginPath() |
| 3283 | |
| 3284 | if (shape == RenderShape.BOX || low_quality) { |
| 3285 | ctx.rect(0, -title_height, size[0], title_height) |
| 3286 | } else if (shape == RenderShape.ROUND || shape == RenderShape.CARD) { |
| 3287 | ctx.roundRect( |
| 3288 | 0, |
| 3289 | -title_height, |
| 3290 | size[0], |
| 3291 | title_height, |
| 3292 | this.collapsed |
| 3293 | ? [LiteGraph.ROUND_RADIUS] |
| 3294 | : [LiteGraph.ROUND_RADIUS, LiteGraph.ROUND_RADIUS, 0, 0], |
| 3295 | ) |
| 3296 | } |
| 3297 | ctx.fill() |
| 3298 | ctx.shadowColor = "transparent" |
| 3299 | } |
| 3300 | |
| 3301 | /** |
| 3302 | * Renders the node's title box, i.e. the dot in front of the title text that |