parsing tool pour collision
This commit is contained in:
		
							parent
							
								
									2c6bf39293
								
							
						
					
					
						commit
						994dfce82a
					
				
					 1 changed files with 40 additions and 0 deletions
				
			
		
							
								
								
									
										40
									
								
								tools/parsing_json.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								tools/parsing_json.html
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,40 @@ | |||
| <!DOCTYPE html> | ||||
| <html lang="en"> | ||||
| <head> | ||||
|   <meta charset="UTF-8"> | ||||
|   <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||
|   <title>Conversion json to js let</title> | ||||
|   <script> | ||||
|     function convertInput() { | ||||
|       const jsonString = document.getElementById('jsonInput').value; | ||||
|       const z = document.getElementById('numberInput').value; | ||||
| 
 | ||||
|       const data = JSON.parse(jsonString); | ||||
| 
 | ||||
|       const squareArray = data.squares.map(square => `new Square(${square.x},${square.y},${z},${square.w},${square.h})`); | ||||
|       const circleArray = data.circles.map(circle => `new Circle(${circle.x},${circle.y},${z},${circle.r})`); | ||||
| 
 | ||||
|       const resultString = `let map${z}Squares = [${squareArray.join(',')}]<br>let map${z}Circles = [${circleArray.join(',')}]`; | ||||
|       document.getElementById('output').innerHTML = resultString; | ||||
|     } | ||||
|   </script> | ||||
| </head> | ||||
| <body> | ||||
|   <h1>Conversion json to js let</h1> | ||||
| 
 | ||||
|   <label for="jsonInput">Entrée JSON :</label> | ||||
|   <textarea id="jsonInput" rows="5" cols="50" placeholder='{"squares":[{"x":100.96875,"y":64,"w":47,"h":45},{"x":280.96875,"y":46,"w":42,"h":39}],"circles":[{"x":882.96875,"y":133,"r":14.142135623730951},{"x":890.96875,"y":249,"r":17.029386365926403}]}'></textarea> | ||||
| 
 | ||||
|   <br> | ||||
| 
 | ||||
|   <label for="numberInput">z :</label> | ||||
|   <input type="number" id="numberInput" placeholder="Entrez le z de la map"> | ||||
| 
 | ||||
|   <br> | ||||
| 
 | ||||
|   <button onclick="convertInput()">Convertir</button> | ||||
| 
 | ||||
|   <h2>Résultat :</h2> | ||||
|   <div id="output"></div> | ||||
| </body> | ||||
| </html> | ||||
		Loading…
	
		Reference in a new issue