Surface.SetDrawColor Alpha Bug?

http://puu.sh/3JW10.webm

As you can see by the video the box on the left (using surface.DrawRect) flashes and produces unwanted results, where the box on the right (using draw.RoundedBox) does the correct thing. Both use the same alpha parameter.

Code used
[LUA]
hook.Add(“HUDPaint”, “SDLKJFLDSKJF”, function()
local alpha = math.Round(255 * math.cos(CurTime() * 2))
local col = Color(255, 0, 0, alpha)

surface.SetDrawColor(col)
surface.DrawRect(ScrW()/2 - 300, ScrH()/2 - 100, 200, 200)

draw.RoundedBox(0, ScrW()/2 + 100, ScrH()/2 - 100, 200, 200, col)

end)
[/LUA]

Is this a bug or am I missing something?

math.sin returns value from -1 to 1, so you are getting values from -255 to 255. Use math.abs or something.