Dynamic Stencil issue

I’m trying to dynamically create a stencil in code… but it’s not working. The screenshot shows a circle stencil (left) but this is created in the editor. The code tries to do it only with code (right) and fails. If I uncomment the gui.set_clipping_mode command the circle object disappears completely.

At no time can I actually get it to stencil.

Not sure what I’m doing wrong.

function UIDrawCircle()

	--the way to do this is to have a boxnode that places an image with a parent circle?

	local size = vmath.vector3(400,400,0)
	local smallsize = vmath.vector3(100,100,0)

	local itempos = vmath.vector3(962.5,318,1)

	local pienode = gui.new_pie_node(itempos, smallsize)
	local boxnody = gui.new_box_node(itempos, size)	

	gui.set_parent(pienode, boxnody, 1)
	--gui.set_clipping_mode(pienode,gui.CLIPPING_MODE_STENCIL)

	gui.set_color(boxnody, ColorTable["red"])
	gui.set_color(pienode, ColorTable["white"])
	gui.move_above(boxnody, nil)
	gui.move_above(pienode, nil)
	gui.set_layer(boxnody, "graphictop")
	gui.set_layer(pienode, "graphictop")
end

Where I want it to eventually go is load box node with texture (i.e. image) place parent circle gui object on top of it, stencil, then get the image only appearing in the circle. I have char portraits in rectangular form and use those forms already but in certain cases I just want a stenciled circle version of same avatar portrait, etc.

Thanks!

1 Like

Any updates? Still curious - have moved on to other issues but this one is still perplexing me.

Sorry, this question slipped my mind. What I’d do is to in code get the two nodes that you created in the editor and print each of their properties. Use every gui.get_xyz() function there is and print each value. Then try again to create your nodes in code using the same setup as the ones that you created in the editor.