Image.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. function Image(fileName) {
  2. if(arguments[0] != "__skip_ptr__") {
  3. this.__ptr = Polycode.Image(fileName)
  4. }
  5. }
  6. Image.IMAGE_RGB = 0
  7. Image.IMAGE_RGBA = 1
  8. Image.IMAGE_FP16 = 2
  9. Image.prototype.BlankImage = function(width,height,type) {
  10. var retVal = new Image()
  11. retVal.__ptr = Polycode.Image_BlankImage(width, height, type)
  12. return retVal
  13. }
  14. Image.prototype.loadImage = function(fileName) {
  15. return Polycode.Image_loadImage(this.__ptr, fileName)
  16. }
  17. Image.prototype.saveImage = function(fileName) {
  18. return Polycode.Image_saveImage(this.__ptr, fileName)
  19. }
  20. Image.prototype.pasteImage = function(image,x,y,blendingMode,blendAmount,blendColor) {
  21. Polycode.Image_pasteImage(this.__ptr, image.__ptr, x, y, blendingMode, blendAmount, blendColor)
  22. }
  23. Image.prototype.createEmpty = function(width,height,fillColor) {
  24. Polycode.Image_createEmpty(this.__ptr, width, height, fillColor)
  25. }
  26. Image.prototype.fill = function(color) {
  27. Polycode.Image_fill(this.__ptr, color)
  28. }
  29. Image.prototype.setPixel = function(x,y,r,g,b,a) {
  30. Polycode.Image_setPixel(this.__ptr, x, y, r, g, b, a)
  31. }
  32. Image.prototype.getPixel = function(x,y) {
  33. var retVal = new Color()
  34. retVal.__ptr = Polycode.Image_getPixel(this.__ptr, x, y)
  35. return retVal
  36. }
  37. Image.prototype.swap = function(v1,v2) {
  38. Polycode.Image_swap(this.__ptr, v1.__ptr, v2.__ptr)
  39. }
  40. Image.prototype.drawLine = function(x0,y0,x1,y1,col) {
  41. Polycode.Image_drawLine(this.__ptr, x0, y0, x1, y1, col)
  42. }
  43. Image.prototype.moveBrushTo = function(x,y) {
  44. Polycode.Image_moveBrushTo(this.__ptr, x, y)
  45. }
  46. Image.prototype.moveBrush = function(x,y) {
  47. Polycode.Image_moveBrush(this.__ptr, x, y)
  48. }
  49. Image.prototype.drawLineTo = function(x,y,col) {
  50. Polycode.Image_drawLineTo(this.__ptr, x, y, col)
  51. }
  52. Image.prototype.fillRect = function(x,y,w,h,col) {
  53. Polycode.Image_fillRect(this.__ptr, x, y, w, h, col)
  54. }
  55. Image.prototype.perlinNoise = function(seed,alpha) {
  56. Polycode.Image_perlinNoise(this.__ptr, seed, alpha)
  57. }
  58. Image.prototype.fastBlur = function(blurSize) {
  59. Polycode.Image_fastBlur(this.__ptr, blurSize)
  60. }
  61. Image.prototype.fastBlurVert = function(blurSize) {
  62. Polycode.Image_fastBlurVert(this.__ptr, blurSize)
  63. }
  64. Image.prototype.fastBlurHor = function(blurSize) {
  65. Polycode.Image_fastBlurHor(this.__ptr, blurSize)
  66. }
  67. Image.prototype.getPixelsInRect = function(x,y,width,height) {
  68. var retVal = new char()
  69. retVal.__ptr = Polycode.Image_getPixelsInRect(this.__ptr, x, y, width, height)
  70. return retVal
  71. }
  72. Image.prototype.getImagePart = function(subRect) {
  73. var retVal = new Image()
  74. retVal.__ptr = Polycode.Image_getImagePart(this.__ptr, subRect)
  75. return retVal
  76. }
  77. Image.prototype.getBrushX = function() {
  78. return Polycode.Image_getBrushX(this.__ptr)
  79. }
  80. Image.prototype.getBrushY = function() {
  81. return Polycode.Image_getBrushY(this.__ptr)
  82. }
  83. Image.prototype.isLoaded = function() {
  84. return Polycode.Image_isLoaded(this.__ptr)
  85. }
  86. Image.prototype.getType = function() {
  87. return Polycode.Image_getType(this.__ptr)
  88. }
  89. Image.prototype.getWidth = function() {
  90. return Polycode.Image_getWidth(this.__ptr)
  91. }
  92. Image.prototype.getHeight = function() {
  93. return Polycode.Image_getHeight(this.__ptr)
  94. }
  95. Image.prototype.getPixels = function() {
  96. var retVal = new char()
  97. retVal.__ptr = Polycode.Image_getPixels(this.__ptr)
  98. return retVal
  99. }
  100. Image.prototype.premultiplyAlpha = function() {
  101. Polycode.Image_premultiplyAlpha(this.__ptr)
  102. }
  103. Image.prototype.savePNG = function(fileName) {
  104. return Polycode.Image_savePNG(this.__ptr, fileName)
  105. }