Spinning rod animation/Text: Difference between revisions

Added Easylang
(J)
(Added Easylang)
 
(8 intermediate revisions by 4 users not shown)
Line 215:
(message "%c" char)
(sit-for 0.25)))</syntaxhighlight>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
 
 
<syntaxhighlight lang="Delphi">
 
procedure SpinningRod(Memo: TMemo);
var I: integer;
const CA: array [0..3] of char = ('|','/','-','\');
begin
LastKey:=#0;
for I:=0 to 1000 do
begin
Memo.SetFocus;
Memo.Lines.Clear;
Memo.Lines.Add(CA[I mod 4]+' - Press Any Key To Stop');
Sleep(250);
if (LastKey<>#0) or Application.Terminated then break;
Application.ProcessMessages;
end;
end;
 
</syntaxhighlight>
{{out}}
<pre>
/ - Press Any Key To Stop
Elapsed Time: 12.251 Sec.
</pre>
 
 
=={{header|EasyLang}}==
 
[https://easylang.dev/show/#cod=Lc09CgIxEAXgfk7xWCwUYcmuaOdJxEKyAwZMAkkQ8Qw2/tt5RY9gHtp8w4M3M3a0WmOJXJLdblJG83mfzqhcyJXcyJ08yJO8Gil6KNkdFQsjPu4VvcHMSAwozmsSAC4M9faYY4puAh+HDjsNsPUrC7zBUBu/zE2Ytp9LK/8gXw== Run it]
 
<syntaxhighlight>
c$[] = strchars "🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘"
textsize 60
move 20 30
on timer
ind = (ind + 1) mod1 len c$[]
text c$[ind]
timer 0.25
.
timer 0
</syntaxhighlight>
 
=={{header|Factor}}==
Line 367 ⟶ 414:
Assuming you have terminal support for the hour wingdings, this would also work:
 
<syntaxhighlight lang=J>0.125 spin '🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧'</syntaxhighlight>
 
or
 
<syntaxhighlight lang=J>0.25 spin a.{~240 159 149&,&>144+i.24</syntaxhighlight>
 
Note also that you could animate lines of text rather than individual characters. For example, converting words to lines:
 
<syntaxhighlight lang=J>0.5 spin >;:'this is a test'</syntaxsyntaxhighlight>
 
AnythingHowever, anything which takes multiple lines wouldn't work here. For that you'd need to clear the screen instead of using a simple carriage return. (Clearing the screen is completely doable, but the easy approaches are either embedded in gui mechanisms which sort of defeats the purpose of ascii art animation, or are not supported by some "purely textual" terminals.)
 
=={{header|Java}}==
Line 1,578 ⟶ 1,629:
=={{header|Wren}}==
{{trans|Kotlin}}
<syntaxhighlight lang="ecmascriptwren">import "io" for Stdout
import "timer" for Timer
 
var ESC = "\u001b"
 
var a = "|/-\\"
System.write("%(ESC)\e[?25l") // hide the cursor
var start = System.clock
var asleep = 0
while (true) {
for (i in 0..3) {
System.write("%(ESC)\e[2J") // clear terminal
System.write("%(ESC)\e[0;0H") // place cursor at top left corner
for (j in 0..79) { // 80 character terminal width, say
System.write(a[i])
}
Stdout.flush()
Timer.sleep(250) // suspends both current fiber & System.clock
asleep = asleep + 250
}
Line 1,602 ⟶ 1,651:
if (now * 1000 + asleep - start * 1000 >= 20000) break
}
System.print("%(ESC)\e[?25h") // restore the cursor</syntaxhighlight>
 
=={{header|XPL0}}==
2,063

edits