| 
									
										
										
										
											2008-08-05 17:30:47 -04:00
										 |  |  | USING: help.markup help.syntax ;
 | 
					
						
							| 
									
										
										
										
											2008-08-10 17:47:52 -04:00
										 |  |  | IN: animations | 
					
						
							| 
									
										
										
										
											2008-08-05 17:30:47 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | HELP: animate ( quot duration -- )
 | 
					
						
							| 
									
										
										
										
											2008-08-10 17:47:52 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-05 17:30:47 -04:00
										 |  |  | { $values | 
					
						
							|  |  |  |     { "quot" "a quot which uses " { $link progress } } | 
					
						
							|  |  |  |     { "duration" "a duration of time" } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-08-10 17:47:52 -04:00
										 |  |  | { $description | 
					
						
							|  |  |  |     { $link animate } " calls " { $link reset-progress } | 
					
						
							|  |  |  |     " , then continously calls the given quot until the" | 
					
						
							|  |  |  |     " duration of time has elapsed. The quot should use " | 
					
						
							|  |  |  |     { $link progress } " at least once." | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $examples | 
					
						
							|  |  |  |     { $unchecked-example  | 
					
						
							|  |  |  |         "USING: animations calendar threads prettyprint ;" | 
					
						
							|  |  |  |         "[ 1 sleep progress unparse write \" ms elapsed\" print ] " | 
					
						
							|  |  |  |         "1/20 seconds animate ;" | 
					
						
							|  |  |  |         "46 ms elapsed\n17 ms elapsed" | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     { $notes "The amount of time elapsed between these iterations will very." } | 
					
						
							| 
									
										
										
										
											2008-08-05 17:30:47 -04:00
										 |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: reset-progress ( -- )
 | 
					
						
							| 
									
										
										
										
											2008-08-10 17:47:52 -04:00
										 |  |  | { $description | 
					
						
							|  |  |  |     "Initiates the timer. Call this before using " | 
					
						
							|  |  |  |     "a loop which makes use of " { $link progress } "." | 
					
						
							|  |  |  | } ;
 | 
					
						
							| 
									
										
										
										
											2008-08-05 17:30:47 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 18:12:41 -04:00
										 |  |  | HELP: progress | 
					
						
							| 
									
										
										
										
											2008-08-05 17:30:47 -04:00
										 |  |  | { $values { "time" "an integer" } } | 
					
						
							| 
									
										
										
										
											2008-08-10 17:47:52 -04:00
										 |  |  | { $description | 
					
						
							|  |  |  |     "Gives the time elapsed since the last time" | 
					
						
							|  |  |  |     " this word was called, in milliseconds."  | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $examples | 
					
						
							|  |  |  |     { $unchecked-example | 
					
						
							|  |  |  |         "USING: animations threads prettyprint ;" | 
					
						
							|  |  |  |         "reset-progress 3 " | 
					
						
							|  |  |  |         "[ 1 sleep progress unparse write \"ms elapsed\" print ] " | 
					
						
							|  |  |  |         "times ;" | 
					
						
							|  |  |  |         "31 ms elapsed\n18 ms elapsed\n16 ms elapsed" | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     { $notes "The amount of time elapsed between these iterations will very." } | 
					
						
							| 
									
										
										
										
											2008-08-05 17:30:47 -04:00
										 |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-10 17:47:52 -04:00
										 |  |  | ARTICLE: "animations" "Animations" | 
					
						
							|  |  |  | "Provides a lightweight framework for properly simulating continuous" | 
					
						
							|  |  |  | " functions of real time. This framework helps one create animations " | 
					
						
							|  |  |  | "that use rates which do not change across platforms. The speed of the " | 
					
						
							|  |  |  | "computer should correlate with the smoothness of the animation, not " | 
					
						
							|  |  |  | "the speed of the animation!" | 
					
						
							| 
									
										
										
										
											2008-08-05 17:30:47 -04:00
										 |  |  | { $subsection animate } | 
					
						
							|  |  |  | { $subsection reset-progress } | 
					
						
							|  |  |  | { $subsection progress } | 
					
						
							| 
									
										
										
										
											2008-08-10 17:47:52 -04:00
										 |  |  | ! A little talk about when to use progress and when to use animate | 
					
						
							|  |  |  |     { $link progress } " specifically provides the length of time since " | 
					
						
							|  |  |  |     { $link reset-progress } " was called, and also calls " | 
					
						
							|  |  |  |     { $link reset-progress } " as its last action. This can be directly " | 
					
						
							|  |  |  |     "used when one's quote runs for a specific number of iterations, instead " | 
					
						
							|  |  |  |     "of a length of time. If the animation is like most, and is expected to " | 
					
						
							|  |  |  |     "run for a specific length of time, " { $link animate } " should be used." ;
 | 
					
						
							|  |  |  | ABOUT: "animations" |