Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
GUI library (WIP) - Page 3 - Gideros Forum

GUI library (WIP)

13»

Comments

  • hgy29hgy29 Maintainer
    Not with just stencil, stencil test will only give a Boolean result. Using a 2x or 3x rendertarget and an averaging downscaler shader could work, but that’ll be expensive.
  • rrraptorrrraptor Member
    edited December 2019
    Ok, I did it diferently :D 2 separated shapes ))
    - Create shape
    - apply stencil operation
    - craete border
    - ...
    - profit!


    function rrect(t)
    	local r = t.r or 40
    	local w = t.w
    	local h = t.h
     
    	local shape = Path2D.new()
    	local ms="MALALALAZ"
    	local mp = {0,r, 
    		r,r,0,0,1,r,0, w-r,0, 
    		r,r,0,0,1,w,r, w,h-r, 
    		r,r,0,0,1,w-r,h, r,h, 
    		r,r,0,0,1,0,h-r
    	}
    	shape:setPath(ms,mp)
    	return shape
    end
     
    local rr = rrect{w=100,h=100}
    rr:setFillColor(0, 1)
     
    local rr1 = rrect{w=100,h=100}
    rr1:setFillColor(0, 0)
    rr1:setLineColor(0x0000ff, 1)
    rr1:setLineThickness(4, 1)
     
    rr:setPosition(50,50)
    rr1:setPosition(50,50)
     
    stage:addChild(rr)
    stage:addChild(rr1)
     
    rr:setStencilOperation{
    	stencilClear = true, 
    	stenciMask = 1, 
    	stencilWriteMask = 1, 
    	stencilRef = 1,
    	stencilFunc = Sprite.STENCIL_ALWAYS, 
    	depthPass = Sprite.STENCIL_REPLACE,
    }
     
    local px = Pixel.new(0xff0000,1, 20, 20)
     
    px:setStencilOperation{
    	stencilClear = false, 
    	stencilMask = 1, 
    	stencilRef = 1,
    	stencilFunc = Sprite.STENCIL_LEQUAL,
    }
     
     
    rr:addChild(px)
     
    stage:addEventListener(Event.MOUSE_MOVE, function(e)
    	local x,y = e.x,e.y
    	px:setPosition(x-50,y-50)
    end)
    rrect_clip.png
    142 x 133 - 7K
    +1 -1 (+2 / -0 ) Share on Facebook
Sign In or Register to comment.