Image.js 3.3 KB

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