Image.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.loadImage = function(fileName) {
  10. return Polycode.Image_loadImage(this.__ptr, fileName)
  11. }
  12. Image.prototype.saveImage = function(fileName) {
  13. return Polycode.Image_saveImage(this.__ptr, fileName)
  14. }
  15. Image.prototype.createEmpty = function(width,height,fillColor) {
  16. Polycode.Image_createEmpty(this.__ptr, width, height, fillColor)
  17. }
  18. Image.prototype.fill = function(color) {
  19. Polycode.Image_fill(this.__ptr, color)
  20. }
  21. Image.prototype.setPixel = function(x,y,r,g,b,a) {
  22. Polycode.Image_setPixel(this.__ptr, x, y, r, g, b, a)
  23. }
  24. Image.prototype.getPixel = function(x,y) {
  25. var retVal = new Color("__skip_ptr__")
  26. retVal.__ptr = Polycode.Image_getPixel(this.__ptr, x, y)
  27. return retVal
  28. }
  29. Image.prototype.drawLine = function(x0,y0,x1,y1,col) {
  30. Polycode.Image_drawLine(this.__ptr, x0, y0, x1, y1, col)
  31. }
  32. Image.prototype.moveBrushTo = function(x,y) {
  33. Polycode.Image_moveBrushTo(this.__ptr, x, y)
  34. }
  35. Image.prototype.moveBrush = function(x,y) {
  36. Polycode.Image_moveBrush(this.__ptr, x, y)
  37. }
  38. Image.prototype.drawLineTo = function(x,y,col) {
  39. Polycode.Image_drawLineTo(this.__ptr, x, y, col)
  40. }
  41. Image.prototype.fillRect = function(x,y,w,h,col) {
  42. Polycode.Image_fillRect(this.__ptr, x, y, w, h, col)
  43. }
  44. Image.prototype.perlinNoise = function(seed,alpha) {
  45. Polycode.Image_perlinNoise(this.__ptr, seed, alpha)
  46. }
  47. Image.prototype.fastBlur = function(blurSize) {
  48. Polycode.Image_fastBlur(this.__ptr, blurSize)
  49. }
  50. Image.prototype.fastBlurVert = function(blurSize) {
  51. Polycode.Image_fastBlurVert(this.__ptr, blurSize)
  52. }
  53. Image.prototype.fastBlurHor = function(blurSize) {
  54. Polycode.Image_fastBlurHor(this.__ptr, blurSize)
  55. }
  56. Image.prototype.getBrushX = function() {
  57. return Polycode.Image_getBrushX(this.__ptr)
  58. }
  59. Image.prototype.getBrushY = function() {
  60. return Polycode.Image_getBrushY(this.__ptr)
  61. }
  62. Image.prototype.isLoaded = function() {
  63. return Polycode.Image_isLoaded(this.__ptr)
  64. }
  65. Image.prototype.getType = function() {
  66. return Polycode.Image_getType(this.__ptr)
  67. }
  68. Image.prototype.getWidth = function() {
  69. return Polycode.Image_getWidth(this.__ptr)
  70. }
  71. Image.prototype.getHeight = function() {
  72. return Polycode.Image_getHeight(this.__ptr)
  73. }
  74. Image.prototype.premultiplyAlpha = function() {
  75. Polycode.Image_premultiplyAlpha(this.__ptr)
  76. }
  77. Image.prototype.savePNG = function(fileName) {
  78. return Polycode.Image_savePNG(this.__ptr, fileName)
  79. }