To achieve the scaling of your entire layout through a CSS transformation without changing the individual elements, you can wrap your existing content in a container div and apply a scale transformation to that container. Here's the modified code with the necessary adjustments:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Trans-Dimensional Quantum ASCII/SVG Nexus</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #1c1c1c;
color: #ffffff;
font-family: monospace;
white-space: pre;
}
.container {
transform: scale(2); /* Adjust the scale factor as needed */
transform-origin: center; /* Ensures scaling is centered */
}
svg {
position: absolute;
width: 100px; /* Adjusted size due to scaling */
height: 200px; /* Adjusted size due to scaling */
}
#quantumAsciiMatrix {
z-index: 1;
}
</style>
</head>
<body>
<div class="container">
<pre id="quantumAsciiMatrix"></pre>
<svg id="vectorialManifestation" viewBox="0 0 200 400">
<text id="protonQuantization" x="100" y="100" text-anchor="middle" dominant-baseline="middle" fill="red" font-family="monospace" font-size="20">O</text>
<text id="neutronQuantization" x="100" y="100" text-anchor="middle" dominant-baseline="middle" fill="black" opacity="0.5" font-family="monospace" font-size="20">:</text>
</svg>
</div>
<script>
const quantumAsciiMatrixElement = document.getElementById('quantumAsciiMatrix');
const vectorialManifestationElement = document.getElementById('vectorialManifestation');
const protonQuantizationElement = document.getElementById('protonQuantization');
const neutronQuantizationElement = document.getElementById('neutronQuantization');
const hyperDimensionalStrataRows = 20;
const hyperDimensionalStrataCols = 17;
let protonCoordX = 8;
let protonCoordY = hyperDimensionalStrataRows - 1;
const interruptiveTopology = [];
const obstructiveCount = 5;
const modulationInterval = 500;
function initializeObstructions() {
for (let i = 0; i < obstructiveCount; i++) {
interruptiveTopology.push({
coordX: Math.floor(Math.random() * hyperDimensionalStrataCols),
coordY: Math.floor(Math.random() * hyperDimensionalStrataRows)
});
}
}
function renderQuantumMatrix() {
const asciiMatrix = Array(hyperDimensionalStrataRows).fill('').map(() => Array(hyperDimensionalStrataCols).fill(' '));
interruptiveTopology.forEach(obstacle => {
if (obstacle.coordY < hyperDimensionalStrataRows) {
asciiMatrix[obstacle.coordY][obstacle.coordX] = ':';
}
});
const isProtonActive = interruptiveTopology.some(obstacle =>
obstacle.coordX === protonCoordX &&
obstacle.coordY === protonCoordY
);
asciiMatrix[protonCoordY][protonCoordX] = isProtonActive ? ' ' : 'O';
let outputRepresentation = '';
for (let row of asciiMatrix) {
outputRepresentation += '|' + row.join('') + '|\n';
}
quantumAsciiMatrixElement.innerHTML = outputRepresentation;
protonQuantizationElement.setAttribute('x', protonCoordX * 11.76 + 7);
protonQuantizationElement.setAttribute('y', protonCoordY * 20 + 10);
vectorialManifestationElement.style.display = isProtonActive ? 'block' : 'none';
}
function updateObstructions() {
interruptiveTopology.forEach(obstacle => {
if (obstacle.coordY < hyperDimensionalStrataRows - 1) {
obstacle.coordY++;
} else {
obstacle.coordY = 0;
obstacle.coordX = Math.floor(Math.random() * hyperDimensionalStrataCols);
}
});
}
window.addEventListener('keydown', (event) => {
switch (event.key) {
case 'ArrowLeft':
protonCoordX = Math.max(protonCoordX - 1, 0);
break;
case 'ArrowRight':
protonCoordX = Math.min(protonCoordX + 1, hyperDimensionalStrataCols - 1);
break;
case 'ArrowUp':
protonCoordY = Math.max(protonCoordY - 1, 0);
break;
case 'ArrowDown':
protonCoordY = Math.min(protonCoordY + 1, hyperDimensionalStrataRows - 1);
break;
}
renderQuantumMatrix();
});
setInterval(() => {
updateObstructions();
renderQuantumMatrix();
}, modulationInterval);
initializeObstructions();
renderQuantumMatrix();
</script>
</body>
</html>
Key Modifications:
-
Container Div: All content is wrapped in a <div class="container"> to serve as the scaling container.
-
CSS Scale: The transform: scale(2); property is applied to the container, which scales everything inside it uniformly. Adjust the value of the scale factor as needed.
-
SVG Size Adjustments: Width and height of the SVG elements are adjusted for better fit depending on the scale.
Now, you can easily control the size of the entire layout by just changing the scale value in the CSS.