How We Built a 100% Offline Bhagavad Gita Mood Guide, 18-Chapter Reader & HTML5 Canvas Quote Card Studio

2026-12-02来源 dev.toEnglish

If you have ever seen one of those viral 1-page "Bhagavad Gita solutions for your problems" PDFs shared on WhatsApp or Pinterest, you know why people love them: when you are angry, anxious, grieving, or overthinking, you want immediate emotional guidance—not to scroll through 700 verses.

You also know why those PDFs are frustrating on a phone: tiny pinch-to-zoom text, external redirect links that break offline, no Hindi/English toggle, and no way to save a private reflection or share a clean quote card.

Today we shipped KitWharf's Bhagavad Gita Mood & Life-Problem Guide—a 100% client-side, zero-login, offline-ready web app built on Next.js 15 and HTML5 Canvas.

Architecture Highlights

1. Instant 20-Mood Index + Smart Chapter Fallback Search

We structured 56 curated shlokas across all 20 life moods (Anger, Confusion, Envy, Grief, Depression, Fear, Guilt, Loneliness, Uncontrolled Mind, Burnout, and more) with:

  • Public-domain Sanskrit (Devanagari) + IAST Transliteration
  • Fresh, copyright-safe English & Hindi meanings
  • A 1-line Practical Step Today reflection
  • Everyday symptom synonyms (overthinking, exam stress, heartbreak, procrastination) plus a smart chapter.verse fallback so typing any verse number surfaces matching or same-chapter shlokas instead of a dead-end empty state.

2. Two-Pass Vertically Centered HTML5 Canvas Quote Card Exporter

Generating vertical 1080×1920 WhatsApp Status / lock-screen wallpapers on <canvas> has a classic layout trap: if you draw text top-down from a fixed y offset, shorter verses leave a massive awkward void at the bottom.

We solved this with a two-pass measurement renderer:

  1. Pass 1 (Measure): Wrap all enabled layers (Mood Pill, Chapter/Verse header, Sanskrit, English, Hindi, and Reflection Callout Box) against the safe inner width and sum their exact pixel heights.
  2. Pass 2 (Center & Paint): Compute startY = safeTop + (availableHeight - totalHeight) / 2, scale typography up +18% on tall 9:16 canvases, paint a subtle geometric lotus mandala watermark + corner diamond ornaments, and export a crisp, watermark-free PNG via canvas.toDataURL("image/png").

3. 18-Chapter Modern Plain-Language Reader + Private Local Journal

We added an 18-Chapter Reader covering all 18 chapters (700 verses distilled into 2–3 minute English & Hindi overviews + 3 practical daily takeaways per chapter) with a private reading progress tracker and reflection journal stored strictly in localStorage—zero accounts, zero cloud sync, and a 1-click Clear Memory wipe button.

Try it free (works even in Airplane Mode): https://kitwharf.com/gita-verse-finder/

Have you ever built an HTML5 Canvas image generator that had to handle variable-length multilingual text (like Devanagari + Latin)? How did you handle vertical balance?

原文:https://www.a8q9.cn/en/article/how-we-built-a-100-offline-bhagavad-gita-mood-guide-18-chapter-reader-html5-canv-27787f.html

相关文章