Processing-Examples.deploy.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. smalltalk.addPackage('Processing-Examples', {});
  2. smalltalk.addClass('ProcessingClock', smalltalk.Object, ['processing', 'centerX', 'centerY', 'maxArmLength'], 'Processing-Examples');
  3. smalltalk.addMethod(
  4. "_draw",
  5. smalltalk.method({
  6. selector: "draw",
  7. fn: function () {
  8. var self = this;
  9. var drawBlock;
  10. drawBlock = function () {var now;var hoursPosition;var minutesPosition;var secondsPosition;smalltalk.send(self['@processing'], "_background_", [224]);now = smalltalk.send(smalltalk.Date || Date, "_new", []);hoursPosition = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(now, "_hours", []), "_\\\\", [12]), "__plus", [smalltalk.send(now, "_minutes", [])]), "__slash", [60]), "__slash", [12]);smalltalk.send(self, "_drawArm_lengthScale_weight_", [hoursPosition, 0.5, 5]);minutesPosition = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(now, "_minutes", []), "__plus", [smalltalk.send(now, "_seconds", [])]), "__slash", [60]), "__slash", [60]);smalltalk.send(self, "_drawArm_lengthScale_weight_", [minutesPosition, 0.8, 3]);secondsPosition = smalltalk.send(smalltalk.send(now, "_seconds", []), "__slash", [60]);return smalltalk.send(self, "_drawArm_lengthScale_weight_", [secondsPosition, 0.9, 1]);};
  11. return drawBlock;
  12. }
  13. }),
  14. smalltalk.ProcessingClock);
  15. smalltalk.addMethod(
  16. "_drawArm_lengthScale_weight_",
  17. smalltalk.method({
  18. selector: "drawArm:lengthScale:weight:",
  19. fn: function (aPosition, aLengthScale, aWeight) {
  20. var self = this;
  21. var myDX;
  22. var myDY;
  23. smalltalk.send(self['@processing'], "_strokeWeight_", [aWeight]);
  24. myDX = smalltalk.send(self['@centerX'], "__plus", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Math || Math, "_sin_", [smalltalk.send(smalltalk.send(aPosition, "__star", [2]), "__star", [smalltalk.send(smalltalk.Math || Math, "_PI", [])])]), "__star", [aLengthScale]), "__star", [self['@maxArmLength']])]);
  25. myDY = smalltalk.send(self['@centerY'], "__minus", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Math || Math, "_cos_", [smalltalk.send(smalltalk.send(aPosition, "__star", [2]), "__star", [smalltalk.send(smalltalk.Math || Math, "_PI", [])])]), "__star", [aLengthScale]), "__star", [self['@maxArmLength']])]);
  26. smalltalk.send(self['@processing'], "_line_y_dX_dy_", [self['@centerX'], self['@centerY'], myDX, myDY]);
  27. return self;
  28. }
  29. }),
  30. smalltalk.ProcessingClock);
  31. smalltalk.addMethod(
  32. "_initialize",
  33. smalltalk.method({
  34. selector: "initialize",
  35. fn: function () {
  36. var self = this;
  37. self['@processing'] = Processing.instances[0];
  38. self['@centerX'] = smalltalk.send(smalltalk.send(self['@processing'], "_width", []), "__slash", [2]);
  39. self['@centerY'] = smalltalk.send(smalltalk.send(self['@processing'], "_height", []), "__slash", [2]);
  40. self['@maxArmLength'] = smalltalk.send(smalltalk.Math || Math, "_min_or_", [self['@centerX'], self['@centerY']]);
  41. return self;
  42. }
  43. }),
  44. smalltalk.ProcessingClock);
  45. smalltalk.addMethod(
  46. "_processing",
  47. smalltalk.method({
  48. selector: "processing",
  49. fn: function () {
  50. var self = this;
  51. return self['@processing'];
  52. }
  53. }),
  54. smalltalk.ProcessingClock);
  55. smalltalk.addMethod(
  56. "_init",
  57. smalltalk.method({
  58. selector: "init",
  59. fn: function () {
  60. var self = this;
  61. var clock;
  62. var processing;
  63. var block;
  64. clock = smalltalk.send(smalltalk.ProcessingClock || ProcessingClock, "_new", []);
  65. processing = smalltalk.send(clock, "_processing", []);
  66. block = smalltalk.send(clock, "_draw", []);
  67. processing.draw = block;
  68. return self;
  69. }
  70. }),
  71. smalltalk.ProcessingClock.klass);