Make AvatarImage circular

Hey,

Someone can give me a quick info how to edit the AvatarImage Element? So i get the Material of the avatar or sth like that?
Need it to be circular and have no clue how to get it done.

Just a quick thought-provoking impulse would be cool :slight_smile:

Thanks,

search; I provided this solution only just a month ago.

Thanks so far,

But as a result i got this:

Is there a way to make it transparent?

Stencils. - They work like masks really, you decide which pixels should or shouldn’t be drawn.

Sorry for asking, but render is normally for 3D right? So i would need to do it in a cam2D?

Nah, they work independent of a view state.

Since i need the AvatarImage to be painted manually, i need to figure out how to…
On the Wiki i found SetPaintedManually, but after setting it to true, no Paint hook gets called:

[LUA]
frame:SetPaintedManually(true)
frame.Paint = function()
print(“calledPaint”) --not called
local w = 64
local h = 64
surface.SetMaterial(Material(‘vgui/white’))
surface.SetDrawColor(Color(52, 56, 67))
for a = 1, 13 do – For extra aa
for i = 0, 360, a do
local _i = i * math.pi/180;
surface.DrawTexturedRectRotated(math.cos(_i)(40)+w/2, math.sin(_i)(40)+h/2, 15, a2, -i )
end
end
end
frame:SetPaintFunction(function()
print(“calledSetPaint”)–not called
local w = 64
local h = 64
surface.SetMaterial(Material(‘vgui/white’))
surface.SetDrawColor(Color(52, 56, 67))
for a = 1, 13 do – For extra aa
for i = 0, 360, a do
local _i = i * math.pi/180;
surface.DrawTexturedRectRotated(math.cos(_i)
(40)+w/2, math.sin(_i)(40)+h/2, 15, a2, -i )
end
end
end)
frame.PaintManual = function()
print(“calledPaintManual”)–not called
local w = 64
local h = 64
surface.SetMaterial(Material(‘vgui/white’))
surface.SetDrawColor(Color(52, 56, 67))
for a = 1, 13 do – For extra aa
for i = 0, 360, a do
local _i = i * math.pi/180;
surface.DrawTexturedRectRotated(math.cos(_i)(40)+w/2, math.sin(_i)(40)+h/2, 15, a*2, -i )
end
end
end
[/LUA]

you set PANEL.Paint and then call PANEL:PaintManual(), you may have to mess around with PANEL:SetPaintedManually( bool ), it’s not the best documented stuff.

Override the “Paint” hook and then do somthing like this to draw it:



self:SetPaintedManually( false )
self:PaintManual()
self:SetPaintedManually( true )