Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gl = require("component").glasses
- local png = require("libPNGimage")
- local os = require("os") --used to avoid "too long without yielding"
- local lib = {}
- function lib.dot(x,y,r,g,b,a)
- r = r or 0
- g = g or 0
- b = b or 1
- a = a or 1
- local d = gl.addDot()
- d.setScale(1)
- d.setPosition(x,y)
- d.setColor(r,g,b)
- d.setAlpha(a)
- return d
- end
- function lib.fillHud(img, xx, yy, cache)
- local dots = {}
- local width, height = img:getSize()
- for x = 1, width do
- for y = 1, height do
- local dot = lib.dot(xx + x - 1, yy + y - 1, img:getPixel(x-1,y-1))
- if cache then table.insert(dots, dot.getID()) end
- os.sleep(0)
- end
- end
- return dots
- end
- function lib.pngToHud(f,x,y,cache)
- checkArg(1, f, "string")
- local fl,err = io.open(f, "rb")
- if not fl then error(err) end
- local img = png.newFromFileHandle(fl)
- return lib.fillHud(img,x or 0, y or 0, cache)
- end
- return lib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement