Processing-Examples.deploy.js 4.6 KB

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