Add timestamp to saved png file name

This commit is contained in:
sup39 2023-04-08 10:24:52 +09:00
parent 2d9b98fa6e
commit d86a6370a0
No known key found for this signature in database
GPG key ID: 19D72AAF429D55D9

View file

@ -221,7 +221,17 @@ function truncateString(str, maxLength = 40) {
function mouseClicked() { function mouseClicked() {
// Save the canvas content as an image file // Save the canvas content as an image file
if (mouseX < 50 && mouseY < 50) { if (mouseX < 50 && mouseY < 50) {
saveCanvas('nicechord-pianometer', 'png'); const now = new Date();
const strDate =
now.getFullYear() +
String(now.getMonth()+1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0');
const strTime =
String(now.getHours()).padStart(2, '0') +
String(now.getMinutes()).padStart(2, '0') +
String(now.getSeconds()).padStart(2, '0');
const fileName = `nicechord-pianometer-${strDate}_${strTime}`;
saveCanvas(fileName, 'png');
} }
if (mouseY > 76) { if (mouseY > 76) {
if (mouseX <= 84) { if (mouseX <= 84) {