soulik

RGB Colormap pseudocode

Oct 15th, 2014
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.45 KB | None | 0 0
  1. -- 256x16 textura, kde kazdy stvorec ma 16x16 px
  2. local textura = ...
  3.  
  4. -- ziska RGB hodnotu farby na danej pozicii v texture
  5. local function getPixel(x, y)
  6.     return getPixelFromTexture(textura, x, y)
  7. end
  8.  
  9. -- vstupom su RGB hodnoty od 0-255
  10. -- vo vystupe su try nove RGB hodnoty vytiahnute z textury
  11. local function colormap(r0, g0, b0)
  12.     -- zmensenie mierky rozsahu z 256 na 16
  13.     local r, g, b = r0/16, g0/16, b0/16
  14.     return getPixel(r % 16 + b / 16, g)
  15. end
Advertisement
Add Comment
Please, Sign In to add comment