MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / drawTitleBox

Method drawTitleBox

src/LGraphNode.ts:3306–3373  ·  view source on GitHub ↗

* Renders the node's title box, i.e. the dot in front of the title text that * when clicked toggles the node's collapsed state. The term `title box` comes * from the original LiteGraph implementation.

(ctx: CanvasRenderingContext2D, {
    scale,
    low_quality = false,
    title_height = LiteGraph.NODE_TITLE_HEIGHT,
    box_size = 10,
  }: DrawTitleBoxOptions)

Source from the content-addressed store, hash-verified

3304 * from the original LiteGraph implementation.
3305 */
3306 drawTitleBox(ctx: CanvasRenderingContext2D, {
3307 scale,
3308 low_quality = false,
3309 title_height = LiteGraph.NODE_TITLE_HEIGHT,
3310 box_size = 10,
3311 }: DrawTitleBoxOptions): void {
3312 const size = this.renderingSize
3313 const shape = this.renderingShape
3314
3315 if (this.onDrawTitleBox) {
3316 this.onDrawTitleBox(ctx, title_height, size, scale)
3317 return
3318 }
3319
3320 if (
3321 [RenderShape.ROUND, RenderShape.CIRCLE, RenderShape.CARD].includes(shape)
3322 ) {
3323 if (low_quality) {
3324 ctx.fillStyle = "black"
3325 ctx.beginPath()
3326 ctx.arc(
3327 title_height * 0.5,
3328 title_height * -0.5,
3329 box_size * 0.5 + 1,
3330 0,
3331 Math.PI * 2,
3332 )
3333 ctx.fill()
3334 }
3335
3336 ctx.fillStyle = this.renderingBoxColor
3337 if (low_quality) {
3338 ctx.fillRect(
3339 title_height * 0.5 - box_size * 0.5,
3340 title_height * -0.5 - box_size * 0.5,
3341 box_size,
3342 box_size,
3343 )
3344 } else {
3345 ctx.beginPath()
3346 ctx.arc(
3347 title_height * 0.5,
3348 title_height * -0.5,
3349 box_size * 0.5,
3350 0,
3351 Math.PI * 2,
3352 )
3353 ctx.fill()
3354 }
3355 } else {
3356 if (low_quality) {
3357 ctx.fillStyle = "black"
3358 ctx.fillRect(
3359 (title_height - box_size) * 0.5 - 1,
3360 (title_height + box_size) * -0.5 - 1,
3361 box_size + 2,
3362 box_size + 2,
3363 )

Callers 1

drawNodeShapeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected