[2¾6×2úN._7Ý.Λ,т.W’IEx.Helpers.Š‡’.E
If only 05AB1E had a builtin to clear the console.. :/
Starts at frame 6, and rotates indefinitely in reversed order. Uses 0
instead of #
as character, although could alternatively use 1
/2
for the same byte-count by replacing the ¾
with X
/Y
respectively. Sleeps for 100 ms between each print, but could alternatively sleep any of these times for the same byte-count: 1
/2
/3
/4
/5
/6
/7
/8
/9
/T
(10)/₂
(26)/₆
(36)/₃
(95)/₅
(255)/₁
(256)/₄
(1000), by replacing the т
.
Explanation:
[ # Loop indefinitely:
2 # Push 2
¾ # Push 0
6× # Repeat it 6 times as string: "000000"
2ú # Pad with 2 leading spaces: " 000000"
N._ # Rotate the string the loop-index amount of times towards the left
7Ý # Push list [0,1,2,3,4,5,6,7]
.Λ # Use the modifiable Canvas builtin with these three options
, # Pop and print it with trailing newline
т.W # Sleep for 100 ms
’IEx.Helpers.Š‡’ # Push dictionary string "IEx.Helpers.clear"
.E # Evaluate and execute it as Elixir code
See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ’IEx.Helpers.Š‡’
is "IEx.Helpers.clear"
.
The Canvas Builtin uses three arguments to draw a shape:
- Length of the lines we want to draw
- Character/string to draw
- The direction to draw in, where each digit represents a certain direction:
7 0 1
↖ ↑ ↗
6 ← X → 2
↙ ↓ ↘
5 4 3
2¾6×2úN._7Ý
creates the following Canvas arguments:
- Length:
2
- Characters:
" 000000"
(potentially rotated)
- Directions:
[0,1,2,3,4,5,6,7]
, which translate to \$[↑,↗,→,↘,↓,↙,←,↖]\$
Try the first two steps online.
Step 1: Draw 2 characters (" "
) in direction 0/↑
:
Step 2: Draw 2-1 characters ("0"
) in direction 1/↗
:
0
Step 3: Draw 2-1 character ("0"
) in direction 2/→
:
00
Step 4: Draw 2-1 character ("0"
) in direction 3/↘
:
00
0
etc.
Step 7: Draw 2-1 character ("0"
) in direction 6/←
:
00
0
0
00
Step 8: Draw 2-1 character (" "
) in direction 7/↖
:
00
0
0
00
See this 05AB1E tip of mine for an in-depth explanation of the Canvas builtin.
I don't have a gif to see the animation in action, because IEx.Helpers.clear
(or any clear through Elixir-eval for that matter) doesn't seem to work on Windows machines.. I tried to enable ANSI escape codes in the Windows Console by modifying the Registry on my PC, but wasn't able to get it to work. This should work as intended on a non-Windows machines, though.
As alternative, here the outputs where the clear-command is ignored and the infinite loop [
is replaced with a loop of eight 8F
: Try it online.
The animation has to be displayed at the same position on screen for every frame.
Can this be done by writing to stdout and letting the screen scroll so that the animation appears at the bottom? Otherwise you're excluding a lot of languages. \$\endgroup\$Flickering is fine as long as the user can tell what is being animated.
This may require delay, by one of: pausing by sleep or in a delay loop; printing each symbol multiple times (within the delay loop); waiting for a keypress from the user. Which are acceptable? Note that this requirement is subjective, as it could depend on both the user's eyes and the hardware used. You could specify a frame rate, or allow it to run as fast as the hardware allows, even if the user can't see what's going on, so long as the output is correct. \$\endgroup\$