Project

General

Profile

Improvement #1412

Updated by Axel "Elanis" Soupé 7 months ago

Test: 
 ``` 
 function calcNextLayer() { 
	 prevLayer++; 

	 const layerMaxItemsPerLine = (-1 + prevLayer * 4); 
	 const layerMaxItemsPerColumn = (-1 + prevLayer * 2); 

 /* 
	 f(1) = (1/1) 
	 f(2) = (5/3) 
	 f(3) = (9/5) 
	 f(4) = (13/7) 
	 f(5) = (17/9) 
 */ 

	 const newPoints = []; 
	 for(let itemX = 0; itemX < layerMaxItemsPerLine; itemX++) { 
		 for(let itemY = 0; itemY < layerMaxItemsPerColumn; itemY++) { 
			 let x = (-0.5 * layerMaxItemsPerLine + itemX + 0.5) * itemsFinalDistance + itemsFinalDistance / 2; 
			 let y = (-0.5 * layerMaxItemsPerColumn + itemY + 0.5) * itemsFinalDistance + itemsFinalDistance / 2; 

			 if(!positions.find(p => p.x === x && p.y === y)) { 
				 newPoints.push({ x, y }); 
			 } 

			 /*if(itemY === 0 || itemY === (layerMaxItemsPerColumn - 1) || itemX === 0 || itemX === (layerMaxItemsPerLine - 1)) { 
				 newPoints.push({ 
					 x: (-0.5 * layerMaxItemsPerLine + itemX + 0.5) * itemsFinalDistance, 
					 y: (-0.5 * layerMaxItemsPerColumn + itemY + 0.5) * itemsFinalDistance, 
				 }); 
			 }*/ 
		 } 
	 } 

	 positions = [...positions, ...newPoints]; 

	 console.log(newPoints); 

	 return newPoints; 
 } 
 ```

Back