Ruby,150个字符
a=(0..15).map{|i|[0.9-3*i*=0.02,i]}
[9,*a[0,11],*(z=a.reverse)[5,11],11,*z,*a,2,11,6,*[0.2]*9].map{|x,y|c=Time.now
1until Time.now-c>x/3
sleep y||x%3}
到目前为止,这还不算很短,但是我认为输出结果还不错,所以我想还是应该发布此内容。与大多数其他解决方案一样,您可能必须通过在Ruby前缀上将Ruby进程固定到某个核心taskset -c $core
。
该代码是旋转/休眠一定时间的简单组合,这应该使其具有一定的可移植性。通过改变旋转/睡眠时间的比率可以创建平滑的渐变。
降低CPU采样频率会使边缘看起来更好一些:
通过在字母表中添加更多字母(AILMNUVW
有些可以识别),我们还可以写一些其他单词:
这些图片是使用以下代码生成的:
def gradient num_samples, direction, base = 0.3, increment = 0.02, scale = 1
range = [*0..num_samples]
samples = case direction
when :up then range.reverse
when :down then range
when :updown then range.reverse + range
when :downup then range + range.reverse
end
samples.map{|i|
i *= increment
[base - scale * i, i]
}
end
# letters are defined as a series of pairs of (spin-time, sleep-time)
# with the time in seconds
THIN_A = gradient(15, :updown, 0.2, 0.2/15)
A = gradient(15, :updown)
I = 2,0
L = 1.5,0, [[0.1,0.2]]*9
M = 2,0, gradient(9, :downup), 2,0
N = 1,0, gradient(9, :down), 2,0
U = 1,0, gradient(9, :downup, 0.1, 0.03, 0.1), 1,0
V = 0.5,0, gradient(12, :downup, 0.25, 0.02), 0.5,0
W = 0.5,0, [gradient(12, :downup, 0.25, 0.02)]*2, 0.5,0
[A,I,L,M,N,U,V,W].map{|i|
# add 2 second pause after each letter
i + [0,2]
}.flatten.each_slice(2){|x,y|
# spin, then sleep
c = Time.now
1 until Time.now-c > x
sleep y
}
可以用已实现的字母写的单词可以找到
grep -E '^[aijlmnuvw]+$' /usr/share/dict/words