xts_test.js.tns 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Xtase drawing routines demo
  2. var t = require('nsp/texture');
  3. var k = require('nsp/keys');
  4. var width = 320;
  5. var height = 240;
  6. var screen = new t.Texture(width, height);
  7. screen.fill(0x0000);
  8. print(width+"x"+height+" press Enter");
  9. k.waitKeyPressed();
  10. var time_start = Date.now();
  11. screen.fill(0x0000);
  12. var RED = 31 << 11 | 0 << 5 | 0;
  13. var GREEN = 0 << 11 | 31 << 5 | 0;
  14. var BLUE = 0 << 11 | 0 << 5 | 31;
  15. var PINK = 31 << 11 | 0 << 5 | 31;
  16. // R G B
  17. screen.drawLine(0,0,width,height, 31 << 11 | 31 << 5 | 31 );
  18. screen.drawRect(50,50,100,70, RED );
  19. screen.fillRect(50+20,50+20,100,70, GREEN );
  20. var pts = [ 200, 40,//
  21. 220, 60,//
  22. 220, 80,//
  23. 200, 120,//
  24. 180, 80, //
  25. ];
  26. // screen.drawPolyLines(pts, pts.length/2, GREEN);
  27. screen.fillPolygon(pts, pts.length / 2, BLUE);
  28. pts = [ 200, 40,//
  29. 220 + 30, 60,//
  30. 220 + 30, 80,//
  31. 200 + 30, 120,//
  32. 180 + 30, 80, //
  33. 210 + 30, 70, //
  34. ];
  35. screen.fillPolygon(pts, pts.length / 2, GREEN);
  36. screen.drawPolyLines(pts, pts.length/2, RED);
  37. var SCREEN_WIDTH = width;
  38. var SCREEN_HEIGHT = height;
  39. screen.drawCircle(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 20, RED);
  40. screen.fillCircle(SCREEN_WIDTH - 10, SCREEN_HEIGHT / 2, 20, PINK);
  41. for(var i=0; i < SCREEN_WIDTH / 40; i++) {
  42. screen.fillCircle( (i*40)+20, SCREEN_HEIGHT -40, 20, PINK);
  43. }
  44. screen.display();
  45. print(width+"x"+height+" in "+(Date.now()-time_start)+" msec.");
  46. k.waitKeyPressed();