Processing-Examples.deploy.js 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. return smalltalk.withContext(function($ctx1) { var $1;
  11. drawBlock=(function(){
  12. var now,hoursPosition,minutesPosition,secondsPosition;
  13. return smalltalk.withContext(function($ctx2) { _st(self["@processing"])._background_((224));
  14. now=_st((smalltalk.Date || Date))._new();
  15. now;
  16. hoursPosition=_st(_st(_st(_st(_st(now)._hours()).__backslash_backslash((12))).__plus(_st(now)._minutes())).__slash((60))).__slash((12));
  17. hoursPosition;
  18. _st(self)._drawArm_lengthScale_weight_(hoursPosition,(0.5),(5));
  19. minutesPosition=_st(_st(_st(_st(now)._minutes()).__plus(_st(now)._seconds())).__slash((60))).__slash((60));
  20. minutesPosition;
  21. _st(self)._drawArm_lengthScale_weight_(minutesPosition,(0.8),(3));
  22. secondsPosition=_st(_st(now)._seconds()).__slash((60));
  23. secondsPosition;
  24. return _st(self)._drawArm_lengthScale_weight_(secondsPosition,(0.9),(1));
  25. }, function($ctx2) {$ctx2.fillBlock({now:now,hoursPosition:hoursPosition,minutesPosition:minutesPosition,secondsPosition:secondsPosition},$ctx1)})});
  26. $1=drawBlock;
  27. return $1;
  28. }, function($ctx1) {$ctx1.fill(self,"draw",{drawBlock:drawBlock}, smalltalk.ProcessingClock)})},
  29. messageSends: ["background:", "new", "/", "+", "minutes", "\x5c\x5c", "hours", "drawArm:lengthScale:weight:", "seconds"]}),
  30. smalltalk.ProcessingClock);
  31. smalltalk.addMethod(
  32. "_drawArm_lengthScale_weight_",
  33. smalltalk.method({
  34. selector: "drawArm:lengthScale:weight:",
  35. fn: function (aPosition, aLengthScale, aWeight) {
  36. var self = this;
  37. var myDX;
  38. var myDY;
  39. smalltalk.send(self['@processing'], "_strokeWeight_", [aWeight]);
  40. 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']])]);
  41. 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']])]);
  42. smalltalk.send(self['@processing'], "_line_y_dX_dy_", [self['@centerX'], self['@centerY'], myDX, myDY]);
  43. return self;
  44. },
  45. messageSends: ["strokeWeight:", "+", "*", "sin:", "PI", "-", "cos:", "line:y:dX:dy:"]}),
  46. smalltalk.ProcessingClock);
  47. smalltalk.addMethod(
  48. "_initialize",
  49. smalltalk.method({
  50. selector: "initialize",
  51. fn: function () {
  52. var self = this;
  53. self['@processing'] = Processing.instances[0];
  54. self['@centerX'] = smalltalk.send(smalltalk.send(self['@processing'], "_width", []), "__slash", [2]);
  55. self['@centerY'] = smalltalk.send(smalltalk.send(self['@processing'], "_height", []), "__slash", [2]);
  56. self['@maxArmLength'] = smalltalk.send(smalltalk.Math || Math, "_min_or_", [self['@centerX'], self['@centerY']]);
  57. return self;
  58. },
  59. messageSends: ["/", "width", "height", "min:or:"]}),
  60. smalltalk.ProcessingClock);
  61. smalltalk.addMethod(
  62. "_processing",
  63. smalltalk.method({
  64. selector: "processing",
  65. fn: function () {
  66. var self = this;
  67. return self['@processing'];
  68. },
  69. messageSends: []}),
  70. smalltalk.ProcessingClock);
  71. smalltalk.addMethod(
  72. "_init",
  73. smalltalk.method({
  74. selector: "init",
  75. fn: function () {
  76. var self = this;
  77. var clock;
  78. var processing;
  79. var block;
  80. clock = smalltalk.send(smalltalk.ProcessingClock || ProcessingClock, "_new", []);
  81. processing = smalltalk.send(clock, "_processing", []);
  82. block = smalltalk.send(clock, "_draw", []);
  83. processing.draw = block;
  84. return self;
  85. },
  86. messageSends: ["new", "processing", "draw"]}),
  87. smalltalk.ProcessingClock.klass);