Ver Fonte

Fix processing example to make clock hands show correct time.

Thomas Rake há 11 anos atrás
pai
commit
841d7d02be

+ 1 - 1
processing/index.html

@@ -13,7 +13,7 @@
   </head> 
   <body> 
 	A Clock made with <a href="http://processingjs.org">Processing.js</a> and <a href"http://amber-lang.net/">Amber</a>
-	<p>Examine the <button onClick="smalltalk.Browser._openOn_(smalltalk.ProcessingClock)"> ProcessingClock class</button></p> 
+	<p>Examine the <button onClick="global_smalltalk.Browser._openOn_(global_smalltalk.ProcessingClock)"> ProcessingClock class</button></p> 
 	<p><canvas id="canvas1" width="200" height="200"></canvas></p>
 	<script id="script1" type="text/javascript">
 		// Simple way to attach js code to the canvas is by using a function

+ 3 - 3
processing/js/Processing-Examples.deploy.js

@@ -1,5 +1,6 @@
 (function(smalltalk,nil,_st){
 smalltalk.addPackage('Processing-Examples');
+
 smalltalk.addClass('ProcessingClock', smalltalk.Object, ['processing', 'centerX', 'centerY', 'maxArmLength'], 'Processing-Examples');
 smalltalk.addMethod(
 smalltalk.method({
@@ -16,10 +17,10 @@ return smalltalk.withContext(function($ctx2) {
 _st(self["@processing"])._background_((224));
 now=_st($Date())._new();
 now;
-hoursPosition=_st(_st(_st(_st(_st(now)._hours()).__backslash_backslash((12))).__plus(_st(now)._minutes())).__slash((60))).__slash((12));
+hoursPosition=_st(_st(_st(_st(now)._hours()).__backslash_backslash((12))).__plus(_st(_st(now)._minutes()).__slash((60)))).__slash((12));
 hoursPosition;
 self._drawArm_lengthScale_weight_(hoursPosition,(0.5),(5));
-minutesPosition=_st(_st(_st(_st(now)._minutes()).__plus(_st(now)._seconds())).__slash((60))).__slash((60));
+minutesPosition=_st(_st(_st(now)._minutes()).__plus(_st(_st(now)._seconds()).__slash((60)))).__slash((60));
 minutesPosition;
 self._drawArm_lengthScale_weight_(minutesPosition,(0.8),(3));
 secondsPosition=_st(_st(now)._seconds()).__slash((60));
@@ -104,5 +105,4 @@ return self}, function($ctx1) {$ctx1.fill(self,"init",{clock:clock,processing:pr
 messageSends: ["new", "processing", "draw", "at:put:"]}),
 smalltalk.ProcessingClock.klass);
 
-
 })(global_smalltalk,global_nil,global__st);

+ 4 - 4
processing/js/Processing-Examples.js

@@ -1,5 +1,6 @@
 (function(smalltalk,nil,_st){
 smalltalk.addPackage('Processing-Examples');
+
 smalltalk.addClass('ProcessingClock', smalltalk.Object, ['processing', 'centerX', 'centerY', 'maxArmLength'], 'Processing-Examples');
 smalltalk.addMethod(
 smalltalk.method({
@@ -17,10 +18,10 @@ return smalltalk.withContext(function($ctx2) {
 _st(self["@processing"])._background_((224));
 now=_st($Date())._new();
 now;
-hoursPosition=_st(_st(_st(_st(_st(now)._hours()).__backslash_backslash((12))).__plus(_st(now)._minutes())).__slash((60))).__slash((12));
+hoursPosition=_st(_st(_st(_st(now)._hours()).__backslash_backslash((12))).__plus(_st(_st(now)._minutes()).__slash((60)))).__slash((12));
 hoursPosition;
 self._drawArm_lengthScale_weight_(hoursPosition,(0.5),(5));
-minutesPosition=_st(_st(_st(_st(now)._minutes()).__plus(_st(now)._seconds())).__slash((60))).__slash((60));
+minutesPosition=_st(_st(_st(now)._minutes()).__plus(_st(_st(now)._seconds()).__slash((60)))).__slash((60));
 minutesPosition;
 self._drawArm_lengthScale_weight_(minutesPosition,(0.8),(3));
 secondsPosition=_st(_st(now)._seconds()).__slash((60));
@@ -31,7 +32,7 @@ $1=drawBlock;
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"draw",{drawBlock:drawBlock},smalltalk.ProcessingClock)})},
 args: [],
-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",
+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",
 messageSends: ["background:", "new", "/", "+", "minutes", "\x5c\x5c", "hours", "drawArm:lengthScale:weight:", "seconds"],
 referencedClasses: ["Date"]
 }),
@@ -134,5 +135,4 @@ referencedClasses: ["ProcessingClock"]
 }),
 smalltalk.ProcessingClock.klass);
 
-
 })(global_smalltalk,global_nil,global__st);

+ 2 - 2
processing/st/Processing-Examples.st

@@ -15,11 +15,11 @@ drawBlock := [
   now := Date new.
   
   "Moving hours arm by small increments"
-   hoursPosition := now hours \\ 12 + now minutes / 60 / 12.
+   hoursPosition := ((now hours \\ 12) + (now minutes / 60 )) /12 .
    self drawArm: hoursPosition lengthScale: 0.5 weight: 5.
    
    "Moving minutes arm by small increments"
-    minutesPosition := now minutes + now seconds / 60 / 60.
+    minutesPosition := (now minutes + (now seconds / 60))/60.
     self drawArm: minutesPosition lengthScale: 0.80 weight: 3.
 
     "Moving hour arm by second increments"