Skip to content

Instantly share code, notes, and snippets.

@tompng
Last active July 27, 2019 13:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tompng/7e15397aba472c136aa8bf7fdcf3f63b to your computer and use it in GitHub Desktop.
Save tompng/7e15397aba472c136aa8bf7fdcf3f63b to your computer and use it in GitHub Desktop.
自己紹介用コード(moved to https://github.com/tompng/tompng)
########################################################################################################################################################################################
########################################################################################################################################################################################
########################################################################################################################################################################################
########### ########################################################################################################################################################################
########### ########################################################################################################################################################################
########### ########################################################################################################################################################################
########### ########################################################################################################################################################################
##### ######### ########## ### ###### ######### ## ########## #### ############## ## #####
##### ####### ######## # ## ####### ######## ## ########## #####
##### ##### ##### ###### ## ### ###### #### ###### ### ####### ##### #####
########### ########## ########## ##### ####### ####### ###### ########## ###### ######## ###### ######### #####
########### ######### ############ ##### ######### ########## ###### ############ ##### ########## ##### ########### #####
########### ######### ############# #### ########## ########## ###### ############## ##### ########### #### ############# #####
########### ######### ############## #### ########## ########## ###### ############## ##### ############ #### ############# #####
########### ######### ############## #### ########## ########## ###### ############## ##### ############ #### ############# #####
########### ######### ############## #### ########## ########## ###### ############## ##### ############ #### ############# #####
########### ######### ############# ##### ########## ########## ###### ############# ##### ############ ##### ############ #####
########### ########## ############ ##### ########## ########## ###### ########### ##### ############ ##### ########## #####
########### ########## ######## ###### ########## ########## ###### ####### ###### ############ ###### #### #####
########### ##### ####### ########## ########## ###### ####### ############ ######## #####
########### ####### ######### ########## ########## ###### # ######### ############ ########## ### #####
############# ########## ############ ########## ########## ###### ##### ############# ############ ####################### ######
################################################################################################# ##################################################################### ######
################################################################################################# ##################################################### ######### #######
################################################################################################# ##################################################### ########
################################################################################################# ####################################################### ##########
################################################################################################# ############################################################ ################
########################################################################################################################################################################################
########################################################################################################################################################################################
require'io/console';cx,w,h,m=cy=0.5;zm=2;R=->{l='';h,w=IO.console&.winsize||[48]*2;h*=2;m=1.0*[w,h].min;m*zm<=w&&cx=0.5;m*zm<=h&&cy=0.5;g=(0...h).map{[0]*w};[[524,489,%(H9zR0b8H/R4EJlT
y5fyPUDVdSVeyIiuzaChOoHiIwhiK9wfZpEuoHKGEBkHQcBv9EWmH28FWXMf0kHDYhi0R3AYdgxEYgYNDGZiGKZ3zOTeC52RWRdv5Zr414suo7ujuEpZHeZyNUsMMEE5a0e41OvXu5/b3wvf/z299+f/lX6H4wQY)],[509,22,%(FVAgpVA59Dv
dSraTKmVyJoeGk6FkaGhSNB1JDwE0SZK1gWKgHNjP98f1x9a2uGluWnANC7Igx8wwS1+Tv+Qv/EiKpBD6iiAGPoFiME5G04EkHxpGEyxBOYmQiI2wMA1HEjEYg8Pq0Ua0jt8ggYR3yGADHbfcjOnkTc4M4RmZFpFWop6oD/wT+h/6D76Doi+pv67
velZAD31yUD ATzJBJ4WGhoZERsVwsmx8ZtCGHv7iCL3b/9H73/rR/1n82fn170yv3y7Tbr/cb9Xq5Wqo9rxQrxXL7T7PZbPQ6DVHvV0wZBA)],[628,111,%(APz70G6321JUVFU/w/+DhWA13My2cnqsHmvGssVuuBthciZt0/0oiMF4cD
CDDMT+E4GFN qRP+0N/R0VURHQIhkEqDgAArBnqBDvj3/MO7wJBNDHEU8tsBFBJBfmvOqpT7tV1Xf/0Xdqh3QgMgdDIJGSQaWawRlIppHE/4ailkFpooe5rYIAhhhrqsxop3LdaaeUbsA7r9HuoEqpEa8lmspVr5EzODOPpYCo4aDgAAQ)],
[639,115,%( EMzODowPTIweFIlH4zSNKGKYeOihMsoo06y3ZUfUZNu3XZF74AEEHnjQLOqe7jth+65vasBDDwD0AQ)],[417,358,%(DndGi+FieHu5nqQmu6lwOBxOJ2KCCULYYUc/4P/4H/pACrjA/pI+6TOBIQImCcIwApMkQsIszhGH
UUn7tK++gC7 seoc7uJv/Bhqw0a44bbX10EGXYTEQhymYU1k5/Veyl+xREVERFZEhGIbhMCUUA0oQhiGNIIIeAwyIjeEgDobCjDLGHeWUw6kYIEAkklCaouu6nukBAzQyCCCQHhnKh3LB0cHBwcHB4eFMOJMbAgAA1U+yLuq9/0ADDSwCCGS
HAgCA /NAviGLje 6fUKdWLqqM 6so 088rFI MBgMZoYhD 4H umb7pV78YY QSQ1 jtngUUG9kOWOgo pp JBy5q
mnimu kUccbbX WoZvu2L3 t 9I 0wLtmmb VjPNcCPc Cj bCzXA9Wg/W g6VgG
7VRxw sjjOl qq50B BhjomA EG iJ4 DFgBoc Q)], [733,+ 435 ,%(HkcZ pJAoC imgLE
QghtRhi60X2 CATdMggA6S z1gpvoYWAW mhBp2 +AARYDF A)],[33 +400,+ 624,%(AITH hrKhTH ZSiIUYBS Ef8sl+ UAd1SALnn fUGGN
iJCtRHfdzTX V0rdmudWu 0NAAE)],[673 ,622, %(AOTaMRW XQzvcBm0QA A+cshp o0GA90iVd2ud 93kgB EA)],[513, +803, %(APzLi3g/r lImZZ
JmIIyjOMtgj DEE1BOfas RBHIwZzBBDEBG HHfl CO6zDu9RQz RDWyNi2FU5 4KYUSb dEUrf67MgAB)], [689, 683,%(7Wh9O QiBI KIEURSRHHLIWJ AFaTQ
RJBxTxC03kT 9cBRVzHHA fYdQTgD1yyAHlt TfeS inFhVs1W7V 90okG)],[8 *60-1, 766,%(DoORMARD hALqq WUAAJBAERAGO Rd2Y R+zAACgpdVOmb bt275
qeesN9M4716 J92Ac1a6E BHngc)],[659,+ 765, %(ANAulVTF ekxyiRTXTA dVCIVg OBvmERbDYRzBWQ wAAEZ ZbXSv2ev2u/W mErJ vrBVO4LrXTnur nfbFU
Ae3cY1opJAD DjnsMCCQB BnmhJMY4JB74rh lvZA LuiCLQwoYY AAE)],[600 ,72,%( ANTKbdmSdVUGZf AxVIl UI+1UP96P27B N2RQ Z6AeCvJqJEEZI UkB8l
FFMMWYEEgAt c8xN6BBPH PIAQvA9I7jkDu ugCvY yhltmqccee QwhBLF2UIV UTIdNW HMYkVE5pBRpRV qgHu6 Gu3nJFVfUQgm lbIh+ X1Rk27VcDfVx n0jus
CMQIYLp0CTE kBjkkEPWW2 yxjymmWItJJJ G0Ghn kmSGGyLCEE vW9VkrZIqy havw7b /Em0cFOsB0p xPrRX tzFXcJmQBwn8 KA4AA E)],[16*31 ,205,
%(FkpmiSWGQ QgR99hjRxy y2BLlHXD GWRA)] ,[375,5*68 ,%(DqiYCZt IbyCIw mg4hSGG 0GGLbe Qn6ZIubgAAQC dtnPX4 j7fe eOtB)
],[645,130, %(AJA 8D/NwPB jncT4IxVmc JYKMMEIZ8B C0S33R 77dkx3R 0FWmrjVXQQZu j0AJb6HR 0V5c1
AAE)],[433, 379,%(D lrosMMo7a IuIqM6oZO9 jB6kB5lZIO mTIIkh g thigzQqox ZsggpuozZpY4 klNVAj7QS0 0AI LPQQE
QgyRZT7ouU2iC IzQFCGEEkQ 89ayLFZFIAgm lllBAEWwTQ SR1uI/65oe RRkprv fUOeO QgCjvkkAXWWSe KzjnngQMB)], [843,387,%(ANR+9tv9Vqvk nPXeO+
ghisAQCsIwi7PEyHkIYwIRAtBD5a231jvjtO2avul3/gMAwMAhGGGEEPQB)]].map{|x,y,c|n=[];c=c.unpack('m')[0]. unpack('b*')[0].chars;[]while'1'!=c.pop;n<<(c.shift==?0?(v=c.shift(4) .join.
to_i(2))>7?v-=16:v:(v=(c.shift(5+2*a=c.shift.to_i)*l).to_i(2))>15+a*48?v-40-a*112:v+7+a*15)while( c[0]);c=[];n.each_slice(6){|q,r,s,t,u,v,p=(zm*m/1024) |u+=s+=q; v+=t+=r
;(0...n=1+(u.abs+v.abs)*p).map{|i|a=3*(1-z=i/n)**2*z;c<<[(x+a*q+z**3*u+s*b=3*z*z*(1-z))*p+(w-m*zm )*cx,(y+a*r+z**3*v+t*b)*p+(h-m*zm)*cy]};x+=u;y+=v};c} .zip([1,
2,*([3]*8),4,4,*([5]*6)]){|c,a|s={};c.size.times{|i|u,v=c[i-2];x,y=c[i-1];p,q=[u,x].sort;([p.ceil ,0].max..[q.floor,w-1].min).each{|j|j!=u&&(j!=x||(x-u)* (-c[i][0]+
x)<0)&&(s[j]||=[])<<v+(y-v)*(j-u)/(x-u)}};s.map{|i,t|t.sort.each_slice(2){|u,v|([u.ceil,0].max... [v,h].min).map{|j|g[j][i]=a}}}};$><<("\e[1;1H\e[J");$>.write g.each_slice(2).
map{|a,b|(a.zip(b).map{|i,j|%(\x20`''"^.:]TYY,;IEPPcjL8RRxLJ&WWxLJ&##)[i+6*j]}*l)}*"\r\n"};R[];trap(:WINCH){R[]};STDIN.raw{loop{s=$<.getc;s.ord==3&&exit;s=="\e"&&s<<$<.gets(2);zm=[2**(
('-m+p'.index(s)||1.0)/2*2-1)*zm,16,1].sort[1];cx=[0,cx+(s=~/[ahD]/?1:s=~/[dlC]/?-1:0)*w/(w-m*zm+1)/2,1].sort[1];cy=[0,cy+(s=~/[wkA]/?1:s=~/[sjB]/?-1:0)*h/(h-m*zm+1)/2,1].sort[1];R[]}}
Display the source blob
Display the rendered blob
Raw
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect fill="#ABBAFF" x="0" y="0" width="1024" height="1024"/>
<path fill="#7F82FF" d="M524 489 c-40 -2 -123 31 -152 55,-29 24 -29 62 -49 84,-21 22 -53 31 -72 49,-20 18 -40 38 -48 58,-7 20 -5 47 -2 62,2 14 11 19 12 32,2 14 -7 38 -10 54,-2 15 -8 36 -4 41,4 5 12 5 20 1,7 -3 19 -35 30 -48,10 -13 18 -27 32 -32,13 -5 39 5 49 2,10 -3 14 -11 21 -14,8 -2 14 -1 25 0,11 1 36 10 55 11,18 1 35 -4 56 -5,21 -2 51 5 72 -2,20 -6 32 -19 54 -34,22 -14 52 -50 84 -61,33 -11 91 -5 113 -3,22 3 42 15 47 11,6 -4 6 -12 4 -19,-3 -8 -16 -18 -32 -30,-17 -11 -54 -24 -87 -48,-33 -25 -82 -87 -118 -112,-36 -26 -60 -49 -100 -52"/>
<path fill="#5754DF" d="M509 22 c-20 0 -44 4 -66 13,-21 9 -50 27 -64 43,-13 16 -19 33 -23 54,-4 21 -2 50 2 77,4 27 13 67 25 85,11 18 37 18 42 34,4 16 -14 39 -22 62,-7 23 -16 45 -25 81,-9 35 -27 109 -29 153,-2 44 6 110 12 118,6 8 13 11 19 7,6 -3 11 -48 15 -75,4 -27 5 -66 9 -89,4 -24 13 -59 15 -58,3 0 2 15 4 28,1 14 5 47 10 70,4 22 13 50 18 65,6 15 11 22 15 33,4 11 1 22 7 32,5 10 16 25 29 26,13 1 41 -16 53 -32,12 -17 15 -61 17 -69,2 -8 1 -10 3 -14,3 -4 4 -6 11 -9,7 -4 41 -16 63 -20,21 -4 47 3 66 -4,18 -8 29 -22 44 -39,15 -17 38 -45 47 -70,9 -25 9 -58 9 -81,-1 -22 -7 -49 -9 -58,-2 -10 -5 -18 -4 -19,1 -1 17 23 25 42,8 19 12 59 22 87,9 27 20 57 33 78,13 20 35 51 43 48,9 -2 12 -38 10 -62,-1 -23 -12 -51 -22 -80,-10 -28 -23 -59 -40 -90,-16 -30 -50 -74 -60 -95,-9 -21 -4 -32 -13 -49,-9 -16 -26 -33 -47 -52,-22 -18 -71 -38 -94 -58,-23 -21 -36 -49 -51 -64,-15 -16 -25 -28 -41 -36,-17 -9 -37 -13 -58 -13"/>
<path fill="#3D399D" d="M628 111 c0 0 -26 -40 -39 -53,-13 -13 -20 -21 -40 -27,-19 -5 -69 -2 -94 6,-24 8 -43 18 -58 38,-14 21 -19 56 -24 91,-4 35 2 92 0 121,-2 30 -6 51 -10 69,-3 18 -12 30 -12 43,1 14 9 39 15 40,6 0 19 -25 23 -33,3 -8 -2 -12 2 -21,5 -9 32 -38 44 -46,12 -8 23 -13 32 -12,10 0 27 14 27 14,0 0 6 -15 15 -27,8 -12 45 -53 52 -65,7 -11 7 -19 11 -24,4 -4 8 -5 13 -8,6 -3 17 -3 22 -10,5 -8 9 -33 3 -45,-6 -12 -27 -22 -44 -27,-17 -5 -48 -6 -59 -1,-12 5 -23 16 -22 25,0 9 31 25 32 31,1 6 -4 12 -8 15,-5 2 -12 -4 -18 -2,-5 3 -14 18 -16 23,-3 5 -2 10 -5 11,-3 1 -8 -8 -13 -8,-4 0 -8 4 -12 9,-4 5 -5 25 -10 27,-6 3 -15 0 -20 -6,-5 -6 -6 -22 -5 -39,1 -17 6 -50 15 -70,9 -20 21 -38 37 -53,16 -14 37 -30 58 -34,21 -4 49 3 67 11,17 8 41 37 41 37"/>
<path fill="#3D399D" d="M639 115 c1 0 50 20 73 34,23 15 56 39 67 53,12 14 17 32 19 37,2 6 5 10 4 11,-1 1 -7 -3 -13 -7,-6 -4 -21 -21 -34 -28,-12 -8 -30 -15 -43 -16,-13 -2 -36 5 -37 5,-1 0 0 0 -1 0,-1 0 -16 -23 -21 -33,-5 -9 -7 -17 -10 -26,-2 -9 -6 -27 -6 -28,1 -1 1 -1 2 -2"/>
<path fill="#3D399D" d="M417 358 c-2 3 -14 36 -22 65,-8 29 -21 90 -26 130,-6 41 -8 84 -7 113,1 29 6 68 9 72,3 4 5 6 8 4,3 -2 8 -42 11 -67,3 -26 5 -66 9 -90,3 -24 9 -51 13 -60,4 -9 10 -17 13 -16,2 0 -2 16 -2 26,1 11 2 27 6 38,4 10 10 24 17 26,7 1 19 -6 24 -15,5 -9 -1 -45 -1 -56,1 -11 0 -13 3 -25,3 -11 25 -45 25 -61,1 -16 -12 -36 -14 -41,-3 -5 -6 -6 -5 -8,1 -2 20 4 33 4,14 1 31 2 52 -4,20 -7 65 -37 81 -47,16 -10 21 -18 32 -24,11 -6 22 -13 31 -12,10 1 20 11 25 15,5 3 5 8 9 10,3 1 12 -4 14 -3,2 1 1 4 1 7,0 4 -3 17 0 25,3 8 12 18 18 23,6 6 13 4 18 11,5 7 6 50 9 50,2 0 6 -7 8 -14,1 -7 -3 -30 -5 -41,-2 -10 -6 -20 -6 -24,0 -5 2 -9 4 -9,2 0 20 31 29 53,9 21 17 54 25 79,8 25 16 54 26 73,10 19 31 45 31 45,0 0 -19 -38 -26 -55,-8 -17 -18 -42 -18 -47,0 -5 0 -8 2 -8,2 0 22 27 22 27,0 0 -7 -40 -16 -64,-8 -23 -24 -56 -36 -78,-12 -22 -29 -45 -35 -57,-6 -12 -13 -25 -11 -26,2 -1 15 10 23 18,8 8 27 36 29 35,1 0 -4 -10 -8 -19,-4 -9 -23 -45 -27 -53,-4 -8 -4 -15 -7 -16,-2 -2 -5 -2 -8 0,-4 1 -13 10 -16 15,-2 5 -1 10 0 15,1 5 8 11 7 16,-1 5 -7 12 -12 14,-5 2 -17 1 -21 -4,-3 -5 6 -23 3 -32,-3 -9 -10 -19 -19 -23,-8 -4 -22 -3 -35 2,-13 5 -32 24 -47 34,-16 10 -30 18 -46 28,-15 10 -32 22 -49 30,-17 8 -39 16 -52 18,-13 2 -25 1 -33 -3,-8 -4 -12 -15 -17 -18,-5 -2 -9 -2 -13 -2,-4 1 -6 7 -10 7,-4 0 -12 -10 -14 -10,-3 0 -3 1 -6 4"/>
<path fill="#3D399D" d="M733 435 c-1 3 11 9 12 14,1 4 -5 9 -4 14,0 5 6 14 10 15,3 1 8 -1 11 -4,3 -3 2 -11 5 -15,2 -4 10 -6 12 -10,2 -4 2 -11 0 -14,-3 -3 -11 -4 -14 -3,-3 1 -3 6 -6 7,-3 0 -15 -9 -19 -9,-4 0 -7 3 -7 5"/>
<path fill="#3D399D" d="M433 624 c0 0 10 35 19 55,9 19 29 59 38 65,9 6 14 6 23 5,9 -1 25 -10 33 -15,8 -5 17 -12 17 -14,-1 -2 -4 -3 -8 -3,-4 1 -16 13 -24 15,-9 2 -18 5 -28 0,-11 -5 -29 -28 -40 -46,-12 -18 -30 -62 -30 -62"/>
<path fill="#3D399D" d="M673 622 c0 0 21 -13 34 -19,14 -7 41 -19 48 -22,8 -3 16 -3 16 -4,0 -2 -6 -5 -11 -5,-5 0 -21 6 -31 10,-11 4 -22 9 -31 16,-9 7 -25 24 -25 24"/>
<path fill="#3D399D" d="M513 803 c0 0 -26 22 -34 36,-9 14 -15 31 -19 48,-4 16 -8 39 -7 53,2 14 8 33 11 36,3 3 4 3 9 2,4 -1 21 -17 35 -17,14 0 48 25 54 27,6 2 7 4 11 2,3 -2 7 -38 12 -50,6 -12 13 -23 18 -27,5 -5 11 -3 14 -8,2 -4 -1 -17 -4 -25,-2 -8 -3 -15 -10 -23,-6 -8 -19 -16 -34 -24,-14 -9 -56 -30 -56 -30"/>
<path fill="#3D399D" d="M689 683 c-13 12 -30 73 -30 82,0 8 2 13 6 15,5 2 16 -5 23 -4,7 1 13 7 21 13,8 5 20 20 28 24,7 3 12 5 19 2,7 -4 18 -32 25 -38,8 -6 14 -8 21 -8,7 -1 18 5 23 4,4 0 7 -1 9 -3,2 -2 2 -8 1 -13,-1 -4 -2 -7 -9 -14,-7 -8 -79 -70 -97 -73,-19 -3 -28 1 -40 13"/>
<path fill="#353089" d="M479 766 c-2 3 -2 34 -1 43,1 9 5 14 5 19,-1 5 -4 11 -4 11,0 0 15 2 26 2,10 0 31 -2 41 -4,10 -1 23 -4 23 -4,0 0 -5 -7 -8 -12,-2 -6 -6 -19 -9 -28,-3 -9 -9 -23 -10 -26,-1 -4 0 -5 -2 -6,-2 -2 -16 3 -25 4,-9 0 -27 -3 -30 -2,-4 0 -5 0 -6 3"/>
<path fill="#353089" d="M659 765 c0 0 5 -11 10 -18,5 -6 18 -16 24 -23,7 -7 9 -13 16 -18,6 -5 14 -11 23 -9,9 1 19 21 29 28,11 6 24 9 34 12,11 3 31 6 31 6,0 0 -4 -6 -7 -11,-4 -5 -14 -20 -24 -31,-9 -11 -26 -26 -32 -34,-7 -9 -11 -12 -14 -20,-2 -8 1 -25 0 -30,-2 -5 -3 -8 -8 -10,-5 -1 -28 8 -40 11,-13 3 -31 7 -36 9,-6 2 -8 2 -10 4,-2 3 -4 6 -4 10,1 4 9 10 12 17,4 7 8 20 8 27,1 7 0 11 -2 18,-3 6 -13 15 -15 23,-2 8 4 22 5 27,0 6 0 12 0 12"/>
<path fill="#282269" d="M600 72 c0 0 -18 -21 -31 -28,-14 -7 -31 -13 -52 -13,-21 0 -60 9 -80 20,-19 11 -32 28 -41 42,-9 14 -12 24 -15 41,-3 17 1 40 0 63,0 22 -6 69 -4 71,3 2 5 -5 10 -5,4 -1 16 5 21 8,5 3 8 9 12 10,4 0 5 -3 11 -5,6 -2 44 -14 48 -15,4 -2 6 -3 6 -2,1 0 -32 19 -40 26,-7 7 -9 10 -14 18,-6 8 -16 27 -20 34,-3 6 -6 11 -7 14,-1 2 -2 5 -1 6,1 0 14 -13 22 -19,9 -6 22 -11 32 -15,10 -5 17 -4 28 -11,12 -7 38 -29 49 -43,11 -14 11 -31 21 -42,10 -11 32 -18 39 -24,7 -6 12 -9 13 -16,1 -7 -6 -23 -14 -32,-9 -8 -29 -15 -42 -17,-14 -2 -32 0 -41 3,-9 4 -16 11 -18 14,-2 4 -1 6 1 10,3 5 30 21 31 24,1 4 -3 6 -5 8,-2 2 -5 1 -8 4,-3 3 -4 16 -10 22,-6 6 -20 12 -27 14,-7 2 -14 -1 -19 1,-4 2 -5 8 -9 12,-4 4 -11 14 -18 15,-7 2 -16 1 -21 -5,-6 -6 -9 -29 -8 -47,2 -19 16 -52 23 -66,7 -15 11 -20 19 -32,8 -13 19 -37 32 -46,12 -10 26 -12 40 -14,15 -3 34 -3 48 0,15 3 39 17 39 17"/>
<path fill="#282269" d="M496 205 c-3 1 -10 7 -13 11,-3 4 -7 10 -6 11,1 2 8 1 11 0,3 -2 7 -4 9 -7,3 -3 7 -9 6 -11,0 -2 -4 -4 -7 -4"/>
<path fill="#282269" d="M375 340 c-2 0 -8 13 -12 23,-4 11 -14 34 -14 46,1 12 11 29 14 30,3 1 4 -1 7 -4,3 -3 14 -34 18 -45,4 -11 7 -27 7 -27,0 0 -12 18 -16 16,-3 -1 0 -29 -1 -32,-1 -4 -2 -7 -3 -7"/>
<path fill="#282269" d="M645 130 c0 0 4 22 11 32,7 10 21 18 35 25,14 7 38 9 52 15,14 6 29 14 35 18,6 4 11 10 11 9,1 0 -12 -22 -21 -30,-9 -9 -23 -16 -35 -20,-12 -5 -31 -3 -36 -6,-5 -4 -8 -10 -7 -12,1 -3 22 2 23 -1,0 -3 -24 -15 -36 -20,-11 -5 -32 -10 -32 -10"/>
<path fill="#282269" d="M433 379 c-2 1 -5 2 -7 5,-2 3 0 21 -2 33,-2 11 -9 23 -14 38,-5 16 -15 35 -20 59,-5 24 -9 72 -9 88,-1 16 -1 32 2 33,2 1 5 -2 8 -6,2 -5 4 -26 6 -40,1 -15 1 -35 4 -48,2 -13 6 -26 9 -33,3 -7 8 -11 9 -16,2 -5 0 -13 1 -16,1 -3 1 -6 2 -7,1 0 5 1 6 4,1 2 -2 8 -3 16,-1 7 -4 23 -2 34,1 11 6 28 10 32,4 5 8 7 12 6,5 -1 11 -12 14 -18,4 -7 6 -14 6 -21,1 -7 -4 -14 -3 -22,1 -8 9 -21 13 -29,4 -7 9 -9 12 -18,2 -9 -2 -41 -6 -48,-4 -7 -11 -10 -14 -11,-3 -1 -5 -1 -6 1,-2 1 0 11 -2 13,-2 2 -5 2 -8 0,-3 -2 -11 -25 -13 -27,-2 -2 -3 -2 -5 -2"/>
<path fill="#282269" d="M843 387 c0 0 -18 -31 -27 -44,-9 -14 -23 -36 -25 -38,-3 -1 -4 -2 -6 -1,-1 1 1 12 2 21,2 8 3 18 9 32,6 15 37 67 39 70,3 4 4 6 6 6,1 -1 2 -7 1 -10,-1 -3 -4 -4 -6 -8,-2 -5 -5 -16 -9 -25,-4 -9 -16 -34 -16 -34,0 0 23 26 26 28,3 2 5 4 6 3"/>
</svg>
data = File.read 'tompng.svg'
colors = data.scan(/<path fill="#(.{6})"/).map do |(color)|
rgb = color.scan(/../).map { |c| c.to_i(16) }
1 - rgb.sum.fdiv(0xff*3)
end
colors = colors.map { |c| (c - colors.min) / (colors.max - colors.min) * 0.9 + 0.1 }
starts = []
curves_base = data.scan(/d="[^"]+"/).map do |s|
x, y, *other = s.scan(/-?\d+/).map(&:to_i)
starts.push [x, y]
other.each_slice(6).map { |a,b,c,d,e,f| [a, b, c - a, d - b, e - c, f - d] }.flatten
end
packed = curves_base.zip(starts).map do |numbers,(sx,sy)|
bits = numbers.map do |v|
next [0, 4.times.map{|i|(v>>i)&1}.reverse] if -8 <= v && v < 8
v -= v > 0 ? 8-1 : -8
next [1, 0, 5.times.map{|i|(v>>i)&1}.reverse] if -16 <= v && v < 16
v -= v > 0 ? 16-1 : -16
next [1, 1, 7.times.map{|i|(v>>i)&1}.reverse]
end
[sx,sy,[[bits.join+'1'].pack('b*')].pack('m').delete("\n=")]
end
code = File.read(__FILE__).split(/\nexit\n/).last
packed_rb = '[' + packed.map { |x,y,s| "[#{x},#{y},%(#{s})]" }.join(",\n") + ']'
code = code.gsub('packed', packed_rb)
File.write('tmp.rb', code) unless File.exist? 'tmp.rb'
tmp = File.read('tmp.rb').delete "\n "
unless File.exist? 'template.txt'
require 'chunky_png'
png = ChunkyPNG::Image.from_file 'template.png'
ratio = (png.width*png.height).times.count{|xy|(png[xy%png.width,xy/png.width]&0xff00)<0xff00/2}.fdiv(png.width*png.height)
w = 184
h = (tmp.size / (1-ratio) / w).round
p tmp.size, w, h
shape = h.times.map{|y|
w.times.map{|x|
(png[x*png.width/w,y*png.height/h]&0xff00)<0xff00/2 ? ' ' : '#'
}.join
}.join("\n")
File.write 'template.txt', shape
end
shape = File.read 'template.txt'
idx=0
out=''
shape.chars.map{|c|
if c=='#'
out << (tmp[idx] || ';')
idx+=1
else
out << c
end
}
out << (tmp[idx..-1]||';')
File.write('out.rb', out)
code.delete!("\n ")
eval code
exit
require'io/console';
cx,w,h,m=cy=0.5;
zm=2;
R=->{
l='';
h,w=IO.console&.winsize||[48]*2;
h*=2;m=1.0*[w,h].min;
m*zm<=w&&cx=0.5;
m*zm<=h&&cy=0.5;
g=(0...h).map{[0]*w};
packed.map{|x,y,c|
c=c.unpack(?m)[0].unpack('b*')[0].chars;
[]while'1'!=c.pop;
n=[];
n<<(
c.shift==?0 ?
(v=(c.shift(4)*l).to_i(2))>7?v-=16:v :
(v=(c.shift(5+2*a=c.shift.to_i)*l).to_i(2))>15+a*48?v-40-a*112:v+7+a*15
)while(c[0]);
c=[];
n.each_slice(6){|q,r,s,t,u,v,p=(m*zm/1024.0)|
u+=s+=q;
v+=t+=r;
(0...n=1+(u.abs+v.abs)*p).each{|i|
a=3*(1-z=i/n)**2*z;
c<<[
(x+a*q+z**3*u+s*b=3*z*z*(1-z))*p+(w-m*zm)*cx,
(y+a*r+z**3*v+t*b)*p+(h-m*zm)*cy
]
};
x+=u;
y+=v
};
c
}.zip([1,2,*([3]*8),4,4,*([5]*6)]){|c,a|
s={};
c.size.times{|i|
u,v=c[i-2];
x,y=c[i-1];
p,q=[u,x].sort;
([p.ceil,0].max..[q.floor,w-1].min).each{|j|
j!=u&&(j!=x||(u-x)*(c[i][0]-x)<0)&&(s[j]||=[])<<v+(y-v)*(j-u)/(x-u)
}
};
s.map{|i,t|
t.sort.each_slice(2){|u,v|
([u.ceil,0].max...[v,h].min).map{|j|g[j][i]=a}
}
}
};
$> << "\e[1;1H\e[J"+g.each_slice(2).map{|a,b|(a.zip(b).map{|i,j|%(\x20`''"^.:]TYY,;IEPPcjL8RRxLJ&WWxLJ&##)[i+6*j]}*l)}*"\r\n"
};
R[];
trap(:WINCH){R[]};
STDIN.raw{
loop{
s=$<.getc;
s.ord==3&&exit;
s=="\e"&&s<<$<.gets(2);
zm=[1,16,zm*2**(('-m+p'.index(s)||1.0)/2*2-1)].sort[1];
cx=[0,cx+(s=~/[ahD]/?1:s=~/[dlC]/?-1:0)*w/(w-m*zm+1)/2,1].sort[1];
cy=[0,cy+(s=~/[wkA]/?1:s=~/[sjB]/?-1:0)*h/(h-m*zm+1)/2,1].sort[1];
R[]
}
}
require 'chunky_png'
def load_shape(name, w)
img = ChunkyPNG::Image.from_file "#{name}.png"
h = (w * img.height / img.width).round
lines = h.times.map do |y|
chars = w.times.map do |x|
color = img[img.width * x / w, img.height * y / h]
color & 0xff00 < 0xff00 / 2 ? '#' : ' '
end
chars.join
end
a=lines.map{|a|a.scan(/^ */).first.size}.min
b=lines.map{|a|a.scan(/ *$/).first.size}.min
p [a, b]
lines.map!{|l|l[a...-b]}
lines.shift while lines.first.count('#')==0
lines.pop while lines.last.count('#')==0
lines=lines.each_slice(2).map(&:first)+lines.each_slice(2).map(&:last)
[lines[0].size,lines.size, lines.join("\n")]
end
# w,h,shape = load_shape('template2', 40)
w, h = [34, 56]
shape = %(
| ##### |
| ############ |
| ############### |
|################### |
|####################### |
|######################### |
| ######################### |
| ########################## |
| ########################### |
| ############################ |
|### ########################## |
|## ######################## ### |
| ######################### #### |
| ######################### #### |
| ########################## ####|
| ######################### ####|
|### ##################### ###|
|### ################## #|
|### ########## ##### |
|### ####### ###### |
|## ###### ######### |
| ##### ########## |
| ##### #### |
| #### |
| ######## |
| ########## |
| ######## |
| ######## |
| ########## |
| ############## |
| ################ |
|##################### |
|######################## |
| ######################### |
| ########################## |
| ########################## |
| ########################### |
| ############################ |
|## ############################ |
|########################### #### |
| ######################### #### |
| ########################## #### |
| ########################## ####|
|### ###################### ###|
|### ################### ##|
|### ################## |
|### ######## ##### |
|## ####### ####### |
|## ##### ########## |
| #### ######## # |
| ##### ## |
| ###### |
| ######## |
| ########## |
| ######## |
| ## |
).lines.map{|l|l.split('|')[1]}.compact.join("\n")
segments = shape.delete("\n").scan(/( +)(#+)/).flatten.map(&:size)
s=segments.map{|a|(a+32).chr}.join
s+='@tompng'.reverse
quote = '%q~'+s.gsub('\\','\\\\\\')+'~'
code, template = DATA.read.split(/\n{2,}/)
chars = code.delete(" \n").gsub('QUOTE', quote).chars
eval chars.join
formatted = template.lines.map{|l|
chars.shift if chars.first==';'
l.gsub('#') { chars.shift }
}.join
File.write 'tompng_simple.rb', formatted
puts formatted
__END__
i=0;s=%w`a=(q=QUOTE).chars.map{|c|[i=1-i]*(c.ord-32)}*'';952.times{|i|
$><<(q[1127-i]||('#".%c'%32)[(a[i]+a[i+952]).to_i(2)])<<$/[~i%34]
}`*'';eval(s)
###
######### ######## ######## ###### ######### ### ##### #########
######### ########## ################ ########### ########## ###########
### ### ### ### #### ### ### ### #### ### #### ####
### ### ### ### #### ### ### ### ### ### #### ####
###### ########## ### #### ### ########### ### ### ##########
###### ######## ### #### ### ######### ### ### ########
### ### ####
### ##########
,cxJJJJJxc
,cJ&###RRRPPPRRJ
,I8####REEIIIIIIIIE,
IL####PIIIIIIIIIIIIII,
II####EIIIILJJJJJLIIIIE&&xc
II###EIIIII########8IIIR###R8c
II##8IIIIIIIP#######IIII8RRR##&xc
'I##8IIIIIJ8#####RPEIIIIIIIIIIEPR&
I##8IILJ&&####R8IIIIIIIIIIIIIIIIE8
'RR&JJ#R#####REIIIIIIIIIIIILLIIIII,
88888&####REIIIIIIIIIIIL88888LIL88
c888&###RR8EIIIIIIIIIL888EEE88EII&E8
&88&REIIIEIIIIIIIIL888EIIIIIIEE88##IE,
#88'8L8LIIIIIILL888EIIIIIIIIIII888#RJI,
### 88#8&8EE888EEEIIIIIIIIIIIIIIIE8,#8LI,
##'L88####8IIIIIIIIIIIIIIIIIIIIIIII8 P8LII
88######IIIIIIIIIIIIIIIIIIIE8L8IE 88LI,
L8#R####EIIIIIIIIIIIIIIIIIIIIE8III I88II,
,8&#8###EIIIIIIIIIIIIIIIIIIIIIIIIII E88II
I8#8I###IIIIIIIIIIIIIIIIIIIIIIIIII' 'LEIII
88#I]##RIIIIIIIIIIIIIIIIIIIIIIIII' ILIII
I8##::888IIIIIIIIIIIIIIIIIIIIIILL' 'LIII
:I8#P::IEEIIIIIIIIIIIIIIIIIILEEI' 'LI'
::I8#I::IIIIIIIIIIIIIIIIIIJJJJWWW '
..:::I88I:::IIIIIIIIIIII]]]:YWWWWWWW
.:::::::I88::::EIIIIIIIII::::::::WWWWWWWx.
.:::::::::I88:::::ELIIIIIII::::::::WWWRRWWWWL:..
:::::::::::I8E::::::ELIIILL]:::::::WWR8888RRWWW:::.
:::::::::::::]:::::::IIEEEI]::::::::R888888888888j``
::::::::::::::::::::::WWWWW::::::::`'''888888'''''
::::::::::::::::::::::WWWWWW::::` '888'
:::::::::::`:::::::::WWWWWWL``
::::`` ``` c888888888c
.::: 88888888888
::` 888888888888'
`` 8888888888'
8888888888
' ''8'
i=0
s=%w`a=(q =%q~'%9, 4/23/7+9 *9):(; '<%#!:$"! 8!# %9!$$ 9"$":#$!9
$'!5&&"2* $"*#%+##'& &)"%&%).%&*-%)$1 $=(9*8(:(8* 6.3015-8+9 ):(:(;'<%"!
<#; !$$ 9"$ ":" $":# '!6 %&" 3(% "2+# "(& %*"$ '&'(
"%% &*- $'( !!- %*"2 &;( 9*8 (?" gnp mot @~). char
s.map{ |c|[i=1-i] *(c .ord -32 )}*'';952.t ime s{| i|$><<(q[1
127-i] ||('#".% c'% 32)[ (a[ i]+a[i+95 2]) .to _i(2)])<
<$/ [~i %34]
}`* '';eval(s)
...#####..
.############.
###############.
###################..
#######################.
"########################.
#########################.
##########################
###########################
############################
##".##########################.
##.######################## ###.
######################### "###.
.######################### ####
########################## ####
.##"###################### "###
### "###################" "##
### ################## "
### ########"" "####.
##" ####### ######.
## #####" #########.
####" ########"#
##### "##"
####..
########
##########
########
"""""##" @tompng
require'io/console';h,w=IO.console&.winsize||[0,0];g=(0...m=[[h,w/2].min*2,48].max).map{[0]*m};[[524,489,%w(H9zR0b8H/R4EJlTy5fyPUDVdSVeyIiuzaChOoHiIwhiK9wfZpEuoHKGEBkHQcBv9EWmH28FW
XMf0kHDYhi0R3AYdgxEYgYNDGZiGKZ3zOTeC52RWRdv5Zr414suo7ujuEpZHeZyNUsMMEE5a0e41OvXu5/b3wvf/z299+f/lX6H4wQY)*l=''],[509,22,%w(FVAgpVA59DvdSraTKmVyJoeGk6FkaGhSNB1JDwE0SZK1gWKgHNjP98f1x9
a2uGluWnANC7Igx8wwS1+Tv+Qv/EiKpBD6iiAGPoFiME5G04EkHxpGEyxBOYmQiI2wMA1HEjEYg8Pq0Ua0jt8ggYR3yGADHbfcjOnkTc4M4RmZFpFWop6oD/wT+h/6D76Doi+pv67velZAD31yUDATzJBJ4WGhoZERsVwsmx8ZtCGHv7iCL3
b/9H73/rR/1n82fn170yv3y7Tbr/cb9Xq5Wqo9rxQrxXL7T7PZbPQ6DVHvV0wZBA)*l],[628,111,%w(APz70G6321JUVFU/w/+DhWA13My2cnqsHmvGssVuuBthciZt0/0oiMF4cDCDDMT+E4GFNqRP+0N/R0VURHQIhkEqDgAArBnqBDv
j3/MO7wJBNDHE U8tsBFBJBfmvOqpT7tV1Xf/0Xdqh3QgMgdDIJGSQaWawRlIppHE/4ailkFpooe5rYIAhhhrqsxop3LdaaeUbsA7r9HuoEqpEa8lmspVr5EzODOPpYCo4aDgAAQ)*l],[639,115,%w(EMzODowPTIweFIlH4zSNKG
KYeOihMsoo06y 3ZUfUZNu3XZF74AEEHnjQLOqe7jth+65vasBDDwD0AQ)*l],[417,358,%w(DndGi+FieHu5nqQmu6lwOBxOJ2KCCULYYUc/4P/4H/pACrjA/pI+6TOBIQImCcIwApMkQsIszhGHUUn7tK++gC7seoc7uJv/Bhqw0
a44bbX10EGXYT EQhymYU1k5/Veyl+xREVERFZEhGIbhMCUUA0oQhiGNIIIeAwyIjeEgDobCjDLGHeWUw6kYIEAkklCaouu6nukBAzQyCCCQHhnKh3LB0cHBwcHB4eFMOJMbAgAA1U+yLuq9/0ADDSwCCGSHAgCA/NAviGLje6fUKdW
LqqM6so0 88rFIMBgMZ oYhD4Humb7p V78 YYQSQ1jt ngUUG9kOW Ogo ppJBy5qmni mukU ccbbXWoZvu2L3t9I 0wLt mmbVjPNc
CPcCjbCz XA9Wg/ Wg6VgG7 V Rxwsjj Olqq50B B hjomAEGi J4DFgBoc
Q)*l],[9 +733 ,435,%w( HkcZp JAoC imgL EQght Rhi60 X2CAT dMggA 6Sz1gp voYWAW mhBp2+AA
RYDFA)*l],[33 +400,624 ,%w(AITHhrKh THZS iIUYBSEf 8sl+UAd 1SALn nfUGGNiJCt RHfd zTXV0rdm udWu0 NAAE)*l],[ 673,622,
%w(AOTaMRWXQz vcBm0QAA +cshpo0GA90iV d2ud 93kgBEA)* l],[513,3 +800, %w(APzLi3g/rl ImZZ JmIIyjOMtgj DEE1 BOfasRBHIwZz BBDEBGHH
flCO6zDu9RQzR DWyNi2FU 54KYUSbdEUrf6 7Mg AB)*l],[9 +680,683, %w(7W h9OQiBIKIEURS RHH LIWJAFaTQRJ BxTx C03kT9cBRVzHH AfYdQTgD
1yyAHltTfeSin FhVs1W7V 90okG)*l],[9+ 470, 766,%w(Do ORMARDhAL qqWUA AJBAERAGORd2Y R+z AACgpdVOmbb t275 qeesN9M4716J 92Ac1a6E
BHngc)*l],[9+ 650,765, %w(ANAulVTFe kxyi RTXTAdVCI VgOBvmERb DYRzB WQwAAEZZbXS v2ev 2u/WmErJvrB VO4L rXTnurnfbFU Ae3cY1op
JADDjnsMCCQBB nmhJMY4JB 74rhlvZAL uiCLQ woYYAAE)* l],[600,2 +7*10 ,%w(ANTKb dmSd VUGZfAxVIlU I+1UP 96P27BN 2RQZ6AeC
vJqJEEZIUkB8l FFMMW YEE gAtc8x N6BBPHPIA QvA9I7jkD uugCv Yyhlt mqcceeQwhBL F2UIVU TIdNWHMY
kVE5pBRpRVqgHu 6Gu3nJ FVfUQgml bIh+X1Rk2 7VcDfVxn0 jusCM Q IYLp0CTE kBjkkEPWW2y xjymmWItJJ JG0 GhnkmSGG
yLCEEvW9VkrZIqyhavw 7b/Em0cFOsB0pxP rRXtzFXcJmQBwn8KA4AAE)*l],[496,205,%w(FkpmiSWGQQgR99h jRxyy2BLlHXDGWRA)*l],[375,340,%w(DqiYCZtIbyCIwmg4hSGG0GGLbeQn6ZIu bgAAQCdtn
PX4j7feeOtB)*l],[645,130,%w(AJA8D/NwPBjncT4IxVmcJYKMMEIZ8BC0S33R77dkx3R0FWmrjVXQQZuj0AJb6HR0V5 c1AAE)*l],[433,379,%w(DlrosMMo7aIuIqM6oZO9jB6kB5lZ IOmTIIkh gthigzQqox
ZsggpuozZpY4klNVAj7QS00AILPQQEQgyRZT7ouU2iCIzQFCGEEkQ89ayLFZFIAgmlllBAEWwTQSR1uI/65oeRRkprvfUO eOQgCjvkkAXWWSeKzjnngQMB)*l],[843,387,%w(ANR+9tv9V qvknPXeO+gh
isAQCsIwi7PEyHkIYwIRAtBD5a231jvjtO2avul3/gMAwMAhGGGEEPQB)*l]].map{|x,y,c|c=c.unpack('m');c=c[0 ].unpack('b*')[0].chars;[]while'1'!=c.pop;n=[];n<<(c .shift==?0?(v=(
c.shift(4)*l).to_i(2))>7?v-=16:v:(v=(c.shift(5+2*a=c.shift.to_i)*l).to_i(2))>15+a*48?v-40-a*112:v+7+a*15)while(c[0]);c=[];n.each_slice(6).map{|q,r,s,t,u,v|u+=s+=q;v+=t+=r;n=(u.abs+
v.abs)*(w=m/1024.0)+1;n.to_i.times{|i|a=3*(1-z=i/n)**2*z;c<<[(x+a*q+z**3*u+s*b=3*z*z*(1-z))*w,(y+a*r+z**3*v+t*b)*w]};x+=u;y+=v};c}.zip([1,2,*([3]*8),4,4,*([5]*6)]){|c,a|s={};(0...(
c.size)).each{|i|u,v=c[i-2];x,y=c[i-1];([u,x].min.ceil..[u,x].max.floor).each{|j|j!=u&&(j!=x||(u-x)*(c[i][0]-x)<0)&&(s[j]||=[])<<v+(y-v)*(j-u)/(x-u)}};s.each{|i,t|t.sort_by(&:to_f)
.each_slice(2){|u,v|(u.ceil...v).each{|j|g[j][i]=a}}}};puts(g.each_slice(2).map{|a,b|(a.zip(b).map{|i,j|(%Q(\x20`''"^.:]TYY,;IEPPcjL8RRxLJ&WWxLJ&)+?#*2)[i+6*j]}*l).gsub(/\s+$/,l)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment