Advertisement
CapsAdmin

Untitled

Jul 16th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. local str = "abcdefg\noaskdoikas dsd\n hrllo"
  2. local tbl = {}
  3. local length = #str
  4.  
  5. for i = 1, length do
  6.     table.insert(tbl, {char = str:sub(i, i), color = HSVToColor((i / #str) * 360, 1, 1)})
  7. end
  8.  
  9. surface.CreateFont("LOL", {
  10.     font = "Arial",
  11.     size = 800,
  12. })
  13.  
  14. hook.Add("HUDPaint", "test", function()
  15.     surface.SetFont("LOL")
  16.    
  17.     local w, h = ScrW(), ScrH()
  18.     local last_w, last_h = 0, 0
  19.    
  20.     for i, data in pairs(tbl) do
  21.         surface.SetTextPos(w/2 + last_w, h/2 + last_h)
  22.        
  23.         surface.SetTextColor(data.color)
  24.         surface.DrawText(data.char)
  25.        
  26.         local w, h = surface.GetTextSize(data.char)
  27.         last_w = last_w + w
  28.        
  29.         if data.char == "\n" then
  30.             last_h = last_h + h / 2
  31.             last_w = 0
  32.         end
  33.     end
  34. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement