ScreenShape.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. require "Polycode/ScreenMesh"
  2. class "ScreenShape" (ScreenMesh)
  3. SHAPE_RECT = 1
  4. SHAPE_CIRCLE = 2
  5. SHAPE_CUSTOM = 4
  6. function ScreenShape:__index__(name)
  7. if name == "strokeEnabled" then
  8. return Polycore.ScreenShape_get_strokeEnabled(self.__ptr)
  9. elseif name == "lineSmooth" then
  10. return Polycore.ScreenShape_get_lineSmooth(self.__ptr)
  11. end
  12. end
  13. function ScreenShape:__set_callback(name,value)
  14. if name == "strokeEnabled" then
  15. Polycore.ScreenShape_set_strokeEnabled(self.__ptr, value)
  16. return true
  17. elseif name == "lineSmooth" then
  18. Polycore.ScreenShape_set_lineSmooth(self.__ptr, value)
  19. return true
  20. end
  21. return false
  22. end
  23. function ScreenShape:ScreenShape(...)
  24. for k,v in pairs(arg) do
  25. if type(v) == "table" then
  26. if v.__ptr ~= nil then
  27. arg[k] = v.__ptr
  28. end
  29. end
  30. end
  31. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  32. self.__ptr = Polycore.ScreenShape(unpack(arg))
  33. Polycore.__ptr_lookup[self.__ptr] = self
  34. end
  35. end
  36. function ScreenShape:Render()
  37. local retVal = Polycore.ScreenShape_Render(self.__ptr)
  38. end
  39. function ScreenShape:setStrokeColor(r, g, b, a)
  40. local retVal = Polycore.ScreenShape_setStrokeColor(self.__ptr, r, g, b, a)
  41. end
  42. function ScreenShape:setStrokeWidth(width)
  43. local retVal = Polycore.ScreenShape_setStrokeWidth(self.__ptr, width)
  44. end
  45. function ScreenShape:setGradient(r1, g1, b1, a1, r2, g2, b2, a2)
  46. local retVal = Polycore.ScreenShape_setGradient(self.__ptr, r1, g1, b1, a1, r2, g2, b2, a2)
  47. end
  48. function ScreenShape:clearGradient()
  49. local retVal = Polycore.ScreenShape_clearGradient(self.__ptr)
  50. end
  51. function ScreenShape:setShapeSize(newWidth, newHeight)
  52. local retVal = Polycore.ScreenShape_setShapeSize(self.__ptr, newWidth, newHeight)
  53. end
  54. function ScreenShape:addShapePoint(x, y)
  55. local retVal = Polycore.ScreenShape_addShapePoint(self.__ptr, x, y)
  56. end