ScreenShape.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. end
  34. end
  35. function ScreenShape:Render()
  36. local retVal = Polycore.ScreenShape_Render(self.__ptr)
  37. end
  38. function ScreenShape:setStrokeColor(r, g, b, a)
  39. local retVal = Polycore.ScreenShape_setStrokeColor(self.__ptr, r, g, b, a)
  40. end
  41. function ScreenShape:setStrokeWidth(width)
  42. local retVal = Polycore.ScreenShape_setStrokeWidth(self.__ptr, width)
  43. end
  44. function ScreenShape:setGradient(r1, g1, b1, a1, r2, g2, b2, a2)
  45. local retVal = Polycore.ScreenShape_setGradient(self.__ptr, r1, g1, b1, a1, r2, g2, b2, a2)
  46. end
  47. function ScreenShape:clearGradient()
  48. local retVal = Polycore.ScreenShape_clearGradient(self.__ptr)
  49. end
  50. function ScreenShape:setShapeSize(newWidth, newHeight)
  51. local retVal = Polycore.ScreenShape_setShapeSize(self.__ptr, newWidth, newHeight)
  52. end
  53. function ScreenShape:addShapePoint(x, y)
  54. local retVal = Polycore.ScreenShape_addShapePoint(self.__ptr, x, y)
  55. end