CapsAdmin

Untitled

Dec 22nd, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.50 KB | None | 0 0
  1. function META:Fill(callback)
  2.     check(callback, "function")
  3.    
  4.     local img = self:GetPixelTable(true)
  5.     local w = self:GetSize()
  6.     local x, y = 0, 0
  7.    
  8.     for i = 0, self:GetPixelLength() do
  9.        
  10.         if x >= w then
  11.             x = 0
  12.             y = y + 1
  13.         else
  14.             x = x + 1
  15.         end
  16.        
  17.         local r, g, b, a = callback(x, y, img[i].r, img[i].g, img[i].b, img[i].a)
  18.        
  19.         img[i].r = r*255 or img[i].r
  20.         img[i].g = g*255 or img[i].g
  21.         img[i].b = b*255 or img[i].b
  22.         img[i].a = a*255 or img[i].a
  23.     end
  24.    
  25.     self:SetPixelTable(img)
  26. end
Advertisement
Add Comment
Please, Sign In to add comment