Processing-Examples.deploy.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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,myDY;
  38. return smalltalk.withContext(function($ctx1) { _st(self["@processing"])._strokeWeight_(aWeight);
  39. myDX=_st(self["@centerX"]).__plus(_st(_st(_st((smalltalk.Math || Math))._sin_(_st(_st(aPosition).__star((2))).__star(_st((smalltalk.Math || Math))._PI()))).__star(aLengthScale)).__star(self["@maxArmLength"]));
  40. myDY=_st(self["@centerY"]).__minus(_st(_st(_st((smalltalk.Math || Math))._cos_(_st(_st(aPosition).__star((2))).__star(_st((smalltalk.Math || Math))._PI()))).__star(aLengthScale)).__star(self["@maxArmLength"]));
  41. _st(self["@processing"])._line_y_dX_dy_(self["@centerX"],self["@centerY"],myDX,myDY);
  42. return self}, function($ctx1) {$ctx1.fill(self,"drawArm:lengthScale:weight:",{aPosition:aPosition,aLengthScale:aLengthScale,aWeight:aWeight,myDX:myDX,myDY:myDY}, smalltalk.ProcessingClock)})},
  43. messageSends: ["strokeWeight:", "+", "*", "sin:", "PI", "-", "cos:", "line:y:dX:dy:"]}),
  44. smalltalk.ProcessingClock);
  45. smalltalk.addMethod(
  46. "_firstProcessingInstance",
  47. smalltalk.method({
  48. selector: "firstProcessingInstance",
  49. fn: function (){
  50. var self=this;
  51. return smalltalk.withContext(function($ctx1) { return Processing.instances[0];
  52. return self}, function($ctx1) {$ctx1.fill(self,"firstProcessingInstance",{}, smalltalk.ProcessingClock)})},
  53. messageSends: []}),
  54. smalltalk.ProcessingClock);
  55. smalltalk.addMethod(
  56. "_initialize",
  57. smalltalk.method({
  58. selector: "initialize",
  59. fn: function (){
  60. var self=this;
  61. return smalltalk.withContext(function($ctx1) { self["@processing"]=_st(self)._firstProcessingInstance();
  62. self["@centerX"]=_st(_st(self["@processing"])._width()).__slash((2));
  63. self["@centerY"]=_st(_st(self["@processing"])._height()).__slash((2));
  64. self["@maxArmLength"]=_st((smalltalk.Math || Math))._min_or_(self["@centerX"],self["@centerY"]);
  65. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.ProcessingClock)})},
  66. messageSends: ["firstProcessingInstance", "/", "width", "height", "min:or:"]}),
  67. smalltalk.ProcessingClock);
  68. smalltalk.addMethod(
  69. "_processing",
  70. smalltalk.method({
  71. selector: "processing",
  72. fn: function (){
  73. var self=this;
  74. return smalltalk.withContext(function($ctx1) { var $1;
  75. $1=self["@processing"];
  76. return $1;
  77. }, function($ctx1) {$ctx1.fill(self,"processing",{}, smalltalk.ProcessingClock)})},
  78. messageSends: []}),
  79. smalltalk.ProcessingClock);
  80. smalltalk.addMethod(
  81. "_init",
  82. smalltalk.method({
  83. selector: "init",
  84. fn: function (){
  85. var self=this;
  86. var clock,processing,block;
  87. return smalltalk.withContext(function($ctx1) { clock=_st((smalltalk.ProcessingClock || ProcessingClock))._new();
  88. processing=_st(clock)._processing();
  89. block=_st(clock)._draw();
  90. _st(processing)._at_put_("draw",block);
  91. return self}, function($ctx1) {$ctx1.fill(self,"init",{clock:clock,processing:processing,block:block}, smalltalk.ProcessingClock.klass)})},
  92. messageSends: ["new", "processing", "draw", "at:put:"]}),
  93. smalltalk.ProcessingClock.klass);