Processing-Examples.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. define("amber_examples_processing/Processing-Examples", ["amber/boot", "amber_core/Kernel-Objects"], function($boot){
  2. var smalltalk=$boot.vm,nil=$boot.nil,_st=$boot.asReceiver,globals=$boot.globals;
  3. smalltalk.addPackage('Processing-Examples');
  4. smalltalk.packages["Processing-Examples"].transport = {"type":"amd","amdNamespace":"amber_examples_processing"};
  5. smalltalk.addClass('ProcessingClock', globals.Object, ['processing', 'centerX', 'centerY', 'maxArmLength'], 'Processing-Examples');
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "draw",
  9. protocol: 'not yet classified',
  10. fn: function (){
  11. var self=this;
  12. var drawBlock;
  13. function $Date(){return globals.Date||(typeof Date=="undefined"?nil:Date)}
  14. return smalltalk.withContext(function($ctx1) {
  15. var $2,$4,$3,$1,$6,$8,$7,$5,$9;
  16. drawBlock=(function(){
  17. var now,hoursPosition,minutesPosition,secondsPosition;
  18. return smalltalk.withContext(function($ctx2) {
  19. _st(self["@processing"])._background_((224));
  20. now=_st($Date())._new();
  21. now;
  22. $2=_st(_st(now)._hours()).__backslash_backslash((12));
  23. $4=_st(now)._minutes();
  24. $ctx2.sendIdx["minutes"]=1;
  25. $3=_st($4).__slash((60));
  26. $ctx2.sendIdx["/"]=2;
  27. $1=_st($2).__plus($3);
  28. $ctx2.sendIdx["+"]=1;
  29. hoursPosition=_st($1).__slash((12));
  30. $ctx2.sendIdx["/"]=1;
  31. hoursPosition;
  32. self._drawArm_lengthScale_weight_(hoursPosition,(0.5),(5));
  33. $ctx2.sendIdx["drawArm:lengthScale:weight:"]=1;
  34. $6=_st(now)._minutes();
  35. $8=_st(now)._seconds();
  36. $ctx2.sendIdx["seconds"]=1;
  37. $7=_st($8).__slash((60));
  38. $ctx2.sendIdx["/"]=4;
  39. $5=_st($6).__plus($7);
  40. minutesPosition=_st($5).__slash((60));
  41. $ctx2.sendIdx["/"]=3;
  42. minutesPosition;
  43. self._drawArm_lengthScale_weight_(minutesPosition,(0.8),(3));
  44. $ctx2.sendIdx["drawArm:lengthScale:weight:"]=2;
  45. secondsPosition=_st(_st(now)._seconds()).__slash((60));
  46. secondsPosition;
  47. return self._drawArm_lengthScale_weight_(secondsPosition,(0.9),(1));
  48. }, function($ctx2) {$ctx2.fillBlock({now:now,hoursPosition:hoursPosition,minutesPosition:minutesPosition,secondsPosition:secondsPosition},$ctx1,1)})});
  49. $9=drawBlock;
  50. return $9;
  51. }, function($ctx1) {$ctx1.fill(self,"draw",{drawBlock:drawBlock},globals.ProcessingClock)})},
  52. args: [],
  53. source: "draw\x0a| drawBlock |\x0a\x0adrawBlock := [\x0a | now hoursPosition minutesPosition secondsPosition | \x0a processing background: 224.\x0a \x0a now := Date new.\x0a \x0a \x22Moving hours arm by small increments\x22\x0a hoursPosition := ((now hours \x5c\x5c 12) + (now minutes / 60 )) /12 .\x0a self drawArm: hoursPosition lengthScale: 0.5 weight: 5.\x0a \x0a \x22Moving minutes arm by small increments\x22\x0a minutesPosition := (now minutes + (now seconds / 60))/60.\x0a self drawArm: minutesPosition lengthScale: 0.80 weight: 3.\x0a\x0a \x22Moving hour arm by second increments\x22\x0a secondsPosition := now seconds / 60.\x0a self drawArm: secondsPosition lengthScale: 0.90 weight: 1.\x0a ].\x0a\x0a^drawBlock",
  54. messageSends: ["background:", "new", "/", "+", "\x5c\x5c", "hours", "minutes", "drawArm:lengthScale:weight:", "seconds"],
  55. referencedClasses: ["Date"]
  56. }),
  57. globals.ProcessingClock);
  58. smalltalk.addMethod(
  59. smalltalk.method({
  60. selector: "drawArm:lengthScale:weight:",
  61. protocol: 'not yet classified',
  62. fn: function (aPosition,aLengthScale,aWeight){
  63. var self=this;
  64. var myDX,myDY;
  65. function $Math(){return globals.Math||(typeof Math=="undefined"?nil:Math)}
  66. return smalltalk.withContext(function($ctx1) {
  67. var $1,$6,$7,$5,$4,$3,$2,$8,$12,$11,$10,$9;
  68. _st(self["@processing"])._strokeWeight_(aWeight);
  69. $1=self["@centerX"];
  70. $6=_st(aPosition).__star((2));
  71. $ctx1.sendIdx["*"]=4;
  72. $7=_st($Math())._PI();
  73. $ctx1.sendIdx["PI"]=1;
  74. $5=_st($6).__star($7);
  75. $ctx1.sendIdx["*"]=3;
  76. $4=_st($Math())._sin_($5);
  77. $3=_st($4).__star(aLengthScale);
  78. $ctx1.sendIdx["*"]=2;
  79. $2=_st($3).__star(self["@maxArmLength"]);
  80. $ctx1.sendIdx["*"]=1;
  81. myDX=_st($1).__plus($2);
  82. $8=self["@centerY"];
  83. $12=_st(_st(aPosition).__star((2))).__star(_st($Math())._PI());
  84. $ctx1.sendIdx["*"]=7;
  85. $11=_st($Math())._cos_($12);
  86. $10=_st($11).__star(aLengthScale);
  87. $ctx1.sendIdx["*"]=6;
  88. $9=_st($10).__star(self["@maxArmLength"]);
  89. $ctx1.sendIdx["*"]=5;
  90. myDY=_st($8).__minus($9);
  91. _st(self["@processing"])._line_y_dX_dy_(self["@centerX"],self["@centerY"],myDX,myDY);
  92. return self}, function($ctx1) {$ctx1.fill(self,"drawArm:lengthScale:weight:",{aPosition:aPosition,aLengthScale:aLengthScale,aWeight:aWeight,myDX:myDX,myDY:myDY},globals.ProcessingClock)})},
  93. args: ["aPosition", "aLengthScale", "aWeight"],
  94. source: "drawArm: aPosition lengthScale: aLengthScale weight: aWeight\x0a| myDX myDY |\x0aprocessing strokeWeight: aWeight.\x0amyDX := centerX \x0a\x09\x09\x09+ ((Math sin: (aPosition * 2 * Math PI))\x0a\x09\x09\x09* aLengthScale * maxArmLength).\x0amyDY := centerY \x0a\x09\x09\x09- ((Math cos: (aPosition * 2 * Math PI))\x0a\x09\x09\x09* aLengthScale * maxArmLength).\x0a\x0aprocessing line: centerX y: centerY dX: myDX dy: myDY.",
  95. messageSends: ["strokeWeight:", "+", "*", "sin:", "PI", "-", "cos:", "line:y:dX:dy:"],
  96. referencedClasses: ["Math"]
  97. }),
  98. globals.ProcessingClock);
  99. smalltalk.addMethod(
  100. smalltalk.method({
  101. selector: "firstProcessingInstance",
  102. protocol: 'not yet classified',
  103. fn: function (){
  104. var self=this;
  105. return smalltalk.withContext(function($ctx1) {
  106. return Processing.instances[0];
  107. return self}, function($ctx1) {$ctx1.fill(self,"firstProcessingInstance",{},globals.ProcessingClock)})},
  108. args: [],
  109. source: "firstProcessingInstance\x0a\x0a\x09<return Processing.instances[0]>",
  110. messageSends: [],
  111. referencedClasses: []
  112. }),
  113. globals.ProcessingClock);
  114. smalltalk.addMethod(
  115. smalltalk.method({
  116. selector: "initialize",
  117. protocol: 'not yet classified',
  118. fn: function (){
  119. var self=this;
  120. function $Math(){return globals.Math||(typeof Math=="undefined"?nil:Math)}
  121. return smalltalk.withContext(function($ctx1) {
  122. self["@processing"]=self._firstProcessingInstance();
  123. self["@centerX"]=_st(_st(self["@processing"])._width()).__slash((2));
  124. $ctx1.sendIdx["/"]=1;
  125. self["@centerY"]=_st(_st(self["@processing"])._height()).__slash((2));
  126. self["@maxArmLength"]=_st($Math())._min_or_(self["@centerX"],self["@centerY"]);
  127. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ProcessingClock)})},
  128. args: [],
  129. source: "initialize\x0aprocessing := self firstProcessingInstance.\x0acenterX := processing width / 2.\x0acenterY := processing height / 2.\x0amaxArmLength := Math min: centerX or: centerY.",
  130. messageSends: ["firstProcessingInstance", "/", "width", "height", "min:or:"],
  131. referencedClasses: ["Math"]
  132. }),
  133. globals.ProcessingClock);
  134. smalltalk.addMethod(
  135. smalltalk.method({
  136. selector: "processing",
  137. protocol: 'not yet classified',
  138. fn: function (){
  139. var self=this;
  140. var $1;
  141. $1=self["@processing"];
  142. return $1;
  143. },
  144. args: [],
  145. source: "processing\x0a^processing",
  146. messageSends: [],
  147. referencedClasses: []
  148. }),
  149. globals.ProcessingClock);
  150. smalltalk.addMethod(
  151. smalltalk.method({
  152. selector: "init",
  153. protocol: 'not yet classified',
  154. fn: function (){
  155. var self=this;
  156. var clock,processing,block;
  157. function $ProcessingClock(){return globals.ProcessingClock||(typeof ProcessingClock=="undefined"?nil:ProcessingClock)}
  158. return smalltalk.withContext(function($ctx1) {
  159. clock=_st($ProcessingClock())._new();
  160. processing=_st(clock)._processing();
  161. block=_st(clock)._draw();
  162. _st(processing)._at_put_("draw",block);
  163. return self}, function($ctx1) {$ctx1.fill(self,"init",{clock:clock,processing:processing,block:block},globals.ProcessingClock.klass)})},
  164. args: [],
  165. source: "init\x0a| clock processing block |\x0aclock := ProcessingClock new .\x0aprocessing := clock processing.\x0ablock := clock draw.\x0aprocessing at: 'draw' put: block",
  166. messageSends: ["new", "processing", "draw", "at:put:"],
  167. referencedClasses: ["ProcessingClock"]
  168. }),
  169. globals.ProcessingClock.klass);
  170. });