Skip to content

Instantly share code, notes, and snippets.

@andresgcarmona
Created October 13, 2022 11:21
Show Gist options
  • Save andresgcarmona/7baba9ac9c02c3fab91376fb12180196 to your computer and use it in GitHub Desktop.
Save andresgcarmona/7baba9ac9c02c3fab91376fb12180196 to your computer and use it in GitHub Desktop.
Mandelbrot coffee
m=(x,y)->
a=x
b=y
z=0
for i in [0..99]
(return if i>60 then '*' else if i>10 then '-' else if i>5 then '.' else ' ') if z>4
l=y*y
z=x*x+l
y=2*x*y+b
x=x*x-l+a
'@'
console.log (m x,y for x in [-1.5..0.5] by 2/79).join '' for y in [-1.3..1.3] by 2.6/40
n='\u001b[0m'
m=(x,y)->
a=x
b=y
z=0
for i in [0..999]
(return if i>100 then '\u001b[33m*'+n else if i>10 then '\u001b[34m-'+n else if i>5 then '\u001b[31m.'+n else ' ') if z>4
l=y*y
z=x*x+l
y=2*x*y+b
x=x*x-l+a
'\u001b[32m@\u001b[0m'
console.log (m x,y for x in [-1.5..0.5] by 2/79).join '' for y in [-1.3..1.3] by 2.6/40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment