Update index.html
This commit is contained in:
164
index.html
164
index.html
@@ -3,137 +3,30 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Full Pixel Wipe</title>
|
<title>Full Screen Pixel Wipe</title>
|
||||||
<style>
|
<style>
|
||||||
html, body {
|
html, body {
|
||||||
margin:0; padding:0; overflow:hidden; height:100%; width:100%;
|
margin:0; padding:0; overflow:hidden; width:100%; height:100%;
|
||||||
background: linear-gradient(135deg,#667eea 0%,#764ba2 100%);
|
background: linear-gradient(135deg,#667eea 0%,#764ba2 100%);
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: sans-serif;
|
||||||
}
|
}
|
||||||
.calculator {
|
|
||||||
background:#2d3748; border-radius:20px; padding:30px; box-shadow:0 20px 60px rgba(0,0,0,0.5); width:400px;
|
|
||||||
position: absolute; top:50%; left:50%; transform:translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
.display {
|
|
||||||
background:#1a202c; border-radius:10px; padding:20px; margin-bottom:20px; text-align:right; min-height:100px; display:flex; flex-direction:column; justify-content:flex-end;
|
|
||||||
}
|
|
||||||
.equation { color:#a0aec0; font-size:18px; min-height:25px; margin-bottom:10px; }
|
|
||||||
.current { color:#fff; font-size:36px; font-weight:600; }
|
|
||||||
.buttons { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
|
|
||||||
button { padding:24px; font-size:20px; font-weight:600; border:none; border-radius:10px; cursor:pointer; transition:all 0.2s; color:#fff; }
|
|
||||||
button:hover { transform:translateY(-2px); box-shadow:0 4px 12px rgba(0,0,0,0.3); }
|
|
||||||
button:active { transform:translateY(0); }
|
|
||||||
.number { background:#4a5568; }
|
|
||||||
.operator { background:#ed8936; }
|
|
||||||
.clear { background:#e53e3e; grid-column:span 2; }
|
|
||||||
.equals { background:#48bb78; grid-column:span 2; }
|
|
||||||
|
|
||||||
#wipeCanvas {
|
#wipeCanvas {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top:0; left:0;
|
top:0; left:0;
|
||||||
width:100vw; height:100vh;
|
width:100vw; height:100vh;
|
||||||
z-index:9999;
|
z-index:9999;
|
||||||
|
cursor:none; /* muis weg */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="calculator">
|
|
||||||
<div class="display">
|
|
||||||
<div class="equation" id="equation"></div>
|
|
||||||
<div class="current" id="current">0</div>
|
|
||||||
</div>
|
|
||||||
<div class="buttons">
|
|
||||||
<button class="clear" onclick="clearCalculator()">C</button>
|
|
||||||
<button class="clear" onclick="triggerPixelWipe()">💥 Wipe</button>
|
|
||||||
<button class="operator" onclick="appendOperator('/')">/</button>
|
|
||||||
<button class="operator" onclick="appendOperator('*')">×</button>
|
|
||||||
|
|
||||||
<button class="number" onclick="appendNumber('7')">7</button>
|
|
||||||
<button class="number" onclick="appendNumber('8')">8</button>
|
|
||||||
<button class="number" onclick="appendNumber('9')">9</button>
|
|
||||||
<button class="operator" onclick="appendOperator('-')">-</button>
|
|
||||||
|
|
||||||
<button class="number" onclick="appendNumber('4')">4</button>
|
|
||||||
<button class="number" onclick="appendNumber('5')">5</button>
|
|
||||||
<button class="number" onclick="appendNumber('6')">6</button>
|
|
||||||
<button class="operator" onclick="appendOperator('+')">+</button>
|
|
||||||
|
|
||||||
<button class="number" onclick="appendNumber('1')">1</button>
|
|
||||||
<button class="number" onclick="appendNumber('2')">2</button>
|
|
||||||
<button class="number" onclick="appendNumber('3')">3</button>
|
|
||||||
<button class="number" onclick="appendNumber('0')">0</button>
|
|
||||||
|
|
||||||
<button class="number" onclick="appendNumber('.')">.</button>
|
|
||||||
<button class="equals" onclick="triggerPixelWipe()">=</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let currentValue = '0';
|
function fullScreenPixelWipe() {
|
||||||
let previousValue = '';
|
|
||||||
let operation = '';
|
|
||||||
let shouldResetScreen = false;
|
|
||||||
|
|
||||||
function updateDisplay() {
|
|
||||||
document.getElementById('current').textContent = currentValue || '';
|
|
||||||
let equationText = previousValue;
|
|
||||||
if (operation) equationText += ' ' + operation;
|
|
||||||
document.getElementById('equation').textContent = equationText;
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendNumber(num) {
|
|
||||||
if (currentValue === '0' || shouldResetScreen) {
|
|
||||||
currentValue = num;
|
|
||||||
shouldResetScreen = false;
|
|
||||||
} else {
|
|
||||||
currentValue += num;
|
|
||||||
}
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendOperator(op) {
|
|
||||||
if (operation && !shouldResetScreen) calculate();
|
|
||||||
previousValue = currentValue;
|
|
||||||
operation = op;
|
|
||||||
shouldResetScreen = true;
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
function calculate() {
|
|
||||||
const prev = parseFloat(previousValue);
|
|
||||||
const current = parseFloat(currentValue);
|
|
||||||
if (isNaN(prev) || isNaN(current)) return;
|
|
||||||
let result;
|
|
||||||
switch(operation){
|
|
||||||
case '+': result=prev+current; break;
|
|
||||||
case '-': result=prev-current; break;
|
|
||||||
case '*': result=prev*current; break;
|
|
||||||
case '/': result=prev/current; break;
|
|
||||||
default: return;
|
|
||||||
}
|
|
||||||
currentValue = result.toString();
|
|
||||||
operation='';
|
|
||||||
previousValue='';
|
|
||||||
shouldResetScreen=true;
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearCalculator() {
|
|
||||||
currentValue='0';
|
|
||||||
previousValue='';
|
|
||||||
operation='';
|
|
||||||
shouldResetScreen=false;
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ======================== PIXEL WIPE ===========================
|
|
||||||
function triggerPixelWipe() {
|
|
||||||
// fullscreen request
|
// fullscreen request
|
||||||
if(document.documentElement.requestFullscreen) document.documentElement.requestFullscreen();
|
if(document.documentElement.requestFullscreen) document.documentElement.requestFullscreen();
|
||||||
document.body.style.cursor = 'none'; // muis weg
|
|
||||||
|
|
||||||
// maak canvas
|
// maak canvas fullscreen
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.id = 'wipeCanvas';
|
canvas.id = 'wipeCanvas';
|
||||||
canvas.width = window.innerWidth;
|
canvas.width = window.innerWidth;
|
||||||
@@ -144,46 +37,43 @@ function triggerPixelWipe() {
|
|||||||
// screenshot van huidige body
|
// screenshot van huidige body
|
||||||
ctx.drawImage(document.body,0,0,canvas.width,canvas.height);
|
ctx.drawImage(document.body,0,0,canvas.width,canvas.height);
|
||||||
|
|
||||||
let imageData = ctx.getImageData(0,0,canvas.width,canvas.height);
|
// pixel data
|
||||||
let pixels = imageData.data;
|
const imageData = ctx.getImageData(0,0,canvas.width,canvas.height);
|
||||||
|
const pixels = imageData.data;
|
||||||
|
|
||||||
// alle pixel indices in array
|
// array met alle pixel indices
|
||||||
let pixelIndices = [];
|
let indices = [];
|
||||||
for(let i=0;i<pixels.length;i+=4) pixelIndices.push(i);
|
for(let i=0; i<pixels.length; i+=4) indices.push(i);
|
||||||
|
|
||||||
// shuffle voor random fade
|
// shuffle indices voor random effect
|
||||||
for(let i=pixelIndices.length-1;i>0;i--){
|
for(let i=indices.length-1;i>0;i--){
|
||||||
const j = Math.floor(Math.random()*(i+1));
|
const j = Math.floor(Math.random()*(i+1));
|
||||||
[pixelIndices[i],pixelIndices[j]]=[pixelIndices[j],pixelIndices[i]];
|
[indices[i],indices[j]]=[indices[j],indices[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
let step = 0;
|
let step = 0;
|
||||||
const interval = setInterval(()=>{
|
const interval = setInterval(()=>{
|
||||||
for(let s=0;s<2000;s++){ // aantal pixels per frame
|
for(let s=0;s<3000;s++){ // pixels per frame
|
||||||
if(step>=pixelIndices.length){
|
if(step >= indices.length){
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
canvas.remove(); // alles weg
|
canvas.remove();
|
||||||
document.body.innerHTML=''; // optional: alles leeg maken
|
document.body.innerHTML = ''; // alles weg
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const idx=pixelIndices[step];
|
const idx = indices[step];
|
||||||
pixels[idx]=0; pixels[idx+1]=0; pixels[idx+2]=0; pixels[idx+3]=255;
|
pixels[idx] = 0; // R
|
||||||
|
pixels[idx+1] = 0; // G
|
||||||
|
pixels[idx+2] = 0; // B
|
||||||
|
pixels[idx+3] = 255; // A
|
||||||
step++;
|
step++;
|
||||||
}
|
}
|
||||||
ctx.putImageData(imageData,0,0);
|
ctx.putImageData(imageData,0,0);
|
||||||
},16); // ~60fps
|
},16); // ~60fps
|
||||||
}
|
}
|
||||||
|
|
||||||
// keyboard support
|
// start animatie na 1 sec (of trigger via knop)
|
||||||
document.addEventListener('keydown',(e)=>{
|
setTimeout(fullScreenPixelWipe, 1000);
|
||||||
if(e.key>='0' && e.key<='9') appendNumber(e.key);
|
|
||||||
else if(e.key==='.') appendNumber('.');
|
|
||||||
else if(e.key==='+'||e.key==='-'||e.key==='*'||e.key==='/') appendOperator(e.key);
|
|
||||||
else if(e.key==='Enter'||e.key==='='){ e.preventDefault(); triggerPixelWipe(); }
|
|
||||||
else if(e.key==='Escape'||e.key==='c'||e.key==='C') clearCalculator();
|
|
||||||
});
|
|
||||||
|
|
||||||
updateDisplay();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user