Color.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. function Color() {
  2. Object.defineProperties(this, {
  3. 'r': { enumerable: true, configurable: true, get: Color.prototype.__get_r, set: Color.prototype.__set_r},
  4. 'g': { enumerable: true, configurable: true, get: Color.prototype.__get_g, set: Color.prototype.__set_g},
  5. 'b': { enumerable: true, configurable: true, get: Color.prototype.__get_b, set: Color.prototype.__set_b},
  6. 'a': { enumerable: true, configurable: true, get: Color.prototype.__get_a, set: Color.prototype.__set_a}
  7. })
  8. }
  9. Color.prototype.__get_r = function() {
  10. return Polycode.Color__get_r(this.__ptr)
  11. }
  12. Color.prototype.__set_r = function(val) {
  13. Polycode.Color__set_r(this.__ptr, val)
  14. }
  15. Color.prototype.__get_g = function() {
  16. return Polycode.Color__get_g(this.__ptr)
  17. }
  18. Color.prototype.__set_g = function(val) {
  19. Polycode.Color__set_g(this.__ptr, val)
  20. }
  21. Color.prototype.__get_b = function() {
  22. return Polycode.Color__get_b(this.__ptr)
  23. }
  24. Color.prototype.__set_b = function(val) {
  25. Polycode.Color__set_b(this.__ptr, val)
  26. }
  27. Color.prototype.__get_a = function() {
  28. return Polycode.Color__get_a(this.__ptr)
  29. }
  30. Color.prototype.__set_a = function(val) {
  31. Polycode.Color__set_a(this.__ptr, val)
  32. }
  33. Color.prototype.setColorHex = function(hex) {
  34. Polycode.Color_setColorHex(this.__ptr, hex)
  35. }
  36. Color.prototype.setColorHexRGB = function(hex) {
  37. Polycode.Color_setColorHexRGB(this.__ptr, hex)
  38. }
  39. Color.prototype.setColorHexFromString = function(hex) {
  40. Polycode.Color_setColorHexFromString(this.__ptr, hex)
  41. }
  42. Color.prototype.setColorHexRGBFromString = function(hex) {
  43. Polycode.Color_setColorHexRGBFromString(this.__ptr, hex)
  44. }
  45. Color.prototype.setColorHSV = function(h,s,v) {
  46. Polycode.Color_setColorHSV(this.__ptr, h,s,v)
  47. }
  48. Color.prototype.setColorRGBA = function(r,g,b,a) {
  49. Polycode.Color_setColorRGBA(this.__ptr, r,g,b,a)
  50. }
  51. Color.prototype.setColorRGB = function(r,g,b) {
  52. Polycode.Color_setColorRGB(this.__ptr, r,g,b)
  53. }
  54. Color.prototype.setColor = function(r,g,b,a) {
  55. Polycode.Color_setColor(this.__ptr, r,g,b,a)
  56. }
  57. Color.prototype.blendColor = function(c2,mode,amount,c3) {
  58. var retVal = new Color()
  59. retVal.__ptr = Polycode.Color_blendColor(this.__ptr, c2,mode,amount,c3)
  60. return retVal
  61. }
  62. Color.prototype.Random = function() {
  63. Polycode.Color_Random(this.__ptr)
  64. }
  65. Color.prototype.getBrightness = function() {
  66. return Polycode.Color_getBrightness(this.__ptr)
  67. }
  68. Color.prototype.getHue = function() {
  69. return Polycode.Color_getHue(this.__ptr)
  70. }
  71. Color.prototype.getSaturation = function() {
  72. return Polycode.Color_getSaturation(this.__ptr)
  73. }
  74. Color.prototype.getValue = function() {
  75. return Polycode.Color_getValue(this.__ptr)
  76. }
  77. Color.prototype.getUint = function() {
  78. return Polycode.Color_getUint(this.__ptr)
  79. }