Image.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. class "Image"
  2. Image.IMAGE_RGB = 0
  3. Image.IMAGE_RGBA = 1
  4. Image.IMAGE_FP16 = 2
  5. function Image:createEmpty(width, height, fillColor)
  6. local retVal = Polycode.Image_createEmpty(self.__ptr, width, height, fillColor.__ptr)
  7. end
  8. function Image:fill(color)
  9. local retVal = Polycode.Image_fill(self.__ptr, color.__ptr)
  10. end
  11. function Image:setPixel(x, y, r, g, b, a)
  12. local retVal = Polycode.Image_setPixel(self.__ptr, x, y, r, g, b, a)
  13. end
  14. function Image:getPixel(x, y)
  15. local retVal = Polycode.Image_getPixel(self.__ptr, x, y)
  16. if retVal == nil then return nil end
  17. local __c = _G["Color"]("__skip_ptr__")
  18. __c.__ptr = retVal
  19. return __c
  20. end
  21. function Image:drawLine(x0, y0, x1, y1, col)
  22. local retVal = Polycode.Image_drawLine(self.__ptr, x0, y0, x1, y1, col.__ptr)
  23. end
  24. function Image:moveBrushTo(x, y)
  25. local retVal = Polycode.Image_moveBrushTo(self.__ptr, x, y)
  26. end
  27. function Image:moveBrush(x, y)
  28. local retVal = Polycode.Image_moveBrush(self.__ptr, x, y)
  29. end
  30. function Image:drawLineTo(x, y, col)
  31. local retVal = Polycode.Image_drawLineTo(self.__ptr, x, y, col.__ptr)
  32. end
  33. function Image:fillRect(x, y, w, h, col)
  34. local retVal = Polycode.Image_fillRect(self.__ptr, x, y, w, h, col.__ptr)
  35. end
  36. function Image:perlinNoise(seed, alpha)
  37. local retVal = Polycode.Image_perlinNoise(self.__ptr, seed, alpha)
  38. end
  39. function Image:fastBlur(blurSize)
  40. local retVal = Polycode.Image_fastBlur(self.__ptr, blurSize)
  41. end
  42. function Image:fastBlurVert(blurSize)
  43. local retVal = Polycode.Image_fastBlurVert(self.__ptr, blurSize)
  44. end
  45. function Image:fastBlurHor(blurSize)
  46. local retVal = Polycode.Image_fastBlurHor(self.__ptr, blurSize)
  47. end
  48. function Image:getBrushX()
  49. local retVal = Polycode.Image_getBrushX(self.__ptr)
  50. return retVal
  51. end
  52. function Image:getBrushY()
  53. local retVal = Polycode.Image_getBrushY(self.__ptr)
  54. return retVal
  55. end
  56. function Image:isLoaded()
  57. local retVal = Polycode.Image_isLoaded(self.__ptr)
  58. return retVal
  59. end
  60. function Image:getType()
  61. local retVal = Polycode.Image_getType(self.__ptr)
  62. return retVal
  63. end
  64. function Image:getWidth()
  65. local retVal = Polycode.Image_getWidth(self.__ptr)
  66. return retVal
  67. end
  68. function Image:getHeight()
  69. local retVal = Polycode.Image_getHeight(self.__ptr)
  70. return retVal
  71. end
  72. function Image:premultiplyAlpha()
  73. local retVal = Polycode.Image_premultiplyAlpha(self.__ptr)
  74. end
  75. function Image:__delete()
  76. if self then Polycode.delete_Image(self.__ptr) end
  77. end