Skip to content

Commit 3bee137

Browse files
committed
fix: clip nodes with their rendered shape
Amp-Thread-ID: https://ampcode.com/threads/T-01a02705-02f3-70c9-ae5b-8ea6c2a3cac2
1 parent 6777c3b commit 3bee137

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/lib/litegraph/src/LGraphCanvas.titleButtons.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
LGraphNode,
99
LiteGraph
1010
} from '@/lib/litegraph/src/litegraph'
11+
import { RenderShape } from '@/lib/litegraph/src/types/globalEnums'
1112

1213
describe('LGraphCanvas Title Button Rendering', () => {
1314
let canvas: LGraphCanvas
@@ -86,6 +87,18 @@ describe('LGraphCanvas Title Button Rendering', () => {
8687
})
8788

8889
describe('drawNode title button rendering', () => {
90+
it('clips using the node rendering shape', () => {
91+
Object.defineProperty(node, 'constructor', {
92+
value: { shape: RenderShape.ROUND }
93+
})
94+
node.clip_area = true
95+
96+
canvas.drawNode(node, ctx)
97+
98+
expect(ctx.roundRect).toHaveBeenCalled()
99+
expect(ctx.rect).not.toHaveBeenCalled()
100+
})
101+
89102
it('should render visible title buttons', () => {
90103
const button1 = node.addTitleButton({
91104
name: 'button1',

src/lib/litegraph/src/LGraphCanvas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5684,7 +5684,7 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
56845684
return
56855685

56865686
// clip if required (mask)
5687-
const shape = node.shape || RenderShape.BOX
5687+
const shape = node.renderingShape
56885688
const size = temp_vec2
56895689
size[0] = node.renderingSize[0]
56905690
size[1] = node.renderingSize[1]

0 commit comments

Comments
 (0)