diff --git a/pouet.json b/pouet.json deleted file mode 100644 index 0967ef4..0000000 --- a/pouet.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/src/index.tsx b/src/index.tsx index 9d5989e..ddac7ff 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -25,7 +25,7 @@ app.listen(3000, () => { * * @return the list of files included in this folder/subfolders */ -async function filesList(Path: string): Promise> { +async function filesList(Path: string): Promise> { // serach returns all the files in a folder and all its subfolders const files: Array = [] const subFolders = await fs.readdir(Path) @@ -41,7 +41,7 @@ async function filesList(Path: string): Promise> { return files } -app.get('/program', (_req, res) => { +app.get('/program', (_req, res) => { // process the images after checking by hash that they were not processed before (async (dirPath: string) => { const files = await filesList(dirPath) @@ -55,7 +55,7 @@ app.get('/program', (_req, res) => { console.log('handeling...') } - for await (const file of files) { + for await (const file of files) { const bFile = path.basename(file) const pName = path.dirname(file) const hash = crypto.createHash('sha256') @@ -74,13 +74,13 @@ app.get('/program', (_req, res) => { await fs.writeFile('output.json', JSON.stringify(json)) try{ const image = await Jimp.read(readI) - image.sepia() - image.rgba(true) - image.contain(256, 256) + image.sepia() // turn images to sepia + image.rgba(true) // activate Alfa channel + image.contain(256, 256) // put in a 256x256 square const index = bFile.lastIndexOf('.') const newBaseName = bFile.slice(0, index) + '.png' const newFileName = pName + '/.' + newBaseName - await image.writeAsync(`${newFileName}`) + await image.writeAsync(`${newFileName}`) // processed images are renamed as hidden files and put back next to originals }catch (err){ console.log('this file is not an image') } @@ -91,7 +91,7 @@ app.get('/program', (_req, res) => { })('./assets') }) -async function listToSend() { +async function listToSend() { // returns sorted and filtered list to be displayed at url '/' const listFiles = readdirSync('./assets') const listFinal: Array> = [] @@ -106,7 +106,7 @@ async function listToSend() { return listToSend } -app.get('/code', async (_, res) => { +app.get('/code', async (_, res) => { // sends previous list to '/code' const data = await listToSend() const lenght = data.length if (lenght !== 0){ @@ -115,12 +115,12 @@ app.get('/code', async (_, res) => { }) -async function base() { +async function base() { // returns list to be displayed when url '/' is refreshed const listFiles = readdirSync('./assets') const outerListFinal: Array> = [] const innerListFinal: Array = [] for(const perso of listFiles){ - const listPerso = await filesList('./assets/' + perso) + const listPerso = await filesList('./assets/' + perso) // takes all files in folder and subfolder and return those starting with .base for(const image of listPerso){ const bName = path.basename(image) if(bName.startsWith('.base')){ @@ -129,7 +129,7 @@ async function base() { } } outerListFinal.push(innerListFinal) - return outerListFinal + return outerListFinal // returns list of list because images and anims are choosen through specific coordinates based on their rank in list } app.get('/', async (_, res) => { @@ -167,7 +167,7 @@ app.get('/', async (_, res) => {
-
+ { } + `}}> } )) } -}) \ No newline at end of file +}) diff --git a/test.js b/test.js index bc4faf2..430a501 100644 --- a/test.js +++ b/test.js @@ -1,7 +1,6 @@ let intervalIds = []; let listToRandom = [0, 1, 2, 3, 4, 5] -let countPerso = 0; -console.log('ouaip') +let countPerso = 0; fetch('http://localhost:3000/code') .then(function(response) { return response.json(); @@ -14,23 +13,19 @@ fetch('http://localhost:3000/code') let timeOuter = 3000; let timeInner = 500; let countAnim = 1; - if(countPerso === 5){ + if(countPerso === 6){ countPerso = 0 - } if(countPerso === 0){ notSoRandomList = notSoRandomPerso() - } - let perso = notSoRandomList[countPerso] - countPerso = countPerso + 1; - // let minPerso = 0; - // let maxPerso = 5; - // let perso = Math.floor(Math.random() * (maxPerso - minPerso + 1) + minPerso); + let perso = notSoRandomList[countPerso] + let length = data[perso].length if(length*timeInner > timeOuter){ timeOuter = length*timeInner + timeInner } + countPerso = countPerso + 1; let imgElement = document.getElementById(perso); if (imgElement){ intervalIds.push(setInterval(function() { @@ -58,9 +53,5 @@ fetch('http://localhost:3000/code') console.log(listToRandom) return listToRandom } - function stopIntervals() { - intervalIds.forEach(clearInterval); - intervalIds = []; - } runIntervals(); }); \ No newline at end of file