 VGUI: Shrinking material 2

Why won’t this turn into a square?
[lua]if( CLIENT ) then

local texture = surface.GetTextureID( "charge" ) -- this is our triangles texture, try to find your own
local centerx = ScrH()/2 --this is the middle x cordinate
local centery = ScrW()/2 --this is the middle y cordinate
local vertex = {{ },{ },{ },{ }} --create the two dimensional table

--First Vertex
vertex["x"] = centerx
vertex["y"] = centery
vertex["u"] = 0 //Top Left
vertex["v"] = 0

--Second Vertex
vertex["x"] = centerx + 50
vertex["y"] = centery
vertex["u"] = 1 //Top Right
vertex["v"] = 0

--Third Vertex
vertex["x"] = centerx
vertex["y"] = centery + 50
vertex["u"] = 0 //Bottom Left
vertex["v"] = 1

--Fourth Vertex
vertex["x"] = centerx + 50
vertex["y"] = centery + 50
vertex["u"] = 1 //Bottom Right
vertex["v"] = 1

local function HUDPaint()

surface.SetTexture( texture ) --set the texture of the triangle
surface.SetDrawColor( 255, 255, 255, 255 ) --set the additive color
surface.DrawPoly( vertex ) --draw the triangle with our triangle table

end

end[/lua]

You have your vertices out of order. Index 3 is the lower right, not lower left.

Does that even matter in what way they are ordered? I mean they still have all 4 vetricles.

Yes of course it matters…

It will join verticies 1 to 2, 2 to 3, 3 to 4, 4 to 1.

Now it doesn’t show up

Can you show updated code.

try this:
[lua]if( CLIENT ) then

local texture = surface.GetTextureID( "charge" ) -- this is our triangles texture, try to find your own
local centerx = ScrH()/2 --this is the middle x cordinate
local centery = ScrW()/2 --this is the middle y cordinate
local vertex = {{ },{ },{ },{ }} --create the two dimensional table

--First Vertex
vertex["x"] = centerx
vertex["y"] = centery
vertex["u"] = 0 //Top Left
vertex["v"] = 0

--Second Vertex
vertex["x"] = centerx + 50
vertex["y"] = centery
vertex["u"] = 1 //Top Right
vertex["v"] = 0

--Third Vertex
vertex["x"] = centerx + 50
vertex["y"] = centery + 50
vertex["u"] = 1 //Bottom Right
vertex["v"] = 1

--Fourth Vertex
vertex["x"] = centerx
vertex["y"] = centery + 50
vertex["u"] = 0 //Bottom Left
vertex["v"] = 1

local function HUDPaint()

surface.SetTexture( texture ) --set the texture of the triangle
surface.SetDrawColor( 255, 255, 255, 255 ) --set the additive color
surface.DrawPoly( vertex ) --draw the triangle with our triangle table

end

end[/lua]

Here, and Tobba it doesn’t work.
[lua]if( CLIENT ) then

local texture = surface.GetTextureID( "charge" ) -- this is our triangles texture, try to find your own
local centerx = ScrH()/2 --this is the middle x cordinate
local centery = ScrW()/2 --this is the middle y cordinate
local vertex = {{ },{ },{ },{ }} --create the two dimensional table

--First Vertex
vertex["x"] = centerx
vertex["y"] = centery
vertex["u"] = 0 //Top Left
vertex["v"] = 0

--Second Vertex
vertex["x"] = centerx + 50
vertex["y"] = centery
vertex["u"] = 1 //Top Right
vertex["v"] = 0

--Third Vertex
vertex["x"] = centerx + 50
vertex["y"] = centery + 50
vertex["u"] = 1 //Bottom Right
vertex["v"] = 1

--Fourth Vertex
vertex["x"] = centerx
vertex["y"] = centery + 50
vertex["u"] = 0 //Bottom Left
vertex["v"] = 1

local function HUDPaint()

surface.SetTexture( texture ) --set the texture of the triangle
surface.SetDrawColor( 255, 255, 255, 255 ) --set the additive color
surface.DrawPoly( vertex ) --draw the triangle with our triangle table

end

end[/lua]

You are never hooking to HUDPaint.

That worked. Thanks man!