4 ms·
I once wrote a program in BASIC (on my C64) which would make such a display (it's straightforward). I lost that program, but recreated a lookalike in Python:
by Luyt 13y ago
I once wrote a program in BASIC (on my C64) which would make such a display (it's straightforward). I lost that program, but recreated a lookalike in Python:
-- --
--- ---
------------------ -------------
--------------------------
------------- ------------------ -------------
------- ---- - ------- -
-------- - - -------
----------- - -------- -----
----- - ---------
-------- - - --------
-------- ------- ----------- -------
---------- ------- -----------
--- - -- ------- --------
- -- -- -
- -- - -
---------------- -- - ------------------
--- - -
--------------- - ----------------
- -
----------------- --
-------------------- ------ ------ ------------
------ - -- ------
-------- ----- ---- -----------
------- - -- -------
------ - - - -------
------- -- - -- -----------
-- - -
----------------- -- -------------------
- ----- --
-- -- -- --
----------------------------- -- --------------
----------- - -----------
- -- - ----------
-- --
-- --
--------------------- --------------
heuh... it looks a bit horrible in ASCII art ;-)
import random
import math
canvh = 40
canvw = 60
tracecount = 16
canvas = [[' ' for col in xrange(canvw)] for row in xrange(canvh)]
def randomtrace():
sigma = random.uniform(4, 20)
mu = random.gauss(canvw/2, canvw/20)
k = canvw / (sigma * math.sqrt(2*math.pi))
s = -1.0 / (2 * sigma * sigma)
amp = 2.0
tr = [amp * k * math.exp(s * (x - mu)*(x - mu)) for x in xrange(canvw)]
# TODO: Random permutations, or Perlin noise.
return tr
for t in range(tracecount):
if t == 0 or t == tracecount - 1:
continue
y = t * canvh / tracecount
trace = randomtrace()
for x, t in enumerate(trace):
t = int(t)
top = y - t
if top >= 0:
canvas[top][x] = '-'
for i in range(t):
top += 1
if top >= 0:
canvas[top][x] = ' '
for row in canvas:
line = "".join(row)
print " ", line
- b6 13y agoI made this a while back with https://github.com/aempirei/Chat-Art https://github.com/aempirei/Chat-Art . ⠶⠾⣿⡿⠟⠁⠀⠀⠀⢀⣾⠁⠀⢹⡇⠀⠀⠀⠀⠀⢀⡾⠁⠀⠀⠀⠸⣧⣠⣤⣄⡀⠀⠀⠀⠀⠀⠀⠙⢷⣄⠀⢀⣠⣤⣴⠞⠁⠀⠘⠷⣦⡀⠀⠀⣩⡿⢿⣿⣓⡶⠶⠶⠶⢦⣤ ⣤⡼⠋⠀⠀⠀⠀⠀⢠⣾⡟⠀⠀⠀⢿⡀⠀⠀⢠⡾⠛⠁⣤⣤⣄⡀⠀⠈⢻⣄⠈⠛⢷⣄⣀⢀⣠⡶⠶⢶⡝⠛⠛⠁⠀⠀⠀⠀⠀⣀⣠⣼⠿⣷⣟⠉⠀⠀⠈⢻⣿⠶⣤⡤⠤⣤ ⠟⠀⠀⠀⠀⠀⢀⣴⠏⣿⠁⠀⠀⠀⠘⣷⡶⠶⢿⣄⠀⢸⡇⠀⠈⢻⣄⣀⠀⠙⢷⣄⠀⠙⠻⠛⠉⠀⠀⠀⠻⣾⣟⠛⠛⠛⠛⠛⠛⠉⠉⠀⠀⠀⠉⠛⠛⠳⠶⠶⣭⣿⣦⣤⣤⣄ ⣠⣤⣤⣴⡶⠶⠛⠁⣸⡇⠀⠀⠀⠀⠀⢸⣇⠀⠀⢹⣶⡟⠀⠀⠀⠈⢿⡙⠷⣄⠀⠙⢷⣄⡀⠀⠀⠀⠀⠀⠀⠀⠙⠳⣦⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠷⣬ ⣁⡀⣀⣀⣤⣴⠶⣾⣿⠃⠀⠀⠀⠀⠀⠀⢿⣄⣠⡟⠁⠀⠀⠀⠀⠀⠘⠿⣿⠻⠷⠲⣦⡉⠻⠶⠶⠶⠶⣦⣤⣄⡀⢀⣠⡿⠛⠻⣿⠛⠲⠶⠛⠛⠛⠛⢶⣄⠀⠀⠀⠀⠀⠀⠀⠀ ⠉⠉⠉⠁⠀⠀⣰⢏⣿⠀⠀⠀⠀⠀⠀⠀⠈⣿⡏⠀⢠⡶⣦⡀⠀⠀⠀⠀⠙⢷⣄⣀⣈⣝⣿⣷⣄⣀⣀⣀⡀⠈⢻⡿⠁⠀⠀⠀⠹⢷⡶⠶⠾⠛⢦⣤⣤⣝⣿⣛⠛⠛⠲⠶⠶⠤ ⣛⣻⣿⣯⣽⣿⠋⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠸⣇⠀⣿⠁⠈⢷⡀⠀⠀⠀⠀⠀⠉⠉⠁⠈⠛⠿⣯⣍⡙⠛⢛⣿⠟⠀⠀⠀⠀⠀⠀⠈⢿⡄⠀⠀⠀⠀⠀⠉⠙⠉⠛⠻⢿⣶⡶⠛ ⠉⢀⣀⣤⠟⠁⢸⡏⠀⠀⠀⠀⠀⠀⠀⢠⡶⣦⣻⣼⡏⠀⠀⠘⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠶⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⢶ ⠛⠋⠉⠀⢀⣴⡟⠀⠀⠀⠀⠀⠀⠀⣾⠋⠀⠈⢷⡿⠀⠀⠀⠀⠘⣧⣀⣠⡴⠶⠞⠻⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⡛⠛⠶⠶⠶⣤⣄⠀⠀⠀⠀⠀ ⣤⡴⠖⠛⣫⡟⠀⠀⠀⣀⠀⠀⠀⣸⠇⠀⠀⠀⣼⠇⠀⠀⠀⠀⠀⠘⣿⡋⠀⠀⠀⠀⠈⠻⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⠀⢀⣈⣿⡖⢶⣤⣤⣀⠉⠛⠛⠛⠷⣤ ⣀⣴⠟⢻⡿⠀⠀⠀⣰⠟⢷⣄⡼⠋⠀⠀⣀⣴⠏⠀⠀⠀⠀⠀⠀⠀⠸⣧⠀⠀⠀⠀⠀⠀⠈⠛⢿⣿⡛⠓⠶⠶⢶⣲⡶⠲⠶⠚⠛⠉⣙⡿⠿⠋⠉⠙⠋⠛⢦⣝⢷⣄⣀⣀⡀⠀ ⠉⢀⣴⠟⠀⠀⠀⣼⠃⠀⠀⢻⣇⠀⢠⡾⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⣶⣶⢦⣤⣤⣤⣤⣀⣈⣙⣷⣶⣶⡿⠋⣙⣷⣶⠶⠶⢛⣯⡤⣤⡀⠀⠀⠀⠀⠀⠙⠷⣭⣻⢯⣭⣭ ⡶⠋⠁⠀⠀⢀⣸⠏⠀⠀⠀⠀⢻⣦⡾⠁⠀⠀⠀⠀⠀⠀⢀⣠⣴⡶⠛⠛⠶⠞⠛⠛⢷⣶⠶⠶⠶⠯⣭⣀⡀⢀⣴⠟⠉⠻⢿⣿⡶⠏⠀⠀⠈⢻⣆⠀⠀⠀⠀⠀⠀⠈⠙⠛⠳⢶ ⠀⣀⣀⣴⠞⣿⠏⠀⠀⠀⠀⠀⠀⠉⠻⢦⣤⣤⠶⠖⠲⢾⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠙⣷⣄⣤⣤⣤⣽⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⠛⠷⣿⣟⠛⠛⠛⠳⣦⣄⣀⣀⡀⠀ ⠛⠉⢁⣠⡞⠁⠀⠀⠀⢀⣀⣀⣀⣀⣠⣴⠾⠛⢳⣤⣴⠟⠛⠷⣦⣠⣤⡀⠀⠀⠀⠀⠀⠀⠀⠙⠷⣤⣀⣀⠀⠀⠀⠀⠀⠀⠀⣠⡴⠟⠛⠁⠀⠀⠀⠙⢷⣄⣀⠀⠀⠈⠉⠉⠉⠉ ⠛⠛⣻⠟⠀⣠⣤⣤⠶⠛⠉⠉⠉⠉⠁⠀⠀⣠⡾⠋⠀⠀⠀⠀⣾⠃⠈⠛⢶⣦⠶⢤⣤⣤⣀⠀⠀⠈⠉⠉⠙⠷⠶⠶⠶⠾⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣽⣟⠛⠓⠶⠶⢦ ⢛⣿⢏⣴⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡾⠋⠀⠀⠀⠀⠀⣼⣷⣤⡀⠀⠀⠙⢷⣄⠀⠀⠙⠛⠶⠶⠛⠳⠾⠳⠶⣤⣄⣀⣀⣀⣀⣀⣴⠶⠶⠶⣤⣀⣀⡀⠈⠙⢿⣿⣟⣛⣛⠓ ⣛⣵⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⠟⢁⣤⣤⡀⠀⢀⣤⡾⠋⠀⠈⢿⡄⠀⠀⠀⢻⣶⣤⣤⣤⣄⣀⠀⣀⣠⣤⣄⠀⠈⠉⠉⠉⠉⠉⠀⠀⠀⠀⠀⠉⠉⠙⠳⣦⣤⣄⣀⣉⠉⠛ ⠋⠀⠀⠀⠀⢀⣀⣀⡴⢶⡶⢿⡿⢛⣷⣿⢻⡟⠿⠷⣿⡟⠁⠀⠀⠀⠈⣿⡄⠀⠀⠀⠉⠉⠛⠷⣬⣍⣛⠉⠁⠀⢉⣿⣷⣤⣤⣤⣤⣤⡴⠶⣦⣀⣀⣀⣀⣀⠀⠀⠀⠀⠉⠙⠛⠶ ⣤⣤⣤⣤⣶⠿⢿⣿⡾⠋⠀⠈⠙⠋⣱⡟⠀⢿⡄⢠⡿⠁⠀⠀⠀⠀⠀⠘⢷⣄⠀⠀⠀⠀⠀⠀⠀⠉⠙⠛⠛⠛⠋⠁⠀⠀⠀⠁⢀⣠⣴⠶⠛⠉⠉⠉⠉⠙⢷⣄⣀⣀⡀⠀⢀⠀ ⣤⡴⠞⠋⠁⢠⣿⡴⠞⠶⠶⠶⠞⢻⡟⠀⠀⠈⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⣦⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣴⠶⠾⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣭⣙⡛⠋⢙ ⣀⣠⣤⠴⠶⣻⡟⠀⠀⠀⠀⠀⠀⣾⠃⠀⠀⠀⢹⣧⣤⡀⠀⠀⢀⣤⠴⠶⢦⣄⠙⠷⣍⣉⡛⡛⠛⠛⠻⣿⣿⣿⣛⣋⠁⣀⣀⣠⣤⣤⣴⠶⠿⣶⡶⠶⣤⣤⣤⣄⡀⠀⠈⠉⠛⠿ ⠉⣁⣤⠶⠞⠋⠀⠀⠀⠀⠀⣀⣾⡇⠀⠀⠀⠀⠈⢿⡌⠙⢷⣴⣿⠁⠀⠀⠀⠙⢷⣤⣈⠉⠉⠙⠷⣦⣤⣀⠈⠉⠉⣉⣋⣩⡿⠿⠞⠋⠀⠀⠀⠘⢷⣦⠀⠀⠀⠉⠙⠳⢦⣤⣄⣀ ⠋⠉⠁⠀⠀⠀⠀⢀⣤⠶⣞⣯⣿⠃⠀⠀⠀⠀⠀⢸⣧⠀⠀⠀⠙⢷⣄⠀⢀⣀⣀⡈⠙⠛⠛⠻⠶⣦⣀⡉⢛⣻⣿⠟⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠷⣦⡀⠀⠀⠀⠀⠀⠉⠙ ⠶⠶⠞⢛⣩⣽⠿⠛⣻⣿⣿⢿⡏⠀⠀⠀⠀⠀⠀⠀⢿⡄⠀⠀⠀⠀⠘⠿⣯⡉⠉⠻⢶⣄⠀⠀⠀⠀⠉⠙⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢷⣶⣶⠶⢤⡤⢤ ⠛⠒⠛⠋⠁⣀⣤⣾⣵⡟⢡⡿⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣤⠶⠾⠶⠶⢦⣬⡛⠷⣤⣀⣙⣻⢿⣿⣛⠛⠛⠶⣤⣤⡤⠶⢶⣶⣾⣛⣛⡛⠛⠛⠻⠛⠛⠳⣤⡀⠀⠀⠈⠛⠛⠶⠶ ⠶⠶⣶⣶⠟⠛⠉⣡⡟⠀⣼⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣷⡀⠀⢀⣴⣦⠈⠛⢷⣬⣙⣋⠉⠻⠶⠿⠷⣦⣤⡼⠋⠀⠀⠀⠀⠈⠉⠋⠻⣦⣤⣤⣄⣀⣀⠈⠛⠷⠶⠤⠶⠶⢤⣄ ⠾⠛⠉⠀⣀⣤⢾⡿⠁⣰⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣦⡾⠃⢻⡄⢀⣀⣬⡉⠉⠛⠷⢶⠶⠶⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⣄⡈⠉⠉⠙⠛⠳⠶⢦⣤⣤⣤⣌ ⣤⡴⠶⠞⠋⢡⡞⠁⢠⡟⠀⢀⣴⣦⡴⠶⠶⣦⣀⣀⣀⣀⣤⢶⡟⠀⠀⠘⣿⠋⠉⠈⠛⢷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣈⣛⣿⣛⣶⠶⠦⢤⣤⣤⣤⣀⣈ ⣀⣀⣀⣀⣴⡟⠀⣠⡿⠀⢀⣾⠃⢸⣇⠀⠀⠈⠛⢿⣌⠉⠀⣼⠇⠀⠀⠀⢹⣧⠀⠀⠀⠈⠛⠳⢶⣄⠀⠀⠀⠀⢀⣴⠶⢶⣄⣀⣤⡤⣴⡶⠟⠻⢿⣭⣉⠉⠻⣦⣀⣀⠀⠀⠈⠉
- mkl 13y agoI just spent way too much time making a matplotlib one. Example output: http://imgur.com/PtkkESv http://imgur.com/PtkkESv import pylab import scipy def gaussian(x, centre, xscale, height): return height * scipy.exp(-(2.*xscale*(x-centre))**2) def triangle(x, centre, xscale, height): y = height * (1. - scipy.absolute(xscale*(x-centre))) return (y>0) * y x = scipy.linspace(0., 1., 1501) shape = triangle#gaussian# def generate_noise(x, num_bumps, centre_min, centre_max, xscale_min, xscale_max, height_min, height_max, shape=shape): y = scipy.zeros_like(x) for i in xrange(num_bumps): centre = centre_min + (centre_max-centre_min)*scipy.rand() xscale = xscale_min + (xscale_max-xscale_min)*scipy.rand() height = height_min + (height_max-height_min)*scipy.rand() print centre, xscale, height y += shape(x, centre, xscale, height) return y def generate_line(x): y = scipy.zeros_like(x) y += generate_noise(x, 100, 0., 1., 0., 300., 0., .003) y += generate_noise(x, 10, .25, .75, 20., 30., 0., .03) y += generate_noise(x, 10, .29, .45, 20., 30., 0., .03) return y num_lines = 85 line_gap = .015 for i in xrange(num_lines): base_line = (num_lines-i)*line_gap y = base_line + generate_line(x) poly = pylab.Polygon([(x[0], base_line)]+zip(x, y)+[(x[-1], base_line)], facecolor='k', edgecolor='none', zorder=i) pylab.gca().add_patch(poly) pylab.plot(x, y, 'w', linewidth=2, zorder=i+.5) pylab.gcf().patch.set_facecolor('black') pylab.gca().set_axis_bgcolor('k') pylab.axis('equal') pylab.gcf().set_size_inches(8., 8.) pylab.savefig('pulsar.png', facecolor=pylab.gcf().get_facecolor(), edgecolor='none', dpi=150)