# 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[1]["x"] = centerx
vertex[1]["y"] = centery
vertex[1]["u"] = 0 //Top Left
vertex[1]["v"] = 0

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

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

--Fourth Vertex
vertex[4]["x"] = centerx + 50
vertex[4]["y"] = centery + 50
vertex[4]["u"] = 1 //Bottom Right
vertex[4]["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[1]["x"] = centerx
vertex[1]["y"] = centery
vertex[1]["u"] = 0 //Top Left
vertex[1]["v"] = 0

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

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

--Fourth Vertex
vertex[4]["x"] = centerx
vertex[4]["y"] = centery + 50
vertex[4]["u"] = 0 //Bottom Left
vertex[4]["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[1]["x"] = centerx
vertex[1]["y"] = centery
vertex[1]["u"] = 0 //Top Left
vertex[1]["v"] = 0

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

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

--Fourth Vertex
vertex[4]["x"] = centerx
vertex[4]["y"] = centery + 50
vertex[4]["u"] = 0 //Bottom Left
vertex[4]["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!