Hey guys, I recently started working on a new hud to develop my coding skills in glua. Before i continue working on it, I need you guys to tell me how can i use masking on a panel according to a surface.
Just in case you didn't understand what I'm talking about. Here is what i have:
[IMG]http://i.imgur.com/XcwwpGN.jpg[/IMG]
Here is my problem:
[IMG]http://i.imgur.com/NoxqlLh.png[/IMG]
And here is the result I am intending to achieve:
[IMG]http://i.imgur.com/yYzuKLE.png[/IMG]
The circle is a surface in a painted panel and the DmodelPanel is a child to that panel
So, I would like a clear explanation from A to Z about what do i need to do.
Here is a part of my code just in case you need a clearer idea about the structure:
[CODE]
function HPHud()
local hud = vgui.Create('DPanel')
--skipped some code
function hud:Paint(w, h)
-- skipped more code
--function that will draw the circle using drawpoly
drawCircledBox(false, padw ,padh, 0, radius - 7, 360, nil, nil, Color(0,0,0,255), nil)
end
local plymod = vgui.Create('DModelPanel', hud)
-- skip skip skip
function plymod:LayoutEntity(ent)
--skip some more
end
function plymod.Entity:GetPlayerColor()
return pl:GetPlayerColor()
end
-- skipped more code relate to the eyepos
end
[/CODE]
This looks to me like a stencils case.
There was a bit of code around the forums several times already that does this.
Ok, I fixed it using stencils in the paint function of the panel. Thank you for the quick help :D
Edit: For future help, if you are having trouble with the paint function of the dmodelpanel use [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dmodelpanel.lua#L115-L150"]this github page[/URL] as a reference to it
Sorry, you need to Log In to post a reply to this thread.