���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home/rickpfrv/public_html/pixel/script.js
���ѧ٧ѧ�
document.addEventListener('DOMContentLoaded', function() { const canvas = document.getElementById('followerCanvas'); const hiddenCanvas = document.getElementById('hiddenCanvas'); const ctx = canvas.getContext('2d'); const hiddenCtx = hiddenCanvas.getContext('2d'); const image = new Image(); const mult = 2 // Update this path to your image's path image.src = 'images/img2.png'; // Load the image into the hidden canvas when the image is loaded image.onload = function() { hiddenCtx.drawImage(image, 0, 0, canvas.width, canvas.height); }; function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } document.getElementById('setButton').addEventListener('click', function() { const previousDay = parseInt(document.getElementById('previousDay').value); const currentDay = parseInt(document.getElementById('currentDay').value); //document.getElementById("nf").innerHTML = numberWithCommas(Math.abs(previousDay - currentDay)); document.getElementById("nt").innerHTML = numberWithCommas(currentDay); document.getElementById("ava").src = document.getElementById('ica').value document.getElementById("usr").innerHTML = document.getElementById('icu').value document.getElementById("cmt").innerHTML = document.getElementById('icc').value document.getElementById("plat").innerHTML = document.getElementById('platform').value if (document.getElementById('platform').value == "YT") { document.getElementById('type1').innerHTML = "Subscribers" document.getElementById('type2').innerHTML = "Subscribers" } else { document.getElementById('type1').innerHTML = "Followers" document.getElementById('type2').innerHTML = "Followers" } uncoverPixels(previousDay); }); document.getElementById('goButton').addEventListener('click', function() { const previousDay = parseInt(document.getElementById('previousDay').value); const currentDay = parseInt(document.getElementById('currentDay').value); animateUncoverPixels(previousDay, currentDay); }); function shuffleArray(array) { for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } } const totalPixels = 387 * 387; const pixelPositions = []; for (let i = 0; i < totalPixels; i++) { pixelPositions.push(i); } shuffleArray(pixelPositions); function uncoverPixels(count) { for (let i = 0; i < count * mult; i++) { const position = pixelPositions[i]; const x = (position % 387); const y = Math.floor(position / 387); const pixel = hiddenCtx.getImageData(x, y, 1, 1); ctx.putImageData(pixel, x, y); applySaturationToCanvas(calculateSaturation(count * mult)) } } function calcBright(x) { let base = Math.round(x * 10) / 10 * 3 if (base > 1) { base = 1 } else if (base < 0.2) { base = 0.2 } return base; } function animateUncoverPixels(start, end) { const animationDuration = 2000; // 5000 milliseconds = 5 seconds let totalPixelsToAnimate = end - start; totalPixelsToAnimate = totalPixelsToAnimate * mult; let pixelsUncovered = 0; animateSaturationChange(start, end) // Calculate interval time if we uncover 1 pixel at a time let intervalTime = animationDuration / totalPixelsToAnimate; // For very high numbers of pixels, intervalTime will be < 1ms, // which is not reliable due to JavaScript's setTimeout/setInterval precision. // So, we uncover multiple pixels per frame when necessary. let pixelsPerFrame = 1; if (intervalTime < 1) { pixelsPerFrame = Math.ceil(1 / intervalTime); intervalTime = 1; // Minimum time interval set to 1ms } const interval = setInterval(() => { for (let p = 0; p < pixelsPerFrame; p++) { // Check if we've reached the total pixels to uncover if (pixelsUncovered >= totalPixelsToAnimate) { clearInterval(interval); break; } const position = pixelPositions[start + pixelsUncovered]; const x = (position % 387); const y = Math.floor(position / 387); const pixel = hiddenCtx.getImageData(x, y, 1, 1); ctx.putImageData(pixel, x, y); pixelsUncovered++; document.getElementById("nf").innerHTML = Math.trunc(pixelsUncovered / mult); document.getElementById("pixels").innerText = Math.trunc(pixelsUncovered / mult); } }, intervalTime); } // Example function to calculate saturation based on follower count function calculateSaturation(followerCount) { const maxFollowers = 150000; // Maximum follower count // Normalize follower count to a 0-1 scale const normalizedCount = followerCount / maxFollowers; // Apply a quadratic curve for more dramatic increase towards the end let saturation = Math.min(1, normalizedCount * normalizedCount); if (saturation < 0.2) { saturation = 0.2 } return saturation; } function applySaturationToCanvas(saturation) { const canvas = document.getElementById('followerCanvas'); canvas.style.filter = `saturate(${saturation}) brightness(${calcBright(saturation)})`; } function animateSaturationChange(startFollowers, endFollowers) { const animationDuration = 2000; // Total duration of the animation in milliseconds const startTime = Date.now(); const startSaturation = calculateSaturation(startFollowers * mult); const endSaturation = calculateSaturation(endFollowers * mult); function step() { const now = Date.now(); const progress = (now - startTime) / animationDuration; const currentSaturation = startSaturation + (endSaturation - startSaturation) * progress; applySaturationToCanvas(currentSaturation); if (progress < 1) { requestAnimationFrame(step); } else { applySaturationToCanvas(endSaturation); // Ensure it ends at the exact target saturation } } requestAnimationFrame(step); } document.getElementById('resetButton').addEventListener('click', function() { // Clear the canvas contexts ctx.clearRect(0, 0, canvas.width, canvas.height); hiddenCtx.clearRect(0, 0, hiddenCanvas.width, hiddenCanvas.height); // Optionally reload the image to the hidden canvas if needed hiddenCtx.drawImage(image, 0, 0, canvas.width, canvas.height); // Reset input fields document.getElementById('previousDay').value = ''; document.getElementById('currentDay').value = ''; // Reset any displayed text or values document.getElementById("pixels").innerText = ''; document.getElementById("nf").innerHTML = ''; document.getElementById("nt").innerHTML = ''; document.getElementById('type1').innerHTML = 'Followers'; document.getElementById('type2').innerHTML = 'Followers'; // Reset saturation filter applySaturationToCanvas(0); // Re-shuffle pixel positions if you want a new random pattern on reset shuffleArray(pixelPositions); }); });
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�