2
0

Processing-Examples.js 7.0 KB

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