Skip to content

Instantly share code, notes, and snippets.

@tompng
Last active February 18, 2023 09:23
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tompng/842616aa61b2b2cb6af52b0389ef3799 to your computer and use it in GitHub Desktop.
Save tompng/842616aa61b2b2cb6af52b0389ef3799 to your computer and use it in GitHub Desktop.
C = File.read(__FILE__).split('__CODE__').last.lines.drop(1).grep(/^[^#]/).join.split
# puts C.join.size+3+11+9+15+13+1
def at_exit;end
def sleep(n=nil);end
def $>.<< s
STDOUT.write s
cc = nil
s.gsub! "\e[1;1H", ''
Object.new.instance_eval s.gsub('C', 'cc')
File.write 'output.rb', s.lines.map(&:rstrip).join("\n") if cc.join =~ /t=96/
if @cc == cc
puts 'all pattern ok'
exit
end
@cc ||= cc
a = cc.join.gsub(/#(t|#).*$/, '').sub(/t=\d+/,'t=0')
b = C.join.gsub('C', 'cc')
unless a == b
puts [a.size, b.size]
puts a
puts b
raise 'error'
end
end
# __CODE__
# C=%w(
t=0;S=->x,y{
(20**(x+y-2)+20**(x-y-2)+2.7**(-x-0.5-1.2*(2.5+(1.2-Math.cos(15*y))**0.25)/
(5+(5*y/3+5*x*y/9)**16)/(1+Math.exp(4*x)))-0.67
)*(((y*y+4e-3)**0.5-0.33)**2+((11*x-1)/12)**2-1/7.0
)*((y.abs-4/13.0)**2+(x-1/8.0)**2-0.11
)*((y.abs-2/7.0)**2+(x-1/6.0)**2-0.03)
};
r=->n{
h=0.1*Math.atan(Math.tan(u=Math::PI/12*t+=1)*(1-Math.sin(u)**8));
q=??.next;
c=([C,?#,C]*'').sub(/=[0-9]+/,"=#{t%768}").chars;
m=(
(1..n).map{|j|
(1..2*n).map{|i|
p=(1.5*(i-n)/n+(1.5*(2*j-n)/n).i)*Math::E**(Math::PI*t/128).i*0.96;
S[p.real*(1.0+h)+0.3,p.imag/(1.0+h)]<0?'!':32.chr
}*''
}*$/
).sub(/.![^!]|!!!/,'%w'+q).
match(/^(.+!.+)!{11}([^!]*)!{9}(.+)!{15}([^!]*)!{13}(.+!.+)!([^!]+)$/m);
m[1..6].zip([
q+'.tap{|c|C=','c};C<<%w'+q,q+';at_exit{eval(',"C*'')};C<<%w"+q,q
]).join.gsub(?!){c.shift}
};
loop{
$> << "#{27.chr}[1;1H"+r[32];
sleep(0.05)
}
# 3
# 11
# 9
# 15
# 13
# 1
# ).join
# eval C
#
#
# %w(
#
# ).tap{|c|C=
# c};C+=%w(
#
# );at_exit{eval(
# C*'')};C+=%w(
#
#
# tt=nil
# (0.9..1.1).bsearch{|t|
# c=render[t].count('#')
# break if c==700&&tt=t
# c<700
# }
%w@t=96;S=->x,y{(20*
*(x+y-2)+20**(x-y-2)+2.7**(-x-0.5-1
.2*(2.5+(1.2-Math.cos(15*y))**0.25)/(5+(5
*y/3+5*x*y/9)**16)/(1+Math.exp(4*x)))-0.67)
*(((y*y+4e-3)**0.5-0.33)**2+((11*x-1)/12)**2
-1/7.0)*((y.abs-4/13.0)**2+(x-1/8.0)**2-0.11
)*((y.abs-2/7.0)**2+(x-1/6. 0)**2-0.0
3)};r=->n{h=0.1*Math.ata n(Math.t an(u=
Math::PI/12*t+=1)*(1-Ma th.s in(u)* *8)
);q=??.next;c=([C,?#,C ]*' ').s ub(/
=[0-9]+/,"=#{t%768}"). ch ars; m=((1
..n).map{|j|(1..2 *n) .map{ |i|p=(1
.5*(i-n)/n+(1. 5*(2*j-n)/n).i)*Math ::E**(Math
::PI*t/128).i *0. 96;S[p.real *(1.0+h)+0.3,
p.imag/(1.0 +h) ]<0? '!':32.chr}*''}*$
/).sub(/.![ ^!]| !!!/ ,'%w'+q).match(/^(.+!.+
)!{11}([^!] *)!{9 }(.+) !{15}([^!]*)!{13}(.+!.
+)!([^!]+)$ /m);m[1..6] .zip([q+'.tap{|c|C
=','c};C<<%w '+q,q+' ;at_exit{eval(',"C*
'')};C<<%w"+q, q]).join.gsub(?!){c.
shift}};loop{$><<"#{27.chr}[1;1H"+r[3
2];sleep (0@.tap{|c|C=c};C<<%w@
.05)}@;at_exit{eval(
C*'')};C<<%w@#t=
0;S=->x,y{
(20**(x
+y-@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment