savescreenshot

This commit is contained in:
gokayfem
2024-03-23 17:10:56 +03:00
parent dff5f4d5e2
commit a3cbd50307
3 changed files with 41 additions and 0 deletions
+1
View File
@@ -27,6 +27,7 @@
}
</script>
<script id="visualizer" type="module" filepath="" crossorigin src="/extensions/ComfyUI-Depth-Visualization/js/threeVisualizer.js"></script>
<button id="screenshotButton">Take Screenshot</button>
</body>
</html>
+12
View File
@@ -174,4 +174,16 @@ if (referenceTexture && depthTexture) {
frameUpdate();
}
document.getElementById('screenshotButton').addEventListener('click', takeScreenshot);
function takeScreenshot() {
renderer.render(scene, camera);
const dataURL = renderer.domElement.toDataURL('image/png');
const link = document.createElement('a');
link.href = dataURL;
link.download = "screenshot.png";
link.click();
console.log("Screenshot taken");
}
main();
+28
View File
@@ -88,4 +88,32 @@ a, button, input, select {
background-color: #f00;
margin-top: 20px;
padding: 10px;
}
#screenshotButton {
position: absolute;
bottom: 10px; /* Adjust as needed */
left: 10px; /* Position to the left */
z-index: 10; /* Ensure this is above the canvas's z-index */
padding: 5px 5px;
border: none;
border-radius: 5px;
background: linear-gradient(145deg, #007bff, #0056b3);
color: #ffffff;
font-size: 10px;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: background 0.3s ease-in-out, transform 0.2s ease;
}
#screenshotButton:hover {
background: linear-gradient(145deg, #0056b3, #007bff);
transform: translateY(-2px);
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}
#screenshotButton:active {
background: #0056b3;
transform: translateY(1px);
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}