From f6bad295e3c97806dc384d845447bb174f565665 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 30 Aug 2020 08:35:46 +0900 Subject: [PATCH] Create basic images --- arrow.png | Bin 0 -> 380 bytes bot.png | Bin 0 -> 646 bytes branch.png | Bin 0 -> 1313 bytes conveyor.png | Bin 0 -> 689 bytes dot.png | Bin 0 -> 498 bytes dot.svg | 101 +++++++++++++++++++++++++++++++++++++++++++ game.js | 109 ++++++++++++++++++++++++++++++++++++++++++----- game.test.js | 39 +++++++++++------ index.html | 10 ++++- path839.png | Bin 0 -> 171 bytes questionmark.png | Bin 0 -> 638 bytes writer.png | Bin 0 -> 347 bytes 12 files changed, 235 insertions(+), 24 deletions(-) create mode 100644 arrow.png create mode 100644 bot.png create mode 100644 branch.png create mode 100644 conveyor.png create mode 100644 dot.png create mode 100644 dot.svg create mode 100644 path839.png create mode 100644 questionmark.png create mode 100644 writer.png diff --git a/arrow.png b/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..b750e875472c2e9a115de9b39bfa3a9b8470faf6 GIT binary patch literal 380 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)V!3HEX7_aUFQk(@Ik;OoIKL|4>Enx+5BuiW) zN`mv#O3D+9QW?t2%k?tzvWt@w3sUv+i_&Mmvyoz8VC3|4aSV}|8hdWz#HIj|)`#*H zb`m{uVhJjo5lt7x7+5V#Hl9?Qw&8CMBa4`W2U7}*fz`PK%oBO<94z$zb#~`>iRG6w z-|gx%@wJ?P{?AkCA4b<-o349ZWFgb>SVHqDPYsj(ved|mdF{Ek-;`NTQZY1}&3m9d zQ-Uo~V$l>Qug;*Z#~(Z1|DM6%#PRL7t(RulYSAFCMH*E~4O5DCDzq?EC^kH{U~y~+ z;yS%a;7|AKT{+vMmt|JvGkvM`kDL~xH@*By)Z|o2-^&ZO);+Z7ONn&5z3tBX@>Q#< z9+~)Z^BiVy2o#y|*+zfC*0?wk*T$a}HW|04t$QuDBX0eb(%v0+^S;#n-)3>Xn4yl5 Yr9E%Oxnl*Bfg#7>>FVdQ&MBb@0IIH+V*mgE literal 0 HcmV?d00001 diff --git a/bot.png b/bot.png new file mode 100644 index 0000000000000000000000000000000000000000..cf29a85e91f29925988f08400c165a26ca4dc112 GIT binary patch literal 646 zcmV;10(t$3P)EJ^bjNz#5>%W610-NSKH0FcV%aFOQ$0K2LRE5ksm zRA44a=(>)zViD)uZUDeyI(_rj+}zS}m#J0`UDuD6M`8f5G7JE~Odf_M2%;(mfCJ#5 zR&_$2T3>&5>c6GteaUh7pMnzfv5X)xArlZk~TGub1;?&TPClmX9JP)X2SffDew3!Ipkuw${93%7vJfPvj6 z6LuN*I`BF0awrtCPn|j?#9}c378e(pnVGSx)v5rj1DAjwUKAVvJ^g-#&Trq>xM|yS`;Qo#y7vo9^s$z&pV2 zJH>iBjVPawekH>>7%ZQ>#wOZ{8?(OZRr>6&9*O6tJL?R(PeE1Me(_RAJ!?FMNcJN!k zFTij#8s)-;3qm9kK@>$KNg@`DQ7VBR*hYwROmoZHfpU=nm_&9C=|l$_444s18_?0uOd#7pVKsr)zwvWT_=~zVOdtUoV$`` zS!6O9bX{k8d6`P30`MoWCN^TO0xT^pQ7V<#*w{c(lox_qmPI<9CZEq!DwVi@|GwMx zGk^=e0#3mPr}pOadFJQmF-`Nip{8k~C<^&}9#vHVxOeZK+kFkd+jz(TimIxkj~+cD z5{aN`8n$h7=guA4YxJ#Kw^&(O!SDBT{P=P9@8917O{dco3I)pLG61TovazuN&h7OV zv{tSNFc}JkaO<*R7}V=^N~IE}X}W7fFc{>>kt6i=^)Wj;ODdHDoO4_#6etu5EoWX) z6xZs@z>o0MYG~MR;$t9-`_IZb|^euLY#|-cJOWB z?csDGhl!(0p{oD zY1h`)R?9Ab{P;1`)6@9<{$`tD7|)DbSXgi!yaMQ*z+VBz;^HE@uG3A)WU|G9PFh%4 zaQ}X@y}cd$4{+Tu4DQ~&+cjbPy6>c7vB>)Rx|?^l8yMgV*xByw8Xq4g5D0XQX`5|* zd!P52XlJ``uB@yKs;Wv~-|oNHP1D3M3@pn+*Y)k-%k8n97U>h XdW8FoXkl4I00000NkvXXu0mjfdIMw^ literal 0 HcmV?d00001 diff --git a/conveyor.png b/conveyor.png new file mode 100644 index 0000000000000000000000000000000000000000..9dd109344089fba49df1ec98269604e66e18970c GIT binary patch literal 689 zcmV;i0#5yjP)R8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10zOGZ zK~y-6rPWv6d`ZZfBm`M>;k8~DL@yQ+hKPxVTRPoPHZ*it zq}ZEuVFgA+5oNi;T=AqNB8?rK|qfk;H5p`n+hr66SvH`e5osD(l@ z_4aNsnK@DK!X%1OTV4)ecl405aT7;t8{?jDUaNr1b)E5vS<0OrvUe3k=bEZgTX%`M zxi3_-c94;s8#Or;rmCuwZ{L4V>Fr`$ddB}3P*oLxv6nNPbhybaC|og3MV7<({R^CS zwUL>V7xUfX;!lFI!kN|%wx?&Vdcn9W&@>H`D02Lqlbw5u{zWX3m2#(ttbCi!l2cQu zXz3t5E0?trw}2oB964Lh?xKS_6U}DI>@IR_dvx}v*xxHzEkeAvK#4>U&BhyAuNmbx X0Jz(yu!$>K00000NkvXXu0mjf5aB%- literal 0 HcmV?d00001 diff --git a/dot.png b/dot.png new file mode 100644 index 0000000000000000000000000000000000000000..e6775099be6e82f181b6163802a18a2652b6e369 GIT binary patch literal 498 zcmVR8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10e?wE zK~y-6mD5ja6Hyce@LwlG-Of^Ii0i?+5*L%jPy=1)Hxb-r6+c9xh`Ol@KY(i&Md?84 zbXjQknP|wuRY0Lol8KASgrMmk4_r7r?z!*2d(Y!vJi;4X;P)~v@EW@t@>jTr5132zw@$;-y_%?Du^ZuNS-YsC;nkvNVWA0I2r@-aR)@Cr$%(~+j>O*2{* znNFvM!(o7{0Q-<6$*tlV?RLAS`vF>54eTyxHk&nl5UAGkUnt9RMFaexTGd@KnM`W> zJ-{L4d4A^tCnqO0Jq&Pwd6s30qPSID6oo9ys2uyTfuFcvmgSSPvomoVi=yaS@nA4; zd3i}?zE8Ciw^df|gkdO6Q|)$Jv)Qy*ER4rvd7jI%%zQqFuXv8D^$WID_MEx-GrhI; onKoe;eVpUhGR~K05C2a71KCcDR=Fs2ng9R*07*qoM6N<$f_{nG9RL6T literal 0 HcmV?d00001 diff --git a/dot.svg b/dot.svg new file mode 100644 index 0000000..9f56cc4 --- /dev/null +++ b/dot.svg @@ -0,0 +1,101 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/game.js b/game.js index ea6f466..9704d01 100644 --- a/game.js +++ b/game.js @@ -1,5 +1,20 @@ var canvas; +const IMAGE_CONVEYOR = new Image(); +IMAGE_CONVEYOR.src ="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAANCAYAAADISGwcAAAACXBIWXMAAADGAAAAxgGwdJvFAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAj5JREFUOI2l1V1IU2Ecx/Hv2dnOfKlIirpRb3xJyJokBFl04bVeF0QvFhKGiImGWzrdUDY0dFik2Jt0YQVGRBJBb2Io5lstMs2yi6LoSgqlbWc753TVbJ0zJfe7/H84D7/n/C8ewTc4pGGQsBzCIlmNaA2TsUiSoRnFFA/mX0/x9O4tQ5sefsbk88eG9mLwHu8mxhIvADDY18vIw/u6uaao9Pu8+EeGdaZEwtzwNPHBP514AU3TGOj2Mfrogc5UReFmu5uZ8VGdheUQV9x2Ft76EysAUFKyn4HLnUwNPYmZS1aJ4uJC+rzNvH81GWNbtqZhs2Vx1W3n8/xsYgWqqw9RWnqA/k4Pb0ZXfrkgCDQ3naJoXz7XWs7H3NZiEWlvqyRvRwY9zjq+fvq4/gKCIFBTc5jNaRu4c/ECocCvqImiCYfjGGZRoN/nRVWUqCUlSTQ2liEHA9zualt/gUhEoaGhl6WlIGUON9bklKiFQjL19m4wmTlR78IkilFbXg5gd/SQsnETR2sb455vXquAy3Wd8YlZyp0esncVROeaqlJbd4m5uS9UtHaQkZ0bNTkUpqqqk2/ff1Dp7WJbesb/F1BVFYCxlzOcdLjJLShcMU1FlsP4/QucdrWRmZMX893i4k+CssKZ1g62p2euesG4K9A0DZMocvyck517i/5FLJKVcqeHrHybzpJTU6lo6SA9K5e1EreAIAgcOVvP7qKDOhPNZsrsLnJse3T2p9jfK1ktQry3QIlEEM3GG1qvGeU3ALjbp7CJK1kAAAAASUVORK5CYII=" +const IMAGE_WRITER = new Image(); +IMAGE_WRITER.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAACgAAAAoAFdfrujAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAOhJREFUWIVjZCARhDX17njy4Ys5NjklYYHlS6rzs0gxj4VUB7z+/J352aevAtjkeDnYSTWOgYlkHVQGow4YdcCoA0YdMOAOYIxtm3T61ddvrETr+P9f6eefv7zYpNhZWN4yMDI8IdYoMW6u3yx337xXwVW2kwGEoZgo8Jnv54cBj4JRB4w6gEVfUmSOojD/f2I1fPv9J+z9tx/y2OREuLkusLMw7SbWLD42VkZGYhXDgGNpy+777z+5YJNTFxOavrOtgqQ24YBHwagDRh0w6oBRBwy4A0juHYvycv79+ffvB6xy3JwkOwAAdhs7qElosC8AAAAASUVORK5CYII=" +const IMAGE_ARROW = new Image(); +IMAGE_ARROW.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAPCAYAAAAoAdW+AAAACXBIWXMAAAC/AAAAvwFipAVzAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAQlJREFUGJVdzrGRglAUheEfeD4YjB4WYCQJWILRFgAFODSxySaWsP1sAQQWQEgCZAQwOs7AA5EN3MFxT/rNufcYp9Np7rqONE05n8/85Rv4MtfrNa7rcjgciOMYKeUMfAI/pmVZeJ6HbdvsdjuS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urKyliwUvjZy18DAwOBf8wM6KLN5YP6+kAAAAABJRU5ErkJggg==" +const IMAGE_BRANCH = new Image(); +IMAGE_BRANCH.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAcCAYAAAB2+A+pAAAACXBIWXMAAAC/AAAAvwFipAVzAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAABK5JREFUSIm1ls1rG0cYh59dSdGHv+TdBCRa2wQhhVqy40JIDoHaJK1JQijpISEUCqW3/AG999ZTb6VQeigtPbRpUvqRthAntO4ph1LT4KxsOR+yrdhJrcqKVitZu9rdHlarWIolHIf+QKCdeed9dn4z887C3hQBrgGfAn17zPHcehsoAnbjlwXe+D+BEvC1C5yYmLBjsZgLt4DPgIHdJhN2Gfc68DnwcigUsk+dOiXEYjEAFhcXmZmZsavVqgCsA5eAH14UHAA+AN4HxEQiwfT0NMFgsCVI0zRu3LhBJpNxm75tvMC/ewGngMvAK36/3z558qSQTCa7vmU6nebmzZvu7HPAO8DvO8V6OuR4F/geiA4NDXH+/HlhZGSkKxQgGo0yOjoqFItFCoVCfwO8D/gDZx90BAeAj4APAd+xY8c4c+YMwWCQgYEBarVaV3A4HEYUReLxOOFwmGw2K1iW9RpwGvgNKOwETgDXgTeDwaB97tw5YWJiAo/HgyzLiKJItVrtCu7t7aWnpwdd15FlmUQiITx8+BBN014C3sOx//Z28FvAL8BwNBrlwoULQiQSQRRFJEkiFotRKpXQNK0ruKenh8OHD1MulzFNE5/Px/j4OIIgkMvl9jU4SWDGA3zcsNd/9OhRzp49SyAQaELj8TiyLLO2trYr8NDQEAcOHEBVVQzDwDRNhoeHiUajZLNZ2zCMJHBaBF4FmJqaYnJyElEUm/bG43EkSeoK20k+n4+xsTFkWW4evYMHDzI1NeWeoqwIXAUoFosAeDweJEkikUjsCerK6/UyNjaGJEmEQiEAlpeX3e6fROA7wF5aWkIQBAYHBzl06BDhcHjPUFcej4dUKkUoFMLr9fLgwQNwS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P5wDAMvor4/X55OBzifD5DrfR6PTKZDEKh0CcIgKya8E3RaBTZbBaEEPz5PkgIgcVigdFoBMdxuF6v2G63WCwWN7vu9XrgOA7pdPoviGEYeL1ehMNhuFwusCx7s/rhcECn00Gj0cDlclHyVquFUCgEEolE5GQyCZPJpOp1hsMhqtUqZPmzkXg8Diafz6uGAFBO7avG4zGYB/N/lNPppPxut3sPpNPpbrK3QJIkUV6v178Hmk6nlHc4HK+DlsslRqMRlQUCgddA+/0etVqNOnq73Q6e529v9iNJkoRKpYLNZqNkWq0WuVwOANSBJpMJ6vU6RFFUMo1Gg0KhAIvF8hwkSRIEQUC/36dylmVRKpXgdruV7C7ocrmg3W6j2WzieDxSYzabDcViEWazmcrvggRBQKvVojKdTodUKoV4PA5CyM0zd0HX65XyPM8jm83CYDDcmw5A5c1OJBI/QlSD1Oj3ge6W7XA4qP/zs34egoLBIILB4Es7+k86GgwG2G63irdardR3pRrU7XYxm80UH4vFnoJ+X0f/DPQBTWisRXkNpbwAAAAASUVORK5CYII=" +const IMAGE_WRITER = new Image(); +IMAGE_WRITER.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAACgAAAAoAFdfrujAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAOhJREFUWIVjZCARhDX17njy4Ys5NjklYYHlS6rzs0gxj4VUB7z+/J352aevAtjkeDnYSTWOgYlkHVQGow4YdcCoA0YdMOAOYIxtm3T61ddvrETr+P9f6eefv7zYpNhZWN4yMDI8IdYoMW6u3yx337xXwVW2kwGEoZgo8Jnv54cBj4JRB4w6gEVfUmSOojD/f2I1fPv9J+z9tx/y2OREuLkusLMw7SbWLD42VkZGYhXDgGNpy+777z+5YJNTFxOavrOtgqQ24YBHwagDRh0w6oBRBwy4A0juHYvycv79+ffvB6xy3JwkOwAAdhs7qElosC8AAAAASUVORK5CYII=" + const WAITING = 0; const RUNNING = 1; const REVIEWING = 2; @@ -45,6 +60,12 @@ var WRITERRIGHT = {type:"WRITER",direction:RIGHT,color:RED} var WRITERUP = {type:"WRITER",direction:UP,color:RED} +var GRID_W = 32 +var GRID_H = 32 +var GRID_X = 20 +var GRID_Y = 20 + + var lastGameUpdate = 0; var gameSpeed = 1000/1; @@ -255,7 +276,7 @@ function runBot(testing) { gameState = REVIEWING BOT_STATE = DEAD } - if (!testing){renderGame()} + //if (!testing){renderGame()} } } @@ -273,11 +294,11 @@ function placeBot(x,y) { } function setupGame() { - canvas = document.createElement("CANVAS"); - canvas.style.width="100%" - canvas.style.height="100%" + canvas = document.createElement("canvas"); + canvas.width=568 + canvas.height=320 document.getElementById("game").appendChild(canvas) - + canvas.addEventListener("mousemove",updateMouse) //gameGrid = [...createGrid(5,5)] } @@ -309,23 +330,91 @@ function step() { } } +function updateMouse(e) { + //console.log(getMousePos(canvas,e)) +} + +function getMousePos(canvas, evt) { + var rect = canvas.getBoundingClientRect(); + return { + x: evt.clientX - rect.left, + y: evt.clientY - rect.top + }; +} + function renderGame() { var displayGrid = [] displayGrid = deepCopy(gameGrid) if (BOT_X!==-1&&BOT_Y!==-1) { displayGrid[BOT_Y][BOT_X]["BOT"]=true } - console.log("Tape: "+BOT_TAPE) - console.log(displayGrid) + /*console.log("Tape: "+BOT_TAPE) + console.log(displayGrid)*/ +} + +function colorToHex(r,g,b) { + function hex(col) { + function toHex(val) { + switch (Math.floor(val)) { + case 10:{ + return "a"; + }break; + case 11:{ + return "b"; + }break; + case 12:{ + return "c"; + }break; + case 13:{ + return "d"; + }break; + case 14:{ + return "e"; + }break; + case 15:{ + return "f"; + }break; + default:{ + return String(Math.floor(val)); + } + } + } + var placeValue1=col%16; + var placeValue2=col/16; + return toHex(placeValue2)+toHex(placeValue1) + } + return "#"+hex(r)+hex(g)+hex(b); +} + +function drawImage(x,y,img,ctx,degrees){ + //context.clearRect(0,0,canvas.width,canvas.height); + ctx.save(); + ctx.translate(x,y); + ctx.rotate(degrees*Math.PI/180); + ctx.drawImage(img,-img.width/2,-img.height/2); + ctx.restore(); } function draw() { var ctx = canvas.getContext("2d") - ctx.fillStyle="#FFF" + if (Math.random()<0.01) { + ctx.fillStyle="#a3adab" + } else { + ctx.fillStyle="#b5c4c1" + } ctx.fillRect(0,0,canvas.width,canvas.height) - ctx.beginPath(); - + renderGame() + for (var y=0;y<=gameGrid.length;y++) { + ctx.moveTo(GRID_X, GRID_Y+GRID_H*y); + ctx.lineTo(GRID_X+GRID_W*gameGrid.length, GRID_Y+GRID_H*y); + } + for (var x=0;x<=gameGrid.length;x++) { + ctx.moveTo(GRID_X+GRID_W*x, GRID_Y); + ctx.lineTo(GRID_X+GRID_W*x, GRID_Y+GRID_H*gameGrid.length); + } + ctx.fillStyle="#000000" ctx.stroke(); + //drawImage(0,0,IMAGE_CONVEYOR,ctx,0) } function ConsumeTape() { diff --git a/game.test.js b/game.test.js index 13c50be..73878c9 100644 --- a/game.test.js +++ b/game.test.js @@ -15,7 +15,7 @@ var TestSuite; class describe { constructor(testname) { this.testname=testname - this.beforecb = undefined; + this.beforecb = ()=>{}; this.cb = undefined; this.totaltests = 0; this.passedtests = 0; @@ -46,7 +46,7 @@ class describe { function expect(testval1,testval2,name) { if (testval1!==testval2) { - console.log(" Test Failed!"+" ("+(new Date().getTime()-TestSuite.starttime)+"ms)"+((name)?` - ${name}`:"")) + console.log(" Test Failed! Expected "+testval2+" but got "+testval1+". ("+(new Date().getTime()-TestSuite.starttime)+"ms)"+((name)?` - ${name}`:"")) TestSuite.totaltests++ testsPass=false } else @@ -453,6 +453,15 @@ function runTests() { }) .showResults() + TestSuite = new describe("Color Hex Conversion") + TestSuite + .it("converts a color to hex",()=>{ + expect(colorToHex(0,0,0),"#000000") + expect(colorToHex(66, 135, 245),"#4287f5") + expect(colorToHex(245, 66, 221),"#f542dd") + expect(colorToHex(58, 79, 55),"#3a4f37") + }).showResults() + if (testsPass===undefined) { testsPass=true } @@ -469,16 +478,22 @@ function runGame() { console.log("Running") } -loadScript("game.js",runTests) +var RUNTESTS = true; -initializeGame() +if (RUNTESTS) { + loadScript("game.js",runTests) -function initializeGame() { - if (testsPass) { - runGame() - } else { - setTimeout(()=>{ - initializeGame() - },1000) + initializeGame() + + function initializeGame() { + if (testsPass) { + runGame() + } else { + setTimeout(()=>{ + initializeGame() + },1000) + } } -} +} else { + loadScript("game.js",runGame) +} \ No newline at end of file diff --git a/index.html b/index.html index ef8719b..757e471 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,10 @@ - -
+ +
+
+
\ No newline at end of file diff --git a/path839.png b/path839.png new file mode 100644 index 0000000000000000000000000000000000000000..d7fb0a0cdf6c491169bfcd056825c24c5b0f1223 GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^+(698!3HEb%tIW26lZ})WHFFF2EvRRN@gDgG9*h} zBT9nv(@M${i&7cN%ggmL^RkPR6AM!H@{7`Ezq647Dzfl&aSY*@$*9Y4=|4koM*e?x z4)*^iPR#jVTbuNsiHYgIjko{*{>}UUCsZ{22de+SZ{L*vJw18-d~ zTXXNZxQ5=veV^U)oHM_3<~e7El*?uLbUIUa#10w^%F|H@oijdf+$?>2&%ph+!Cby7@K_w|fty)9G%qw?L94QC_dtzXzI5r<8X%9Iu0x%Oysm5tRi3f!9F$ z{T{VijXHX}-434TZ*TS^Ns@$0rGm|7qhwmG7P(vw0MvmdlL_keIz&-aGL1%qLZJYQ z#qt~^NfHD>K)>Ioa+YOLDwW`NyOr!N=yJKB-EO1VY~px4Qe!ro4aH&+X0w^f?}7wD zK&#cFGM!F`R4RpdJPtz0%`)f`Y*yg2CWRJNi#L8Vm;5ZnuiJTCLP~r5e=jb}^gH6d#Mlo`QZ~NB<1; Y0ZnMEMR^USyZ`_I07*qoM6N<$f~esn3;+NC literal 0 HcmV?d00001 diff --git a/writer.png b/writer.png new file mode 100644 index 0000000000000000000000000000000000000000..c8aa48a375701afeaf70d2319aab41808873f241 GIT binary patch literal 347 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVj#T$gc)P&b}t4pBuiW) zN`mv#O3D+9QW?t2%k?tzvWt@w3sUv+i_&MmvylQSdg1Bf7!uK%oT4DuV*2%6#ixhe zmS&c!iH%RaSAE{>Vc6dq!oKI`d<4J|(4Nud)#?BPk5Vpm95~T-LFuTbb zJm5>{$(>#D>+1FVH7>7z{EvV6eE$ADHDZZtxw$2Y9&Sj^JpJzXd;6UUlY_;DXYJd(wrPpk!v^<*V28YF2xRBk!R+x)w)<1j nzrR1fzh_@lbZ3r=H3LJLwDk(lj1BrgKQnl``njxgN@xNAU1pP$ literal 0 HcmV?d00001