Processing-Examples.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. define("amber-processingclock/Processing-Examples", ["amber/boot", "amber_core/Kernel-Objects"], function($boot){
  2. var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var smalltalk=$core,_st=$recv,globals=$globals;
  4. $core.addPackage('Processing-Examples');
  5. $core.packages["Processing-Examples"].transport = {"type":"amd","amdNamespace":"amber-processingclock"};
  6. $core.addClass('ProcessingClock', $globals.Object, ['processing', 'centerX', 'centerY', 'maxArmLength'], 'Processing-Examples');
  7. $core.addMethod(
  8. $core.method({
  9. selector: "draw",
  10. protocol: 'not yet classified',
  11. fn: function (){
  12. var self=this;
  13. var drawBlock;
  14. function $Date(){return $globals.Date||(typeof Date=="undefined"?nil:Date)}
  15. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  16. return $core.withContext(function($ctx1) {
  17. //>>excludeEnd("ctx");
  18. var $2,$4,$3,$1,$6,$8,$7,$5,$9;
  19. drawBlock=(function(){
  20. var now,hoursPosition,minutesPosition,secondsPosition;
  21. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  22. return $core.withContext(function($ctx2) {
  23. //>>excludeEnd("ctx");
  24. $recv(self["@processing"])._background_((224));
  25. now=$recv($Date())._new();
  26. now;
  27. $2=$recv($recv(now)._hours()).__backslash_backslash((12));
  28. $4=$recv(now)._minutes();
  29. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  30. $ctx2.sendIdx["minutes"]=1;
  31. //>>excludeEnd("ctx");
  32. $3=$recv($4).__slash((60));
  33. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  34. $ctx2.sendIdx["/"]=2;
  35. //>>excludeEnd("ctx");
  36. $1=$recv($2).__plus($3);
  37. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  38. $ctx2.sendIdx["+"]=1;
  39. //>>excludeEnd("ctx");
  40. hoursPosition=$recv($1).__slash((12));
  41. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  42. $ctx2.sendIdx["/"]=1;
  43. //>>excludeEnd("ctx");
  44. hoursPosition;
  45. self._drawArm_lengthScale_weight_(hoursPosition,(0.5),(5));
  46. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  47. $ctx2.sendIdx["drawArm:lengthScale:weight:"]=1;
  48. //>>excludeEnd("ctx");
  49. $6=$recv(now)._minutes();
  50. $8=$recv(now)._seconds();
  51. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  52. $ctx2.sendIdx["seconds"]=1;
  53. //>>excludeEnd("ctx");
  54. $7=$recv($8).__slash((60));
  55. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  56. $ctx2.sendIdx["/"]=4;
  57. //>>excludeEnd("ctx");
  58. $5=$recv($6).__plus($7);
  59. minutesPosition=$recv($5).__slash((60));
  60. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  61. $ctx2.sendIdx["/"]=3;
  62. //>>excludeEnd("ctx");
  63. minutesPosition;
  64. self._drawArm_lengthScale_weight_(minutesPosition,(0.8),(3));
  65. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  66. $ctx2.sendIdx["drawArm:lengthScale:weight:"]=2;
  67. //>>excludeEnd("ctx");
  68. secondsPosition=$recv($recv(now)._seconds()).__slash((60));
  69. secondsPosition;
  70. return self._drawArm_lengthScale_weight_(secondsPosition,(0.9),(1));
  71. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  72. }, function($ctx2) {$ctx2.fillBlock({now:now,hoursPosition:hoursPosition,minutesPosition:minutesPosition,secondsPosition:secondsPosition},$ctx1,1)});
  73. //>>excludeEnd("ctx");
  74. });
  75. $9=drawBlock;
  76. return $9;
  77. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  78. }, function($ctx1) {$ctx1.fill(self,"draw",{drawBlock:drawBlock},$globals.ProcessingClock)});
  79. //>>excludeEnd("ctx");
  80. },
  81. //>>excludeStart("ide", pragmas.excludeIdeData);
  82. args: [],
  83. 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",
  84. referencedClasses: ["Date"],
  85. //>>excludeEnd("ide");
  86. messageSends: ["background:", "new", "/", "+", "\x5c\x5c", "hours", "minutes", "drawArm:lengthScale:weight:", "seconds"]
  87. }),
  88. $globals.ProcessingClock);
  89. $core.addMethod(
  90. $core.method({
  91. selector: "drawArm:lengthScale:weight:",
  92. protocol: 'not yet classified',
  93. fn: function (aPosition,aLengthScale,aWeight){
  94. var self=this;
  95. var myDX,myDY;
  96. function $Math(){return $globals.Math||(typeof Math=="undefined"?nil:Math)}
  97. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  98. return $core.withContext(function($ctx1) {
  99. //>>excludeEnd("ctx");
  100. var $1,$6,$7,$5,$4,$3,$2,$8,$12,$11,$10,$9;
  101. $recv(self["@processing"])._strokeWeight_(aWeight);
  102. $1=self["@centerX"];
  103. $6=$recv(aPosition).__star((2));
  104. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  105. $ctx1.sendIdx["*"]=4;
  106. //>>excludeEnd("ctx");
  107. $7=$recv($Math())._PI();
  108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  109. $ctx1.sendIdx["PI"]=1;
  110. //>>excludeEnd("ctx");
  111. $5=$recv($6).__star($7);
  112. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  113. $ctx1.sendIdx["*"]=3;
  114. //>>excludeEnd("ctx");
  115. $4=$recv($Math())._sin_($5);
  116. $3=$recv($4).__star(aLengthScale);
  117. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  118. $ctx1.sendIdx["*"]=2;
  119. //>>excludeEnd("ctx");
  120. $2=$recv($3).__star(self["@maxArmLength"]);
  121. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  122. $ctx1.sendIdx["*"]=1;
  123. //>>excludeEnd("ctx");
  124. myDX=$recv($1).__plus($2);
  125. $8=self["@centerY"];
  126. $12=$recv($recv(aPosition).__star((2))).__star($recv($Math())._PI());
  127. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  128. $ctx1.sendIdx["*"]=7;
  129. //>>excludeEnd("ctx");
  130. $11=$recv($Math())._cos_($12);
  131. $10=$recv($11).__star(aLengthScale);
  132. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  133. $ctx1.sendIdx["*"]=6;
  134. //>>excludeEnd("ctx");
  135. $9=$recv($10).__star(self["@maxArmLength"]);
  136. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  137. $ctx1.sendIdx["*"]=5;
  138. //>>excludeEnd("ctx");
  139. myDY=$recv($8).__minus($9);
  140. $recv(self["@processing"])._line_y_dX_dy_(self["@centerX"],self["@centerY"],myDX,myDY);
  141. return self;
  142. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  143. }, function($ctx1) {$ctx1.fill(self,"drawArm:lengthScale:weight:",{aPosition:aPosition,aLengthScale:aLengthScale,aWeight:aWeight,myDX:myDX,myDY:myDY},$globals.ProcessingClock)});
  144. //>>excludeEnd("ctx");
  145. },
  146. //>>excludeStart("ide", pragmas.excludeIdeData);
  147. args: ["aPosition", "aLengthScale", "aWeight"],
  148. 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.",
  149. referencedClasses: ["Math"],
  150. //>>excludeEnd("ide");
  151. messageSends: ["strokeWeight:", "+", "*", "sin:", "PI", "-", "cos:", "line:y:dX:dy:"]
  152. }),
  153. $globals.ProcessingClock);
  154. $core.addMethod(
  155. $core.method({
  156. selector: "firstProcessingInstance",
  157. protocol: 'not yet classified',
  158. fn: function (){
  159. var self=this;
  160. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  161. return $core.withContext(function($ctx1) {
  162. //>>excludeEnd("ctx");
  163. return Processing.instances[0];
  164. return self;
  165. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  166. }, function($ctx1) {$ctx1.fill(self,"firstProcessingInstance",{},$globals.ProcessingClock)});
  167. //>>excludeEnd("ctx");
  168. },
  169. //>>excludeStart("ide", pragmas.excludeIdeData);
  170. args: [],
  171. source: "firstProcessingInstance\x0a\x0a\x09<return Processing.instances[0]>",
  172. referencedClasses: [],
  173. //>>excludeEnd("ide");
  174. messageSends: []
  175. }),
  176. $globals.ProcessingClock);
  177. $core.addMethod(
  178. $core.method({
  179. selector: "initialize",
  180. protocol: 'not yet classified',
  181. fn: function (){
  182. var self=this;
  183. function $Math(){return $globals.Math||(typeof Math=="undefined"?nil:Math)}
  184. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  185. return $core.withContext(function($ctx1) {
  186. //>>excludeEnd("ctx");
  187. self["@processing"]=self._firstProcessingInstance();
  188. self["@centerX"]=$recv($recv(self["@processing"])._width()).__slash((2));
  189. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  190. $ctx1.sendIdx["/"]=1;
  191. //>>excludeEnd("ctx");
  192. self["@centerY"]=$recv($recv(self["@processing"])._height()).__slash((2));
  193. self["@maxArmLength"]=$recv($Math())._min_or_(self["@centerX"],self["@centerY"]);
  194. return self;
  195. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  196. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.ProcessingClock)});
  197. //>>excludeEnd("ctx");
  198. },
  199. //>>excludeStart("ide", pragmas.excludeIdeData);
  200. args: [],
  201. source: "initialize\x0aprocessing := self firstProcessingInstance.\x0acenterX := processing width / 2.\x0acenterY := processing height / 2.\x0amaxArmLength := Math min: centerX or: centerY.",
  202. referencedClasses: ["Math"],
  203. //>>excludeEnd("ide");
  204. messageSends: ["firstProcessingInstance", "/", "width", "height", "min:or:"]
  205. }),
  206. $globals.ProcessingClock);
  207. $core.addMethod(
  208. $core.method({
  209. selector: "processing",
  210. protocol: 'not yet classified',
  211. fn: function (){
  212. var self=this;
  213. var $1;
  214. $1=self["@processing"];
  215. return $1;
  216. },
  217. //>>excludeStart("ide", pragmas.excludeIdeData);
  218. args: [],
  219. source: "processing\x0a^processing",
  220. referencedClasses: [],
  221. //>>excludeEnd("ide");
  222. messageSends: []
  223. }),
  224. $globals.ProcessingClock);
  225. $core.addMethod(
  226. $core.method({
  227. selector: "init",
  228. protocol: 'not yet classified',
  229. fn: function (){
  230. var self=this;
  231. var clock,processing,block;
  232. function $ProcessingClock(){return $globals.ProcessingClock||(typeof ProcessingClock=="undefined"?nil:ProcessingClock)}
  233. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  234. return $core.withContext(function($ctx1) {
  235. //>>excludeEnd("ctx");
  236. clock=$recv($ProcessingClock())._new();
  237. processing=$recv(clock)._processing();
  238. block=$recv(clock)._draw();
  239. $recv(processing)._at_put_("draw",block);
  240. return self;
  241. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  242. }, function($ctx1) {$ctx1.fill(self,"init",{clock:clock,processing:processing,block:block},$globals.ProcessingClock.klass)});
  243. //>>excludeEnd("ctx");
  244. },
  245. //>>excludeStart("ide", pragmas.excludeIdeData);
  246. args: [],
  247. source: "init\x0a| clock processing block |\x0aclock := ProcessingClock new .\x0aprocessing := clock processing.\x0ablock := clock draw.\x0aprocessing at: 'draw' put: block",
  248. referencedClasses: ["ProcessingClock"],
  249. //>>excludeEnd("ide");
  250. messageSends: ["new", "processing", "draw", "at:put:"]
  251. }),
  252. $globals.ProcessingClock.klass);
  253. $core.addMethod(
  254. $core.method({
  255. selector: "start",
  256. protocol: 'not yet classified',
  257. fn: function (){
  258. var self=this;
  259. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  260. return $core.withContext(function($ctx1) {
  261. //>>excludeEnd("ctx");
  262. self._init();
  263. return self;
  264. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  265. }, function($ctx1) {$ctx1.fill(self,"start",{},$globals.ProcessingClock.klass)});
  266. //>>excludeEnd("ctx");
  267. },
  268. //>>excludeStart("ide", pragmas.excludeIdeData);
  269. args: [],
  270. source: "start\x0a\x0a self init",
  271. referencedClasses: [],
  272. //>>excludeEnd("ide");
  273. messageSends: ["init"]
  274. }),
  275. $globals.ProcessingClock.klass);
  276. });