在控制台应用程序中,可以使用ascii转轮,如GUI等待游标,以指示工作正在完成。一个普通的旋转器循环使用以下4个字符:'|','/','-','\'

还有哪些循环动画序列可以为控制台应用程序增添趣味?


当前回答

Unicode有很多选择,包括⌚和⌛!

←↖↑↗→↘↓↙ ▁▂▃▄▅▆▇█▇▆▅▄▃▁ ▉▊▋▌▍▎▏▎▍▌▋▊▉ ▖▘▝▗ ┤┘┴└├┌┬┐ ◢◣◤◥ ◰◳◲◱ ◴◷◶◵ ◐◓◑◒ ◡◡⊙⊙◠◠ ⣾⣽⣻⢿⡿⣟⣯⣷⠁⠂⠄⡀⢀⠠⠐盲文⠈整个街区,甚至在随机订单http://www.fileformat.info/info/unicode/block/braille_patterns/images.htm

其他回答

我用了一个循环

Working. 
Working..
Working...

我知道这很鼓舞人心

试试这些

“+”,“x” 'v', '<', '^', '>'

在Javascript中使用一个jQuery选择器:

var spins = [
    "←↖↑↗→↘↓↙",
    "▁▃▄▅▆▇█▇▆▅▄▃",
    "▉▊▋▌▍▎▏▎▍▌▋▊▉",
    "▖▘▝▗",
    "┤┘┴└├┌┬┐",
    "◢◣◤◥",
    "◰ ◳ ◲ ◱",
    "◴◷◶◵",
    "◐◓◑◒",
    "|/-\\"];

    var spin = spins[0],
        title$ = $('title'),
        i=0;

    setInterval(function() {
        i = i==spin.length-1 ? 0 : ++i;
        title$.text('('+ spin[i] +') Loading...');
    },300);

由我的一个同事提供,这是C语言中一个漂亮的实现:

#define COW 2172
char* moo = "MO ";
void wrap() {
    int i,j;
    for(i=0;doSomething(i);i++)
        j=COW-moo[i&3],fputs(&j,stderr);
}

根据我的分析,它只能在至少有32位单词和ASCII字符集的小端计算机上工作。但它相当聪明。

制作一个可爱的“雨”效果:

using System;
using System.Text;
using System.Threading;

namespace CSharpSandbox
{
    class Program
    {
        static Random rnd = new Random();
        static char[,] Step(char[,] matrix)
        {
            int width = matrix.GetUpperBound(0) + 1;
            int height = matrix.GetUpperBound(1) + 1;

            char[,] res = new char[width, height];
            for (int h = 0; h < height; h++)
            {
                for (int w = 0; w < width; w++)
                {
                    char c;
                    if (h == 0)
                        c = rnd.Next(2) == 0 ? ' ' : '*';
                    else
                        c = matrix[w, h - 1];

                    res[w, h] = c;
                }
            }

            return res;
        }

        static string ToString(char[,] matrix)
        {
            int width = matrix.GetUpperBound(0) + 1;
            int height = matrix.GetUpperBound(1) + 1;
            StringBuilder sb = new StringBuilder();

            for (int h = 0; h < height; h++)
            {
                for (int w = 0; w < width; w++)
                {
                    sb.Append(matrix[w, h]);
                }
                sb.AppendLine();
            }
            return sb.ToString();
        }

        static Timer timer;
        static void Spinner()
        {
            char[,] matrix = new char[10, 5];
            timer = new Timer(_ =>
                {
                    string s = ToString(matrix);

                    Console.SetCursorPosition(0, 0);
                    Console.Write(s);

                    matrix = Step(matrix);
                },
                null,
                0,
                200);
        }

        static void Main(string[] args)
        {
            Spinner();
            Console.ReadLine();
        }
    }
}