From a9f07d59d80480935ac1b9770dc2d97bc58b41e5 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 25 Nov 2023 13:29:13 -0300 Subject: [PATCH] You can now record a webp (still need to add options) --- js/minecraft-tip-impl.js | 32 +++++++++++++++++--------------- js/minecraft-tip.js | 1 - minecrafttooltips.html | 5 +++-- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/js/minecraft-tip-impl.js b/js/minecraft-tip-impl.js index 22957de..f100fed 100644 --- a/js/minecraft-tip-impl.js +++ b/js/minecraft-tip-impl.js @@ -32,20 +32,22 @@ setInterval(() => { } }, 50); -// followerTooltip.classList.add("hidden"); -// const minecraftItems = document.getElementsByClassName("minecraft-item"); +function startRecording() { + const chunks = []; + const stream = tooltip.captureStream(); + const rec = new MediaRecorder(stream); + + rec.ondataavailable = e => chunks.push(e.data); -// for (let i = 0; i < minecraftItems.length; i++) { -// minecraftItems.item(i).addEventListener('mouseenter', (e) => { -// if (!e.target.dataset.mctitle) return; -// followerTooltip.classList.remove("hidden"); -// getTextFromJSON(e.target.dataset.mctitle).get().then(str => { -// setTooltipText(followerTooltip, str); -// }); -// }); + rec.onstop = e => exportVid(new Blob(chunks, {type: 'video/webm'})); + + rec.start(); + setTimeout(()=>rec.stop(), Math.PI * 2000); +} -// minecraftItems.item(i).addEventListener('mouseleave', (e) => { -// followerTooltip.classList.add("hidden"); -// }); -// } -// document.body.appendChild(followerTooltip); \ No newline at end of file +function exportVid(blob) { + const a = document.createElement('a'); + a.download = 'myvid.webm'; + a.href = URL.createObjectURL(blob); + a.click(); +} \ No newline at end of file diff --git a/js/minecraft-tip.js b/js/minecraft-tip.js index 8fb1a36..0f56136 100644 --- a/js/minecraft-tip.js +++ b/js/minecraft-tip.js @@ -349,7 +349,6 @@ class TextFormatting { if (value) { let originalFillStyle = ctx.fillStyle; ctx.fillStyle = "#" + ('000000' + this.getFormattingOption(TextFormatting.FormattingOptions.COLOR)().toString(16).toUpperCase()).slice(-6); - console.log((textRenderingContext.x + textRenderingContext.left) - 2, (textRenderingContext.y + (textRenderingContext.line * textRenderer.getLineHeight()) + (textRenderingContext.line > 0 && settings.firstLineIsHigher ? 4 : 0)) - 7, textRenderer.getWidth(textRenderingContext.char) + 2, 2); ctx.fillRect((textRenderingContext.x + textRenderingContext.left) - 2, (textRenderingContext.y + (textRenderingContext.line * textRenderer.getLineHeight()) + (textRenderingContext.line > 0 && settings.firstLineIsHigher ? 4 : 0)) - 7, textRenderer.getWidth(textRenderingContext.char) + 2, 2); ctx.fillStyle = originalFillStyle; } diff --git a/minecrafttooltips.html b/minecrafttooltips.html index 869bff1..8afa117 100644 --- a/minecrafttooltips.html +++ b/minecrafttooltips.html @@ -16,7 +16,6 @@ -
@@ -33,7 +32,7 @@


-
+ + \ No newline at end of file