memoscan
← all memos

Memo 0xc07779bc…9d6134 on Ethereum

<html> <head> <style> polyline { stroke-width: 3; stroke: black; stroke-opacity: 1; } </style> </head> <body> <svg width="900" height="900" id="svg" style="background-color:#ddd"></svg> <script> function createPath(bloodAlcohol, startX, startY) { let x = startX; let y = startY; let angle = 0; let radius = 1; const points = [{ x, y }]; function isOutOfBounds(x, y) { return x < startX - 70 || x >= startX + 70 || y < startY - 70 || y >= startY + 70; } while (!isOutOfBounds(x, y)) { angle += (.15 + bloodAlcohol * Math.random() * 0.05) % (2 * Math.PI); radius = Math.pow(angle, 1.09); // radius = 2 * angle; // radius += 1; const dx = Math.cos(angle) * radius; const dy = Math.sin(angle) * radius; x = startX + dx; y = startY + dy; points.push({ x, y }); } return points; } function drawPath(points, svg) { function pointToCubicBezier(i) { if (i < points.length - 1) { const x1 = points[i].x; const y1 = points[i].y; const x2 = points[i + 1].x; const y2 = points[i + 1].y; const xc1 = (x1 + x2) / 2; const yc1 = (y1 + y2) / 2; const xc2 = (xc1 + x2) / 2; const yc2 = (yc1 + y2) / 2; return `C ${xc1},${yc1} ${xc1},${yc1} ${xc2},${yc2}`; } return ''; } const d = `M ${points[0].x},${points[0].y} ` + points.slice(1).map((_, i) => pointToCubicBezier(i)).join(' '); const path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); path.setAttribute('d', d); path.setAttribute('fill', 'none'); path.setAttribute('stroke', 'black'); path.setAttribute('stroke-width', '3'); svg.appendChild(path); } const svg = document.getElementById('svg'); const gridRows = 5; const gridColumns = 5; const cellSize = 180; const totalCells = gridRows * gridColumns; for (let row = 0; row < gridRows; row++) { for (let col = 0; col < gridColumns; col++) { const startX = col * cellSize + 90; const startY = row * cellSize + 90; const cellIndex = row * gridColumns + col; const bloodAlcohol = cellIndex / (totalCells - 1) * 70; // Compute blood alcohol level based on cell index const pathPoints = createPath(bloodAlcohol, startX, startY); drawPath(pathPoints, svg); } } </script> </body> </html>