Unmined Bitcoin: Unterschied zwischen den Versionen

Aus quickguide.bitcointoolz.com
Zur Navigation springenZur Suche springen
(Die Seite wurde neu angelegt: „<source lang="html"> <!-- // Handlungsanweisung: Füge diese Sanduhr-Komponente in Deinen Artikel ein. // Sie ruft die aktuelle Umlaufmenge von Bitcoin per Coingecko-API ab // und zeichnet eine animierte Sanduhr, in der die obere Kammer den noch verbleibenden Bitcoin-Anteil darstellt. --> <div id="bitcoin-hourglass-container" style="width:220px; margin:20px auto; text-align:center;"> <h3 style="margin-bottom:10px;">Verbleibende Bitcoin bis 21 000…“)
 
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
<source lang="html">
<!--
  // Handlungsanweisung: Füge diese Sanduhr-Komponente in Deinen Artikel ein.
  // Sie ruft die aktuelle Umlaufmenge von Bitcoin per Coingecko-API ab
  // und zeichnet eine animierte Sanduhr, in der die obere Kammer den noch verbleibenden Bitcoin-Anteil darstellt.
-->
<div id="bitcoin-hourglass-container" style="width:220px; margin:20px auto; text-align:center;">
<div id="bitcoin-hourglass-container" style="width:220px; margin:20px auto; text-align:center;">
   <h3 style="margin-bottom:10px;">Verbleibende Bitcoin bis 21 000 000</h3>
   <h3 style="margin-bottom:10px;">Verbleibende Bitcoin bis 21 000 000</h3>
Zeile 21: Zeile 14:
   let animationParticles = [];
   let animationParticles = [];


  // Abschnitt 1: Hilfsfunktion, um Daten von Coingecko zu holen
   async function fetchCirculatingSupply() {
   async function fetchCirculatingSupply() {
     try {
     try {
Zeile 27: Zeile 19:
       if (!response.ok) throw new Error('Netzwerkfehler');
       if (!response.ok) throw new Error('Netzwerkfehler');
       const data = await response.json();
       const data = await response.json();
      // Feld circulating_supply liefert die im Umlauf befindlichen BTC (ungefähr gleich minierten BTC)
       circulating = data.market_data.circulating_supply;
       circulating = data.market_data.circulating_supply;
       remaining = Math.max(totalSupply - circulating, 0);
       remaining = Math.max(totalSupply - circulating, 0);
Zeile 38: Zeile 29:
   }
   }


  // Abschnitt 2: Zeichnet die statische Umrandung der Sanduhr
   function drawHourglassFrame() {
   function drawHourglassFrame() {
     ctx.clearRect(0, 0, canvas.width, canvas.height);
     ctx.clearRect(0, 0, canvas.width, canvas.height);
Zeile 71: Zeile 61:
   }
   }


  // Abschnitt 3: Zeichnet den Sand in der oberen und unteren Kammer anhand des verbleibenden Anteils
   function drawSandLevels() {
   function drawSandLevels() {
     const ratio = remaining / totalSupply; // Anteil der oberen Kammer
     const ratio = remaining / totalSupply;
     const maxHeight = (canvas.height/2 - 30); // maximal nutzbare Höhe in einer Kammer
     const maxHeight = (canvas.height/2 - 30);
     const upperHeight = maxHeight * ratio;
     const upperHeight = maxHeight * ratio;
     const lowerHeight = maxHeight * (1 - ratio);
     const lowerHeight = maxHeight * (1 - ratio);
Zeile 82: Zeile 71:
       ctx.fillStyle = '#f2c94c';
       ctx.fillStyle = '#f2c94c';
       ctx.beginPath();
       ctx.beginPath();
      // Wir zeichnen ein kleines Trapez, das von der Mitte nach oben geht
       const topY = 20;
       const topY = 20;
       const baseY = (canvas.height/2 - 20);
       const baseY = (canvas.height/2 - 20);
Zeile 118: Zeile 106:
   }
   }


  // Abschnitt 4: Animation von Sandkörnern, die durch die Engstelle fallen
   class Particle {
   class Particle {
     constructor() {
     constructor() {
Zeile 163: Zeile 150:
   }
   }


  // Abschnitt 5: Initialisierung
   async function init() {
   async function init() {
     await fetchCirculatingSupply();
     await fetchCirculatingSupply();
     initParticles(50);
     initParticles(50);
     animateSand();
     animateSand();
    // Alle 5 Minuten die Daten neu laden
     setInterval(async () => {
     setInterval(async () => {
       await fetchCirculatingSupply();
       await fetchCirculatingSupply();
Zeile 177: Zeile 162:
})();
})();
</script>
</script>
</source>

Version vom 3. Juni 2025, 14:24 Uhr

Verbleibende Bitcoin bis 21 000 000

 <canvas id="bitcoinHourglass" width="200" height="400" style="border:1px solid #ccc; background:#f9f9f9;"></canvas>

Lade Daten…

<script> (function() {

 const canvas = document.getElementById('bitcoinHourglass');
 const ctx = canvas.getContext('2d');
 const totalSupply = 21000000;
 let circulating = 0;
 let remaining = 0;
 let animationParticles = [];
 async function fetchCirculatingSupply() {
   try {
     const response = await fetch('https://api.coingecko.com/api/v3/coins/bitcoin');
     if (!response.ok) throw new Error('Netzwerkfehler');
     const data = await response.json();
     circulating = data.market_data.circulating_supply;
     remaining = Math.max(totalSupply - circulating, 0);
     document.getElementById('btc-remaining-text').textContent =
       'Noch ' + remaining.toLocaleString('de-DE') + ' BTC';
   } catch (err) {
     document.getElementById('btc-remaining-text').textContent = 'Fehler beim Laden der Daten';
     console.error(err);
   }
 }
 function drawHourglassFrame() {
   ctx.clearRect(0, 0, canvas.width, canvas.height);
   ctx.strokeStyle = '#333';
   ctx.lineWidth = 2;
   // Obere Kammer (Dreieck nach unten)
   ctx.beginPath();
   ctx.moveTo(20, 20);
   ctx.lineTo(canvas.width - 20, 20);
   ctx.lineTo(canvas.width/2 + 20, canvas.height/2 - 20);
   ctx.lineTo(canvas.width/2 - 20, canvas.height/2 - 20);
   ctx.closePath();
   ctx.stroke();
   // Untere Kammer (Dreieck nach oben)
   ctx.beginPath();
   ctx.moveTo(20, canvas.height - 20);
   ctx.lineTo(canvas.width - 20, canvas.height - 20);
   ctx.lineTo(canvas.width/2 + 20, canvas.height/2 + 20);
   ctx.lineTo(canvas.width/2 - 20, canvas.height/2 + 20);
   ctx.closePath();
   ctx.stroke();
   // Verbindungslinien
   ctx.beginPath();
   ctx.moveTo(canvas.width/2 - 20, canvas.height/2 - 20);
   ctx.lineTo(canvas.width/2 - 20, canvas.height/2 + 20);
   ctx.moveTo(canvas.width/2 + 20, canvas.height/2 - 20);
   ctx.lineTo(canvas.width/2 + 20, canvas.height/2 + 20);
   ctx.stroke();
 }
 function drawSandLevels() {
   const ratio = remaining / totalSupply;
   const maxHeight = (canvas.height/2 - 30);
   const upperHeight = maxHeight * ratio;
   const lowerHeight = maxHeight * (1 - ratio);
   // Obere Kammer füllen
   if (upperHeight > 0) {
     ctx.fillStyle = '#f2c94c';
     ctx.beginPath();
     const topY = 20;
     const baseY = (canvas.height/2 - 20);
     const currentY = baseY - upperHeight;
     const interpolation = (currentY - topY) / (baseY - topY);
     const leftX = 20 + (canvas.width/2 - 20 - 20) * (1 - interpolation);
     const rightX = canvas.width - 20 - (canvas.width/2 - 20 - 20) * (1 - interpolation);
     ctx.moveTo(leftX, currentY);
     ctx.lineTo(rightX, currentY);
     ctx.lineTo(canvas.width/2 + 20, baseY);
     ctx.lineTo(canvas.width/2 - 20, baseY);
     ctx.closePath();
     ctx.fill();
   }
   // Untere Kammer füllen
   if (lowerHeight > 0) {
     ctx.fillStyle = '#f2c94c';
     ctx.beginPath();
     const bottomY = canvas.height - 20;
     const baseY2 = (canvas.height/2 + 20);
     const currentY2 = baseY2 + lowerHeight;
     const interpolation2 = (currentY2 - baseY2) / (bottomY - baseY2);
     const leftX2 = 20 + (canvas.width/2 - 20 - 20) * interpolation2;
     const rightX2 = canvas.width - 20 - (canvas.width/2 - 20 - 20) * interpolation2;
     ctx.moveTo(canvas.width/2 - 20, baseY2);
     ctx.lineTo(canvas.width/2 + 20, baseY2);
     ctx.lineTo(rightX2, currentY2);
     ctx.lineTo(leftX2, currentY2);
     ctx.closePath();
     ctx.fill();
   }
 }
 class Particle {
   constructor() {
     this.reset();
   }
   reset() {
     this.x = canvas.width/2 + (Math.random() * 20 - 10);
     this.y = canvas.height/2 - 20;
     this.size = Math.random() * 3 + 2;
     this.vy = Math.random() * 2 + 1;
     this.alpha = 1;
   }
   update() {
     this.y += this.vy;
     if (this.y > canvas.height/2 + 20) {
       this.alpha -= 0.05;
     }
     if (this.alpha <= 0) {
       this.reset();
     }
   }
   draw() {
     ctx.fillStyle = 'rgba(242,201,76,' + this.alpha + ')';
     ctx.beginPath();
     ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
     ctx.fill();
   }
 }
 function initParticles(count) {
   for (let i = 0; i < count; i++) {
     animationParticles.push(new Particle());
   }
 }
 function animateSand() {
   drawHourglassFrame();
   drawSandLevels();
   animationParticles.forEach(p => {
     p.update();
     p.draw();
   });
   requestAnimationFrame(animateSand);
 }
 async function init() {
   await fetchCirculatingSupply();
   initParticles(50);
   animateSand();
   setInterval(async () => {
     await fetchCirculatingSupply();
   }, 5 * 60 * 1000);
 }
 init();

})(); </script>




Bitte empfiehl diesen Artikel zum Thema »Unmined Bitcoin« Deinen Freunden & Bekannten und hilf uns damit, dieses nützliche Wissen zu verbreiten!


Teilen auf:

Facebook

Twitter / X

LinkedIn

WhatsApp

oder

Jetzt per E-Mail teilen


Vielen Dank, dass Du dieses Wiki-Projekt weiterempfiehlst und damit entscheidend dazu beiträgst, das BitcoinToolz-Wiki noch bekannter zu machen!


Hilf mit, Wissen frei zu halten.
   Wenn Dir dieser Artikel geholfen hat, gib 21 000 sats oder 5 € zurück – damit finanzierst Du Quellenarbeit, Aktualisierungen und den Server.
Werbefrei & unabhängig – Danke!



Von ❤️ by TöpperwienTentacleTechnology-Systems, HB & AI

Zurück zur → Hauptseite