Is it possible to rotate a material using surface.DrawTexturedRectUV()

The code I am using is this,


surface.SetMaterial(self.Powerbar)
	surface.SetDrawColor(255, 255, 255, 255)
	surface.DrawTexturedRectUV(x * 0.05, y * 0.9, x * 0.075, y * 0.15 * (self.Charge / 100), 1, 0, 0, (-self.Charge / 100))

which renders the results

http://www.mythicservers.com/images/mythic/2015-09-18_00-55-46.gif

The original way I had it was this,


surface.SetMaterial(self.Powerbar)
	surface.SetDrawColor(255, 255, 255, 255)
        surface.DrawTexturedRectUV(x * 0.05, y * 0.8, x * 0.075, y * 0.15 * (self.Charge / 100), 0, 0, 1, (self.Charge / 100))

which drew the image properly but in reverse order

http://www.mythicservers.com/images/mythic/2015-09-18_00-56-45.gif

Seeing the first one is drawing in the correct way (from green to red), is it possible to rotate a material being drawn with surface.DrawTexturedRectUV()? If not, can anyone possibly see the problem in my code or offer a fix? As always, I appreciate any and all help.

While you can rotate one using sharders … its much easier to just move the y-position.

Make it start at the bottom and move slowly the y-position up as the bar fills. Have in mind that you need to fix the UV to match.

if it helps …
[lua]
local x,y,width,height,procent(0-1)
local endy = y+height
surface.DrawTexturedRectUV( x,endy-(heightprocent),width,(heightprocent), 0, procent, 1, 1 )
[/lua]

I went ahead and did what you said Nak and I am much farther than where I was. This is what I am now getting:

http://www.mythicservers.com/images/mythic/2015-09-18_01-40-37.gif


surface.SetMaterial(self.Powerbar)
surface.SetDrawColor(255, 255, 255, 255)
local percent = self.Charge / 100
surface.DrawTexturedRectUV(x * 0.05, y * 0.95 - (y * 0.15 * percent), x * 0.075, y * 0.15 * percent, 0, percent/100, 1, 1)

Any idea how to make it grow like a light meter rather than shrink from very tiny to normal size and back?

Pretty obvious I don’t even understand simple concepts about UV isnt it haha.

Try this
[lua]
surface.SetMaterial(self.Powerbar)
surface.SetDrawColor(255, 255, 255, 255)
local percent = self.Charge / 100
surface.DrawTexturedRectUV(x * 0.05, y * 0.95 - (y * 0.15 * percent), x * 0.075, y * 0.15 * percent, 0, 1-percent, 1, 1)
[/lua]
I think it should work.
100% = 0V
50% = 0.5V
20% = 0.8V
0% = 1V
Where V is the start position of the texture

Still a bit sick here :stuck_out_tongue:

The amount I love you right now is unequaled. Thank you very much Nak, its working perfectly.