• Stencils for cutting / masking derma panel
    0 replies, posted
//Stencil out the icons, paint only within the borders. render.SetStencilEnable(true) render.ClearStencil() render.SetStencilWriteMask( 3 ) -- Fix halos render.SetStencilTestMask( 3 ) render.SetStencilCompareFunction( STENCIL_NEVER ) render.SetStencilPassOperation( STENCIL_KEEP ) render.SetStencilFailOperation( STENCIL_REPLACE ) render.SetStencilZFailOperation( STENCIL_REPLACE ) render.SetStencilReferenceValue( 1 ) --1 = paint. 0 = ignore //Set whole panel to 1. derma.SkinHook( "Paint", "Tree", self, w, h ) //Cut out icons. render.SetStencilFailOperation( STENCIL_ZERO ) render.SetStencilZFailOperation( STENCIL_ZERO ) for k,v in pairs(self.IconLayout:GetChildren())do local x1,y1,w1,h1 = v:GetBounds() local x2,y2 = self:GetCanvas():GetPos() y1 = y1+y2 draw.RoundedBox(8,x1,y1,w1,h1,Color(0,255,0,255)) end //Actually paint panel. render.SetStencilCompareFunction( STENCIL_EQUAL ) render.SetStencilFailOperation( STENCIL_KEEP ) render.SetStencilZFailOperation( STENCIL_KEEP ) derma.SkinHook( "Paint", "Tree", self, w, h ) render.SetStencilEnable(false) Above is some code from bobbleheadbob's stencil wrapper V2 post, though I'm not sure if he's painting within the bounds of these referenced 'icons' or cutting around them. I'm trying to achieve the effect shown on this red derma panel below: (Ignore the advertisement text) https://web.archive.org/web/20160812013953im_/https://dl.dropboxusercontent.com/u/104427432/Scripts/csg/stencils.png I tried removing the for loop, and just doing draw.roundedbox at the point where it occurs; this didn't seem to work. Where should this code even go? I tried sticking it inside of a Panel:PAINT function, was this wrong or right? I'm very new to stencils, so I don't really know what I'm doing. Any help would be appreciated.
Sorry, you need to Log In to post a reply to this thread.