From 01790fbb76885c163c8372cd31c8133447f75676 Mon Sep 17 00:00:00 2001 From: $intu $ingh Date: Tue, 9 Jun 2026 06:34:33 +0530 Subject: [PATCH] =?UTF-8?q?Add=20PI=20calculator=20('PI=20mera=20Bhai')=20?= =?UTF-8?q?=E2=80=94=20interactive=20approximations=20(Leibniz,=20Nilakant?= =?UTF-8?q?ha,=20Monte=20Carlo)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 61 +-- index.html | 1072 ++-------------------------------------------------- script.js | 148 ++++++++ styles.css | 26 ++ 4 files changed, 214 insertions(+), 1093 deletions(-) create mode 100644 script.js create mode 100644 styles.css diff --git a/README.md b/README.md index 599654a..8283045 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,21 @@ -# Sintu | Personal Link Page +# PI mera Bhai -Welcome to my **digital playground** โ€” a place where creativity meets code. This is my **personal link page**, designed to showcase my profiles, projects, and creations all in one sleek, interactive experience. +A small interactive PI calculator/demonstration that shows Math.PI and approximates PI with three methods: -![Worker Profile Preview]([https://sintus.netlify.app/]) +- Leibniz series +- Nilakantha series +- Monte Carlo simulation (with optional canvas visualization) ---- +How to use -## ๐Ÿ”— Links Included +1. Open `index.html` in your browser (or serve the folder statically). +2. Choose the method and set the number of iterations. -- [LinkedIn Services](https://www.linkedin.com/services/page/a2a5a332bb266061a8/) -- [Google Dev Profile](https://g.dev/rs0) -- [UPWORK]([https://t.me/swapsathibot](https://www.upwork.com/freelancers/~019719c5ae734e138f?mp_source=share)) +Notes +- The Monte Carlo method is stochastic โ€” results vary each run. Increasing iterations improves accuracy but costs time. +- The repository and branch created by this commit: branch `pi-mera-bhai`. ---- +License -## ๐ŸŽจ Design & Features - -- **Dark professional neon theme** with mint, pink, and gold accents -- **Profile pic** with pulse glow effect -- **Animated floating particles** for a premium feel -- **Glassmorphic buttons** with hover glow -- **Responsive layout** โ€” looks perfect on mobile, tablet, and desktop -- **Background music** (click play/pause) - ---- - -## โšก Deployment - -This page is **hosted on Netlify**, auto-deployed via GitHub. -- Repository: [GitHub Repo](https://github.com/soulsync-cpu/sin2) -- Live site: `[https://sintus.netlify.app/]` - -Push any changes to this repo and Netlify automatically redeploys the page. - ---- - -## ๐ŸŽต Music Credits - -Background music: *Legacy of Baroque โ€“ Cinematic Background Music* (1 min loop) -[Link to music file](https://dl.dropboxusercontent.com/s/jmp6cox1heaxe5eobosj3/legacy-of-baroque-cinematic-background-music-for-video-stories-1-min-416088.mp3) - ---- - -## ๐Ÿš€ How to Use / Customize - -1. Clone this repo -2. Edit `index.html` to update profile pic, links, colors, or music -3. Push changes to GitHub -4. Netlify auto-updates the live page - ---- - -**Designed & Built by Sintu** -*Crafting digital dreams into reality.* +This demo is provided as-is. Copy, modify, and use freely. diff --git a/index.html b/index.html index 1a59f86..84849a6 100644 --- a/index.html +++ b/index.html @@ -1,1060 +1,42 @@ - + - - - - Sintu Singh | Digital Creator - - - - - - + + + PI mera Bhai ๐Ÿ˜‰๐Ÿ‡ฎ๐Ÿ‡ณโ˜บ๏ธ + - - - - - - +
+

PI mera Bhai ๐Ÿ˜‰๐Ÿ‡ฎ๐Ÿ‡ณโ˜บ๏ธ

+

Interactive PI calculator: display Math.PI, approximate with Leibniz and Nilakantha series, or estimate with a Monte Carlo simulation.

- - - - -
- - - - - - - - - -
- - - - - + - diff --git a/script.js b/script.js new file mode 100644 index 0000000..e13d130 --- /dev/null +++ b/script.js @@ -0,0 +1,148 @@ +// script.js โ€” PI calculator logic (Leibniz, Nilakantha, Monte Carlo visualization) +const btnMath = document.getElementById('btn-mathpi'); +const btnLeib = document.getElementById('btn-leibniz'); +const btnNila = document.getElementById('btn-nilakantha'); +const btnMonte = document.getElementById('btn-monte'); +const iterationsInput = document.getElementById('iterations'); +const resultEl = document.getElementById('result'); +const deltaEl = document.getElementById('delta'); + +const canvas = document.getElementById('mc-canvas'); +const ctx = canvas.getContext('2d'); +const W = canvas.width; +const H = canvas.height; +const cx = W/2, cy = H/2, R = Math.min(W,H)/2 - 2; + +function setResult(value){ + const num = typeof value === 'number' ? value : Number(value); + resultEl.textContent = 'Result: ' + (isNaN(num) ? String(value) : num); + if (!isNaN(num)){ + deltaEl.textContent = 'Difference from Math.PI: ' + Math.abs(num - Math.PI); + } else deltaEl.textContent = ''; +} + +btnMath.addEventListener('click', () => { + setResult(Math.PI); + clearCanvas(); +}); + +btnLeib.addEventListener('click', () => { + const n = clampIterations(); + disableButtons(true); + setTimeout(()=>{ + const pi = leibniz(n); + setResult(pi); + disableButtons(false); + clearCanvas(); + }, 10); +}); + +btnNila.addEventListener('click', () => { + const n = clampIterations(); + disableButtons(true); + setTimeout(()=>{ + const pi = nilakantha(n); + setResult(pi); + disableButtons(false); + clearCanvas(); + }, 10); +}); + +btnMonte.addEventListener('click', () => { + const n = clampIterations(); + disableButtons(true); + runMonteCarlo(n, (pi)=>{ + setResult(pi); + disableButtons(false); + }); +}); + +function clampIterations(){ + let n = parseInt(iterationsInput.value, 10) || 1000; + if (n < 1) n = 1; + if (n > 5_000_000) n = 5_000_000; // safety cap + iterationsInput.value = n; + return n; +} + +function disableButtons(dis){ + [btnMath, btnLeib, btnNila, btnMonte].forEach(b=>b.disabled = dis); +} + +function leibniz(n){ + let sum = 0; + for (let i=0;i