Make flowcharts of the chapter " heart rate " full chapter flowcharts with long lines , take reference from the book of physiology "sembulingam" . Make easy and simple english language

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Finding Sources
Reading File
Reading File
Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/heart-rate-flowcharts && ls /home/daytona/workspace/heart-rate-flowcharts/

Writing File

~/heart-rate-flowcharts/heart_rate_flowcharts.js

const pptxgen = require("pptxgenjs");
const pres = new pptxgen();
pres.layout = "LAYOUT_WIDE"; // 13.3 x 7.5 inches - more space for flowcharts

// ─── COLOR PALETTE ───────────────────────────────────────────────────────────
const C = {
  darkBg:   "0D1B2A",   // deep navy - title slides
  midBg:    "1B2F4B",   // medium navy
  accent1:  "2196F3",   // vivid blue - main boxes
  accent2:  "00BCD4",   // cyan - sub-boxes
  accent3:  "FF9800",   // amber - outcomes / results
  accent4:  "4CAF50",   // green - positive effects
  accent5:  "F44336",   // red - negative effects
  accentPu: "9C27B0",   // purple - special nodes
  lightBg:  "EBF5FB",   // very light blue background
  white:    "FFFFFF",
  textDark: "1A237E",   // deep blue text
  textMid:  "263238",
  gray:     "B0BEC5",
  arrowClr: "37474F",
};

// ─── HELPERS ─────────────────────────────────────────────────────────────────

function addSlideTitle(slide, title, subtitle) {
  slide.background = { color: C.darkBg };
  slide.addShape("rect", { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.darkBg } });
  // decorative bar
  slide.addShape("rect", { x: 0, y: 6.8, w: 13.3, h: 0.7, fill: { color: C.accent1 } });
  slide.addText(title, {
    x: 0.5, y: 2.2, w: 12.3, h: 1.2,
    fontSize: 44, bold: true, color: C.white, align: "center", fontFace: "Calibri"
  });
  if (subtitle) {
    slide.addText(subtitle, {
      x: 0.5, y: 3.7, w: 12.3, h: 0.7,
      fontSize: 22, color: C.accent2, align: "center", fontFace: "Calibri", italic: true
    });
  }
  slide.addText("Ref: Sembulingam — Essentials of Medical Physiology", {
    x: 0.5, y: 6.85, w: 12.3, h: 0.5,
    fontSize: 13, color: C.white, align: "center", fontFace: "Calibri"
  });
}

// Draw a box with centered text, returns nothing (adds to slide directly)
function box(slide, label, x, y, w, h, fillColor, textColor, fontSize, bold) {
  slide.addShape("roundRect", {
    x, y, w, h,
    fill: { color: fillColor || C.accent1 },
    line: { color: C.white, width: 1.5 },
    rectRadius: 0.12
  });
  slide.addText(label, {
    x, y, w, h,
    fontSize: fontSize || 12, bold: bold !== false, color: textColor || C.white,
    align: "center", valign: "middle", fontFace: "Calibri", wrap: true, margin: 4
  });
}

// Draw a diamond shape
function diamond(slide, label, x, y, w, h, fillColor, textColor, fontSize) {
  slide.addShape("diamond", {
    x, y, w, h,
    fill: { color: fillColor || C.accent3 },
    line: { color: C.white, width: 1.5 }
  });
  slide.addText(label, {
    x, y, w, h,
    fontSize: fontSize || 11, bold: true, color: textColor || C.textDark,
    align: "center", valign: "middle", fontFace: "Calibri", wrap: true, margin: 5
  });
}

// Vertical arrow
function arrowDown(slide, x, y, len, label) {
  slide.addShape("line", {
    x, y, w: 0, h: len,
    line: { color: C.arrowClr, width: 2.0, endArrowType: "triangle" }
  });
  if (label) {
    slide.addText(label, {
      x: x + 0.05, y: y + len / 2 - 0.15, w: 1.2, h: 0.3,
      fontSize: 9, color: C.arrowClr, fontFace: "Calibri"
    });
  }
}

// Horizontal arrow right
function arrowRight(slide, x, y, len, label) {
  slide.addShape("line", {
    x, y, w: len, h: 0,
    line: { color: C.arrowClr, width: 2.0, endArrowType: "triangle" }
  });
  if (label) {
    slide.addText(label, {
      x: x + len / 2 - 0.3, y: y - 0.25, w: 1.0, h: 0.3,
      fontSize: 9, color: C.arrowClr, fontFace: "Calibri", align: "center"
    });
  }
}

// Horizontal arrow left
function arrowLeft(slide, x, y, len, label) {
  slide.addShape("line", {
    x, y, w: -len, h: 0,
    line: { color: C.arrowClr, width: 2.0, endArrowType: "triangle" }
  });
}

function arrowUp(slide, x, y, len) {
  slide.addShape("line", {
    x, y, w: 0, h: -len,
    line: { color: C.arrowClr, width: 2.0, endArrowType: "triangle" }
  });
}

function sectionHeader(slide, text, color) {
  slide.addShape("rect", { x: 0, y: 0, w: 13.3, h: 0.6, fill: { color: color || C.midBg } });
  slide.addText(text, {
    x: 0.2, y: 0, w: 12.9, h: 0.6,
    fontSize: 18, bold: true, color: C.white, align: "center", valign: "middle", fontFace: "Calibri"
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 1 — TITLE SLIDE
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  addSlideTitle(sl, "HEART RATE", "Full Chapter Flowcharts — Essentials of Medical Physiology (Sembulingam)");
  // decorative heart symbol area
  sl.addText("❤", { x: 5.9, y: 1.0, w: 1.5, h: 1.0, fontSize: 52, color: C.accent5, align: "center" });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 2 — OVERVIEW / DEFINITION OF HEART RATE
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "HEART RATE — DEFINITION & NORMAL VALUES", C.midBg);

  // Central topic box
  box(sl, "HEART RATE", 5.15, 0.75, 3.0, 0.7, C.accent1, C.white, 18, true);
  arrowDown(sl, 6.65, 1.45, 0.45);

  // Definition
  box(sl, "Number of times the heart beats per minute (beats/min)", 4.15, 1.9, 5.0, 0.75, C.midBg, C.white, 13);
  arrowDown(sl, 6.65, 2.65, 0.4);

  // Normal value box
  box(sl, "Normal Heart Rate\n60 – 100 beats/min", 5.0, 3.05, 3.3, 0.8, C.accent3, C.textDark, 13);
  arrowDown(sl, 6.65, 3.85, 0.35);

  // Three branches from normal HR
  // Left arrow
  sl.addShape("line", { x: 6.65, y: 4.2, w: -3.4, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  // Right arrow
  sl.addShape("line", { x: 6.65, y: 4.2, w: 3.4, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  // Center down arrow
  arrowDown(sl, 6.65, 4.2, 0.4);

  // Bradycardia
  sl.addShape("line", { x: 3.25, y: 4.2, w: 0, h: 0.4, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "BRADYCARDIA\n< 60 beats/min\n(Slow heart rate)", 1.9, 4.6, 2.7, 1.0, C.accentPu, C.white, 12);

  // Normal
  sl.addShape("line", { x: 6.65, y: 4.2, w: 0, h: 0.4, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "NORMAL\n60 – 100 beats/min\n(Healthy adult at rest)", 5.1, 4.6, 3.1, 1.0, C.accent4, C.white, 12);

  // Tachycardia
  sl.addShape("line", { x: 10.05, y: 4.2, w: 0, h: 0.4, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "TACHYCARDIA\n> 100 beats/min\n(Fast heart rate)", 8.65, 4.6, 2.7, 1.0, C.accent5, C.white, 12);

  arrowDown(sl, 6.65, 5.6, 0.35);

  // Bottom note: Newborn vs adult
  box(sl, "Newborn: ~120 beats/min   |   Child (5 yrs): ~90 beats/min   |   Adult: 72 beats/min (average)", 1.5, 5.95, 10.3, 0.65, C.accent2, C.textDark, 12);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 3 — SA NODE AS PACEMAKER (Origin of Heart Rate)
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "ORIGIN OF HEART RATE — SA NODE (PACEMAKER)", C.midBg);

  // SA Node top box
  box(sl, "SA NODE\n(Sinoatrial Node)", 5.15, 0.75, 3.0, 0.75, C.accent1, C.white, 14);
  arrowDown(sl, 6.65, 1.5, 0.35);

  box(sl, "Located at junction of right atrium and superior vena cava", 4.4, 1.85, 4.5, 0.65, C.midBg, C.white, 12);
  arrowDown(sl, 6.65, 2.5, 0.35);

  box(sl, "PACEMAKER POTENTIAL (Automatic / Self-Excitation)", 4.3, 2.85, 4.7, 0.65, C.accent3, C.textDark, 13);
  arrowDown(sl, 6.65, 3.5, 0.35);

  // Three properties
  sl.addShape("line", { x: 6.65, y: 3.85, w: -3.5, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 6.65, y: 3.85, w: 3.5, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  arrowDown(sl, 6.65, 3.85, 0.3);

  sl.addShape("line", { x: 3.15, y: 3.85, w: 0, h: 0.3, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "AUTOMATICITY\nSpontaneous firing\nwithout nerve stimulation", 1.5, 4.15, 3.3, 0.95, C.accent2, C.textDark, 11);

  sl.addShape("line", { x: 6.65, y: 3.85, w: 0, h: 0.3, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "RHYTHMICITY\nRegular, repetitive\nfiring pattern", 4.9, 4.15, 3.5, 0.95, C.accent4, C.textDark, 11);

  sl.addShape("line", { x: 10.15, y: 3.85, w: 0, h: 0.3, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "CONDUCTIVITY\nSpreads impulse to\nentire heart", 8.5, 4.15, 3.3, 0.95, C.accentPu, C.white, 11);

  arrowDown(sl, 6.65, 5.1, 0.35);

  // Impulse conduction path
  box(sl, "Impulse from SA Node   →   AV Node   →   Bundle of His   →   Purkinje Fibers   →   Ventricles Contract", 1.0, 5.45, 11.3, 0.7, C.accent1, C.white, 12);
  arrowDown(sl, 6.65, 6.15, 0.35);

  box(sl, "One complete HEART BEAT = Atrial contraction + Ventricular contraction", 3.5, 6.5, 6.3, 0.65, C.accent3, C.textDark, 12);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 4 — FACTORS AFFECTING HEART RATE (Overview)
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "FACTORS AFFECTING HEART RATE — OVERVIEW", C.midBg);

  // Central box
  box(sl, "HEART RATE\nREGULATION", 5.3, 0.75, 2.7, 0.9, C.accent1, C.white, 14);

  // 6 branches radiating out
  const factors = [
    { label: "1. NERVOUS\nSystem", x: 0.3, y: 1.05, color: C.midBg },
    { label: "2. CHEMICAL\nFactors", x: 0.3, y: 2.4, color: C.accent2 },
    { label: "3. HORMONES", x: 0.3, y: 3.75, color: C.accentPu },
    { label: "4. TEMPERATURE", x: 9.8, y: 1.05, color: C.accent3 },
    { label: "5. EXERCISE &\nPhysical", x: 9.8, y: 2.4, color: C.accent4 },
    { label: "6. AGE, SEX &\nOther Factors", x: 9.8, y: 3.75, color: C.accent5 },
  ];

  factors.forEach((f, i) => {
    box(sl, f.label, f.x, f.y, 2.7, 0.75, f.color, C.white, 12);
    if (i < 3) {
      sl.addShape("line", { x: 3.0, y: f.y + 0.37, w: 2.3, h: 0, line: { color: C.arrowClr, width: 1.6, endArrowType: "triangle" } });
    } else {
      sl.addShape("line", { x: 9.8, y: f.y + 0.37, w: -2.3, h: 0, line: { color: C.arrowClr, width: 1.6, endArrowType: "triangle" } });
    }
  });

  arrowDown(sl, 6.65, 1.65, 0.4);

  // Bottom section - key message
  box(sl, "All these factors either INCREASE or DECREASE heart rate by acting on the SA node (pacemaker)", 1.5, 4.8, 10.3, 0.7, C.midBg, C.white, 13);
  arrowDown(sl, 6.65, 5.5, 0.35);

  // Two outcomes
  sl.addShape("line", { x: 6.65, y: 5.85, w: -2.8, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 6.65, y: 5.85, w: 2.8, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 3.85, y: 5.85, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  sl.addShape("line", { x: 9.45, y: 5.85, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "↑ TACHYCARDIA\n(Heart rate increases)", 2.35, 6.2, 3.0, 0.8, C.accent5, C.white, 12);
  box(sl, "↓ BRADYCARDIA\n(Heart rate decreases)", 8.0, 6.2, 3.0, 0.8, C.accentPu, C.white, 12);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 5 — NERVOUS SYSTEM REGULATION (SYMPATHETIC)
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "NERVOUS REGULATION — SYMPATHETIC SYSTEM (Increases Heart Rate)", C.accent5);

  box(sl, "SYMPATHETIC NERVOUS SYSTEM\n(Cardioaccelerator Nerves)", 4.3, 0.75, 4.7, 0.8, C.accent5, C.white, 14);
  arrowDown(sl, 6.65, 1.55, 0.4);

  box(sl, "Originates in Cardioaccelerator Center (CAC)\nin Medulla Oblongata", 4.3, 1.95, 4.7, 0.75, C.midBg, C.white, 12);
  arrowDown(sl, 6.65, 2.7, 0.35);

  box(sl, "Nerve fibers go through CERVICAL GANGLIA\n(Superior, Middle, and Inferior Cervical Ganglia)", 3.9, 3.05, 5.5, 0.75, C.accent2, C.textDark, 12);
  arrowDown(sl, 6.65, 3.8, 0.35);

  box(sl, "Releases NOREPINEPHRINE (Noradrenaline)\nat SA Node", 4.3, 4.15, 4.7, 0.75, C.accent3, C.textDark, 13);
  arrowDown(sl, 6.65, 4.9, 0.35);

  box(sl, "Binds to β1 (Beta-1) Adrenergic Receptors\non SA node cells", 4.3, 5.25, 4.7, 0.7, C.midBg, C.white, 12);
  arrowDown(sl, 6.65, 5.95, 0.35);

  // Two mechanisms
  sl.addShape("line", { x: 6.65, y: 6.3, w: -2.8, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 6.65, y: 6.3, w: 2.8, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 3.85, y: 6.3, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  sl.addShape("line", { x: 9.45, y: 6.3, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "↑ Phase 4 depolarization rate\n(↑ If — funny current)", 2.0, 6.65, 3.7, 0.7, C.accent4, C.textDark, 11);
  box(sl, "↓ Threshold potential\n(↑ ICa — Ca2+ current)", 7.6, 6.65, 3.7, 0.7, C.accent4, C.textDark, 11);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 6 — SYMPATHETIC FINAL EFFECT
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "SYMPATHETIC SYSTEM — FINAL OUTCOME & POSITIVE CHRONOTROPIC EFFECT", C.accent5);

  box(sl, "β1 Receptor Activation by Norepinephrine", 4.3, 0.75, 4.7, 0.7, C.accent5, C.white, 13);
  arrowDown(sl, 6.65, 1.45, 0.35);

  box(sl, "Gs Protein Activated   →   Adenylyl Cyclase Activated   →   ↑ cAMP", 3.0, 1.8, 7.3, 0.7, C.midBg, C.white, 12);
  arrowDown(sl, 6.65, 2.5, 0.35);

  // Two effects
  sl.addShape("line", { x: 6.65, y: 2.85, w: -3.2, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 6.65, y: 2.85, w: 3.2, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 3.45, y: 2.85, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  sl.addShape("line", { x: 9.85, y: 2.85, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "↑ If (Inward Na+ current)\nFaster Phase 4 depolarization\n→ SA node reaches threshold FASTER", 1.5, 3.2, 3.9, 1.0, C.accent2, C.textDark, 11);
  box(sl, "↑ ICa (Ca2+ current)\nThreshold potential DECREASES\n→ Less depolarization needed", 7.9, 3.2, 3.9, 1.0, C.accent2, C.textDark, 11);

  // Converge
  sl.addShape("line", { x: 3.45, y: 4.2, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 9.85, y: 4.2, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 3.45, y: 4.55, w: 6.4, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  arrowDown(sl, 6.65, 4.55, 0.35);

  box(sl, "SA Node fires ACTION POTENTIALS more FREQUENTLY", 4.0, 4.9, 5.3, 0.7, C.accent3, C.textDark, 13);
  arrowDown(sl, 6.65, 5.6, 0.35);

  box(sl, "POSITIVE CHRONOTROPIC EFFECT\n↑ HEART RATE (TACHYCARDIA)", 4.0, 5.95, 5.3, 0.85, C.accent5, C.white, 16, true);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 7 — PARASYMPATHETIC SYSTEM (DECREASES HEART RATE)
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "NERVOUS REGULATION — PARASYMPATHETIC SYSTEM (Decreases Heart Rate)", C.accentPu);

  box(sl, "PARASYMPATHETIC NERVOUS SYSTEM\n(Cardioinhibitory Nerves — Vagus Nerve X)", 4.0, 0.75, 5.3, 0.8, C.accentPu, C.white, 14);
  arrowDown(sl, 6.65, 1.55, 0.35);

  box(sl, "Originates in Cardioinhibitory Center (CIC)\nin Medulla Oblongata", 4.3, 1.9, 4.7, 0.7, C.midBg, C.white, 12);
  arrowDown(sl, 6.65, 2.6, 0.35);

  box(sl, "Vagus Nerve (10th Cranial Nerve)\nReaches SA Node and AV Node", 4.3, 2.95, 4.7, 0.7, C.accent2, C.textDark, 12);
  arrowDown(sl, 6.65, 3.65, 0.35);

  box(sl, "Releases ACETYLCHOLINE (ACh)\nat SA Node", 4.3, 4.0, 4.7, 0.7, C.accent3, C.textDark, 13);
  arrowDown(sl, 6.65, 4.7, 0.35);

  box(sl, "Binds to M2 (Muscarinic) Receptors\non SA node cells", 4.3, 5.05, 4.7, 0.7, C.midBg, C.white, 12);
  arrowDown(sl, 6.65, 5.75, 0.35);

  // Three branches
  sl.addShape("line", { x: 6.65, y: 6.1, w: -4.5, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 6.65, y: 6.1, w: 4.5, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  arrowDown(sl, 6.65, 6.1, 0.35);
  sl.addShape("line", { x: 2.15, y: 6.1, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  sl.addShape("line", { x: 11.15, y: 6.1, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "↓ If\n(Slows Phase 4\ndepolarization)", 0.4, 6.45, 3.5, 0.8, C.accent2, C.textDark, 11);
  box(sl, "↑ IK-ACh\n(Hyperpolarizes\nmax diastolic potential)", 4.9, 6.45, 3.5, 0.8, C.accent2, C.textDark, 11);
  box(sl, "↓ ICa\n(Raises threshold\npotential)", 9.45, 6.45, 3.4, 0.8, C.accent2, C.textDark, 11);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 8 — PARASYMPATHETIC FINAL EFFECT
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "PARASYMPATHETIC SYSTEM — FINAL OUTCOME & NEGATIVE CHRONOTROPIC EFFECT", C.accentPu);

  box(sl, "THREE Combined Effects of ACh on SA Node", 4.0, 0.75, 5.3, 0.65, C.accentPu, C.white, 13);
  arrowDown(sl, 6.65, 1.4, 0.35);

  sl.addShape("line", { x: 6.65, y: 1.75, w: -4.0, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 6.65, y: 1.75, w: 4.0, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  arrowDown(sl, 6.65, 1.75, 0.35);
  sl.addShape("line", { x: 2.65, y: 1.75, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  sl.addShape("line", { x: 10.65, y: 1.75, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });

  box(sl, "Effect 1:\nSLOWS Phase 4\ndepolarization rate", 1.0, 2.1, 3.3, 0.9, C.accent2, C.textDark, 11);
  box(sl, "Effect 2:\nHyperpolarizes\nmax diastolic potential\n(SA node further from threshold)", 4.9, 2.1, 3.5, 1.2, C.accent2, C.textDark, 10);
  box(sl, "Effect 3:\nIncreases threshold\npotential\n(more depolarization needed)", 9.2, 2.1, 3.6, 1.2, C.accent2, C.textDark, 10);

  // Converge
  sl.addShape("line", { x: 2.65, y: 3.0, w: 0, h: 0.4, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 6.65, y: 3.3, w: 0, h: 0.1, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 10.95, y: 3.3, w: 0, h: 0.1, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 2.65, y: 3.4, w: 8.3, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  arrowDown(sl, 6.65, 3.4, 0.4);

  box(sl, "SA Node fires ACTION POTENTIALS LESS frequently\n(SA node depolarized to threshold LESS often)", 3.8, 3.8, 5.7, 0.75, C.accent3, C.textDark, 12);
  arrowDown(sl, 6.65, 4.55, 0.35);

  box(sl, "NEGATIVE CHRONOTROPIC EFFECT\n↓ HEART RATE (BRADYCARDIA)", 4.0, 4.9, 5.3, 0.85, C.accentPu, C.white, 16, true);
  arrowDown(sl, 6.65, 5.75, 0.35);

  box(sl, "Vagal Tone — Parasympathetic dominates at REST → Normal resting HR ~72 beats/min", 2.5, 6.1, 8.3, 0.7, C.accent1, C.white, 12);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 9 — CARDIOVASCULAR CENTER IN MEDULLA (Control Center)
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "CARDIOVASCULAR CENTER IN MEDULLA — CONTROL OF HEART RATE", C.midBg);

  box(sl, "CARDIOVASCULAR CENTER\n(Vasomotor Center — Medulla Oblongata)", 4.0, 0.75, 5.3, 0.8, C.accent1, C.white, 14);
  arrowDown(sl, 6.65, 1.55, 0.35);

  // Two sub-centers
  sl.addShape("line", { x: 6.65, y: 1.9, w: -3.5, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 6.65, y: 1.9, w: 3.5, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 3.15, y: 1.9, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  sl.addShape("line", { x: 10.15, y: 1.9, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "CARDIOACCELERATOR\nCENTER (CAC)\n— Sympathetic", 1.5, 2.25, 3.3, 0.95, C.accent5, C.white, 12);
  box(sl, "CARDIOINHIBITORY\nCENTER (CIC)\n— Parasympathetic", 8.5, 2.25, 3.3, 0.95, C.accentPu, C.white, 12);

  // Inputs to cardiovascular center
  sl.addText("INPUTS TO CARDIOVASCULAR CENTER:", {
    x: 0.5, y: 3.45, w: 12.3, h: 0.4,
    fontSize: 13, bold: true, color: C.textDark, align: "center", fontFace: "Calibri"
  });

  const inputs = [
    { label: "BARORECEPTORS\n(Aortic arch & Carotid sinus)\n↑ BP → ↓ HR (vagal reflex)", x: 0.3, y: 3.9, color: C.accent2 },
    { label: "CHEMORECEPTORS\n(↓ O2, ↑ CO2, ↑ H+)\n→ ↑ HR initially", x: 3.5, y: 3.9, color: C.accent3 },
    { label: "HIGHER BRAIN\nCENTERS\n(Cortex, Hypothalamus)", x: 6.7, y: 3.9, color: C.accentPu },
    { label: "BAINBRIDGE\nREFLEX\n(↑ Venous return → ↑ HR)", x: 9.9, y: 3.9, color: C.accent4 },
  ];
  inputs.forEach(inp => {
    box(sl, inp.label, inp.x, inp.y, 3.1, 1.0, inp.color, inp.color === C.accent3 || inp.color === C.accent2 ? C.textDark : C.white, 11);
    sl.addShape("line", { x: inp.x + 1.55, y: inp.y, w: 0, h: -0.5, line: { color: C.arrowClr, width: 1.6, endArrowType: "triangle" } });
  });

  arrowDown(sl, 6.65, 4.9, 0.35);
  box(sl, "Cardiovascular Center integrates ALL inputs → adjusts Sympathetic / Parasympathetic output → Controls SA Node → Sets Heart Rate", 0.8, 5.25, 11.7, 0.8, C.accent1, C.white, 12);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 10 — HORMONAL REGULATION
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "HORMONAL REGULATION OF HEART RATE", C.accentPu);

  box(sl, "HORMONES AFFECTING HEART RATE", 4.15, 0.75, 5.0, 0.7, C.accentPu, C.white, 15);
  arrowDown(sl, 6.65, 1.45, 0.35);

  // Split into two columns: increase vs decrease
  sl.addShape("rect", { x: 0.3, y: 1.8, w: 5.8, h: 0.45, fill: { color: C.accent5 }, line: { color: C.accent5 } });
  sl.addText("HORMONES THAT ↑ HEART RATE", { x: 0.3, y: 1.8, w: 5.8, h: 0.45, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", fontFace: "Calibri" });
  sl.addShape("rect", { x: 7.2, y: 1.8, w: 5.8, h: 0.45, fill: { color: C.accentPu }, line: { color: C.accentPu } });
  sl.addText("HORMONES THAT ↓ HEART RATE", { x: 7.2, y: 1.8, w: 5.8, h: 0.45, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", fontFace: "Calibri" });

  const increaseHormones = [
    ["Epinephrine (Adrenaline)", "Adrenal medulla → β1 receptors → ↑ HR (similar to sympathetic)"],
    ["Norepinephrine", "Adrenal medulla → β1 receptors → ↑ HR"],
    ["Thyroid Hormones (T3/T4)", "↑ sensitivity of heart to catecholamines → ↑ HR"],
    ["Glucagon", "Acts on SA node → ↑ HR (less potent)"],
  ];

  const decreaseHormones = [
    ["Acetylcholine (ACh)", "Vagal stimulation → M2 receptors → ↓ HR"],
    ["Adenosine", "Acts on A1 receptors → ↓ HR (used clinically for SVT)"],
    ["High Progesterone", "Mild bradycardia in some contexts"],
  ];

  let y = 2.35;
  increaseHormones.forEach(h => {
    box(sl, h[0], 0.3, y, 2.4, 0.6, C.accent5, C.white, 11);
    sl.addShape("line", { x: 2.7, y: y + 0.3, w: 0.4, h: 0, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
    box(sl, h[1], 3.1, y, 3.0, 0.6, "FFF3E0", C.textDark, 10, false);
    y += 0.7;
  });

  y = 2.35;
  decreaseHormones.forEach(h => {
    box(sl, h[0], 7.2, y, 2.4, 0.6, C.accentPu, C.white, 11);
    sl.addShape("line", { x: 9.6, y: y + 0.3, w: 0.4, h: 0, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
    box(sl, h[1], 10.0, y, 3.0, 0.6, "EDE7F6", C.textDark, 10, false);
    y += 0.7;
  });

  box(sl, "KEY POINT: Epinephrine and Norepinephrine from adrenal medulla mimic sympathetic stimulation — both act on β1 receptors of SA node to increase heart rate", 0.5, 5.8, 12.3, 0.85, C.accent1, C.white, 12);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 11 — TEMPERATURE & CHEMICAL FACTORS
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "TEMPERATURE, CHEMICAL & IONIC FACTORS AFFECTING HEART RATE", C.accent3);

  // Temperature section
  box(sl, "BODY TEMPERATURE", 0.4, 0.75, 3.5, 0.6, C.accent3, C.textDark, 14);
  arrowDown(sl, 2.15, 1.35, 0.35);

  sl.addShape("line", { x: 2.15, y: 1.7, w: -1.3, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 2.15, y: 1.7, w: 1.3, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 0.85, y: 1.7, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  sl.addShape("line", { x: 3.45, y: 1.7, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "↑ Temp (FEVER)\n→ ↑ Heart Rate\n(10 bpm per 1°F rise)", 0.2, 2.05, 1.3, 0.85, C.accent5, C.white, 10);
  box(sl, "↓ Temp (HYPOTHERMIA)\n→ ↓ Heart Rate\n(Bradycardia)", 2.55, 2.05, 1.3, 0.85, C.accentPu, C.white, 10);

  box(sl, "Mechanism: Temperature changes directly affect\nmetabolic rate of SA node cells", 0.2, 3.0, 3.7, 0.7, C.accent2, C.textDark, 10);

  // Chemical factors section
  box(sl, "BLOOD GAS LEVELS (O2 / CO2)", 4.5, 0.75, 4.3, 0.6, C.accent3, C.textDark, 13);
  arrowDown(sl, 6.65, 1.35, 0.35);

  sl.addShape("line", { x: 6.65, y: 1.7, w: -1.5, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 6.65, y: 1.7, w: 1.5, h: 0, line: { color: C.arrowClr, width: 1.8 } });
  sl.addShape("line", { x: 5.15, y: 1.7, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  sl.addShape("line", { x: 8.15, y: 1.7, w: 0, h: 0.35, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "HYPOXIA (↓ O2)\n↑ CO2, ↑ H+\n(Acidosis)\n→ ↑ HR via chemoreceptors", 4.0, 2.05, 2.3, 1.0, C.accent5, C.white, 10);
  box(sl, "↑ O2\n↓ CO2 (Alkalosis)\n→ ↓ HR\n(Less chemoreceptor drive)", 6.9, 2.05, 2.3, 1.0, C.accentPu, C.white, 10);

  // Ions section
  box(sl, "ELECTROLYTE (ION) EFFECTS", 9.5, 0.75, 3.5, 0.6, C.accent3, C.textDark, 13);
  arrowDown(sl, 11.25, 1.35, 0.35);

  const ions = [
    ["↑ K+ (Hyperkalemia)", "↓ HR → Cardiac arrest (extreme)", "E3F2FD"],
    ["↓ K+ (Hypokalemia)", "↑ HR → Arrhythmia risk", "FFEBEE"],
    ["↑ Ca2+ (Hypercalcemia)", "↑ HR → Spastic heart", "FFEBEE"],
    ["↓ Ca2+ (Hypocalcemia)", "↓ HR → Tetany, bradycardia", "E3F2FD"],
  ];
  ions.forEach((ion, i) => {
    box(sl, ion[0] + "\n→ " + ion[1], 9.0, 1.7 + i * 0.75, 4.5, 0.65, ion[2] === "E3F2FD" ? C.accent2 : C.accent5, ion[2] === "E3F2FD" ? C.textDark : C.white, 10, false);
  });

  // Exercise section at bottom
  box(sl, "EXERCISE & PHYSICAL ACTIVITY → ↑ HR (via sympathetic activation + ↓ vagal tone + ↑ CO2 / ↓ O2 in muscles)", 0.3, 4.8, 12.7, 0.65, C.accent4, C.textDark, 12);
  arrowDown(sl, 6.65, 5.45, 0.35);
  box(sl, "Maximum HR during exercise = 220 − Age (years) [approximate formula]", 3.0, 5.8, 7.3, 0.6, C.midBg, C.white, 12);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 12 — AGE, SEX, AND OTHER FACTORS
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "AGE, SEX, EMOTIONAL & OTHER FACTORS AFFECTING HEART RATE", C.accent4);

  // Age
  box(sl, "AGE", 0.3, 0.75, 2.0, 0.6, C.accent4, C.textDark, 14);
  arrowDown(sl, 1.3, 1.35, 0.35);
  const ageData = [
    ["Fetus (in womb)", "120–160 bpm"],
    ["Newborn", "~120 bpm"],
    ["Infant (1 yr)", "~110 bpm"],
    ["Child (5 yrs)", "~90 bpm"],
    ["Adult (20–60 yrs)", "60–100 bpm"],
    ["Elderly (>60 yrs)", "Slightly ↑ due to ↓ vagal tone"],
  ];
  ageData.forEach((d, i) => {
    box(sl, d[0], 0.2, 1.7 + i * 0.72, 1.5, 0.62, i % 2 === 0 ? C.accent2 : C.midBg, i % 2 === 0 ? C.textDark : C.white, 10, false);
    sl.addShape("line", { x: 1.7, y: 1.7 + i * 0.72 + 0.31, w: 0.3, h: 0, line: { color: C.arrowClr, width: 1.6, endArrowType: "triangle" } });
    box(sl, d[1], 2.0, 1.7 + i * 0.72, 1.5, 0.62, "F1F8E9", C.textDark, 10, false);
  });

  // Sex
  box(sl, "SEX", 4.5, 0.75, 2.0, 0.6, C.accentPu, C.white, 14);
  arrowDown(sl, 5.5, 1.35, 0.35);
  box(sl, "Females have slightly HIGHER resting HR than males\n(~5–7 bpm higher on average)", 3.8, 1.7, 3.4, 0.9, C.accentPu, C.white, 11);
  arrowDown(sl, 5.5, 2.6, 0.35);
  box(sl, "Due to smaller heart size → lower stroke volume\n→ higher HR needed to maintain cardiac output", 3.8, 2.95, 3.4, 0.9, "EDE7F6", C.textDark, 10, false);

  // Emotions / Psychological
  box(sl, "EMOTIONAL & PSYCHOLOGICAL FACTORS", 8.3, 0.75, 4.7, 0.6, C.accent5, C.white, 13);
  arrowDown(sl, 10.65, 1.35, 0.35);
  const emotions = [
    { e: "Fear / Anxiety", effect: "↑ HR (sympathetic activation)", color: C.accent5 },
    { e: "Excitement", effect: "↑ HR (adrenaline rush)", color: C.accent5 },
    { e: "Grief / Sorrow", effect: "↓ HR (vagal dominance)", color: C.accentPu },
    { e: "Deep Sleep", effect: "↓ HR (parasympathetic dominates)", color: C.accentPu },
  ];
  emotions.forEach((em, i) => {
    box(sl, em.e + "\n→ " + em.effect, 8.1, 1.7 + i * 0.72, 4.9, 0.62, em.color, C.white, 10, false);
  });

  // Posture & Others at bottom
  box(sl, "POSTURE", 0.3, 6.0, 1.8, 0.55, C.accent3, C.textDark, 12);
  sl.addShape("line", { x: 2.1, y: 6.27, w: 0.5, h: 0, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "Standing → ↑ HR vs lying down (orthostatic reflex)", 2.6, 6.0, 4.6, 0.55, "FFF8E1", C.textDark, 11, false);

  box(sl, "PAIN", 7.5, 6.0, 1.3, 0.55, C.accent3, C.textDark, 12);
  sl.addShape("line", { x: 8.8, y: 6.27, w: 0.5, h: 0, line: { color: C.arrowClr, width: 1.8, endArrowType: "triangle" } });
  box(sl, "Acute pain → ↑ HR (sympathetic)  |  Severe/chronic pain → ↓ HR (vasovagal)", 9.3, 6.0, 3.7, 0.55, "FFF8E1", C.textDark, 10, false);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 13 — REFLEXES CONTROLLING HEART RATE
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "REFLEXES CONTROLLING HEART RATE", C.accent1);

  // Bainbridge Reflex
  box(sl, "BAINBRIDGE REFLEX\n(Atrial Reflex)", 0.3, 0.8, 3.2, 0.75, C.accent1, C.white, 13);
  arrowDown(sl, 1.9, 1.55, 0.35);
  box(sl, "↑ Venous return\n→ Stretches right atrium", 0.3, 1.9, 3.2, 0.7, C.accent2, C.textDark, 11);
  arrowDown(sl, 1.9, 2.6, 0.35);
  box(sl, "Stretch receptors (atrial mechanoreceptors)\nsend signals to medulla via vagus nerve", 0.3, 2.95, 3.2, 0.75, C.midBg, C.white, 10, false);
  arrowDown(sl, 1.9, 3.7, 0.35);
  box(sl, "↑ Sympathetic + ↓ Parasympathetic\n→ ↑ HEART RATE", 0.3, 4.05, 3.2, 0.7, C.accent5, C.white, 11);
  box(sl, "Purpose: Prevent blood pooling in veins; match HR with increased venous return", 0.3, 4.85, 3.2, 0.75, "E3F2FD", C.textDark, 10, false);

  // Baroreceptor Reflex
  box(sl, "BARORECEPTOR REFLEX\n(Carotid Sinus / Aortic Arch)", 5.05, 0.8, 3.2, 0.75, C.accent3, C.textDark, 13);
  arrowDown(sl, 6.65, 1.55, 0.35);
  box(sl, "↑ Blood Pressure\n→ Stretches arterial walls", 5.05, 1.9, 3.2, 0.7, C.accent2, C.textDark, 11);
  arrowDown(sl, 6.65, 2.6, 0.35);
  box(sl, "Baroreceptors signal CIC in medulla\nvia Glossopharyngeal (IX) & Vagus (X) nerves", 5.05, 2.95, 3.2, 0.75, C.midBg, C.white, 10, false);
  arrowDown(sl, 6.65, 3.7, 0.35);
  box(sl, "↑ Parasympathetic + ↓ Sympathetic\n→ ↓ HEART RATE (Reflex Bradycardia)", 5.05, 4.05, 3.2, 0.7, C.accentPu, C.white, 11);
  box(sl, "Purpose: Prevent dangerously high BP; buffer BP changes (short-term)", 5.05, 4.85, 3.2, 0.75, "EDE7F6", C.textDark, 10, false);

  // Chemoreceptor Reflex
  box(sl, "CHEMORECEPTOR REFLEX\n(Carotid & Aortic Bodies)", 9.8, 0.8, 3.2, 0.75, C.accent4, C.textDark, 13);
  arrowDown(sl, 11.4, 1.55, 0.35);
  box(sl, "↓ O2 (Hypoxia)\n↑ CO2 / ↑ H+ (Acidosis)", 9.8, 1.9, 3.2, 0.7, C.accent2, C.textDark, 11);
  arrowDown(sl, 11.4, 2.6, 0.35);
  box(sl, "Chemoreceptors activated\n→ Signal to CAC in medulla", 9.8, 2.95, 3.2, 0.75, C.midBg, C.white, 10, false);
  arrowDown(sl, 11.4, 3.7, 0.35);
  box(sl, "↑ Sympathetic drive\n→ ↑ HEART RATE\n(+ Vasoconstriction)", 9.8, 4.05, 3.2, 0.7, C.accent5, C.white, 11);
  box(sl, "Purpose: Increase O2 delivery during hypoxia/acidosis; ensures adequate cardiac output", 9.8, 4.85, 3.2, 0.75, "E8F5E9", C.textDark, 10, false);

  // Bottom summary box
  box(sl, "ALL REFLEXES converge at the Cardiovascular Center (Medulla) → Modulate Sympathetic / Parasympathetic outflow → Change SA Node firing rate → Change Heart Rate", 0.3, 5.8, 12.7, 0.8, C.accent1, C.white, 12);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 14 — MASTER SUMMARY FLOWCHART
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "MASTER SUMMARY — HEART RATE REGULATION (All Factors)", C.darkBg);

  // Top: Stimuli
  const stimuli = [
    { t: "Fear/\nExercise/\nFever", x: 0.2, color: C.accent5 },
    { t: "↓O2\n↑CO2\nAcidosis", x: 2.2, color: C.accent3 },
    { t: "↑ Venous\nReturn\n(Bainbridge)", x: 4.2, color: C.accent4 },
    { t: "↓ Blood\nPressure", x: 6.2, color: C.accentPu },
    { t: "Drugs:\nAtropine /\nAdrenaline", x: 8.2, color: C.accent1 },
    { t: "Emotions /\nAnxiety /\nPain", x: 10.3, color: C.accent5 },
  ];
  stimuli.forEach(s => {
    box(sl, s.t, s.x, 0.75, 1.9, 0.85, s.color, s.color === C.accent3 || s.color === C.accent4 ? C.textDark : C.white, 9);
    arrowDown(sl, s.x + 0.95, 1.6, 0.35);
  });

  // Cardiovascular Center
  box(sl, "CARDIOVASCULAR CENTER (Medulla Oblongata)", 2.5, 1.95, 8.3, 0.65, C.midBg, C.white, 13);
  arrowDown(sl, 6.65, 2.6, 0.35);

  // Two arms: Sympathetic and Parasympathetic
  sl.addShape("line", { x: 6.65, y: 2.95, w: -3.5, h: 0, line: { color: C.arrowClr, width: 2.0 } });
  sl.addShape("line", { x: 6.65, y: 2.95, w: 3.5, h: 0, line: { color: C.arrowClr, width: 2.0 } });
  sl.addShape("line", { x: 3.15, y: 2.95, w: 0, h: 0.35, line: { color: C.arrowClr, width: 2.0, endArrowType: "triangle" } });
  sl.addShape("line", { x: 10.15, y: 2.95, w: 0, h: 0.35, line: { color: C.arrowClr, width: 2.0, endArrowType: "triangle" } });
  box(sl, "↑ SYMPATHETIC\n(Norepinephrine → β1)", 1.5, 3.3, 3.3, 0.75, C.accent5, C.white, 12);
  box(sl, "↓ PARASYMPATHETIC\n(ACh → M2)", 8.5, 3.3, 3.3, 0.75, C.accentPu, C.white, 12);

  // Both converge on SA NODE
  sl.addShape("line", { x: 3.15, y: 4.05, w: 0, h: 0.35, line: { color: C.arrowClr, width: 2.0 } });
  sl.addShape("line", { x: 10.15, y: 4.05, w: 0, h: 0.35, line: { color: C.arrowClr, width: 2.0 } });
  sl.addShape("line", { x: 3.15, y: 4.4, w: 7.0, h: 0, line: { color: C.arrowClr, width: 2.0 } });
  arrowDown(sl, 6.65, 4.4, 0.35);

  box(sl, "SA NODE (Pacemaker)\nSets firing rate", 4.8, 4.75, 3.7, 0.75, C.accent1, C.white, 13);
  arrowDown(sl, 6.65, 5.5, 0.35);

  // Two final outcomes
  sl.addShape("line", { x: 6.65, y: 5.85, w: -3.2, h: 0, line: { color: C.arrowClr, width: 2.0 } });
  sl.addShape("line", { x: 6.65, y: 5.85, w: 3.2, h: 0, line: { color: C.arrowClr, width: 2.0 } });
  sl.addShape("line", { x: 3.45, y: 5.85, w: 0, h: 0.35, line: { color: C.arrowClr, width: 2.0, endArrowType: "triangle" } });
  sl.addShape("line", { x: 9.85, y: 5.85, w: 0, h: 0.35, line: { color: C.arrowClr, width: 2.0, endArrowType: "triangle" } });
  box(sl, "↑ HEART RATE\nTACHYCARDIA\n> 100 bpm", 1.5, 6.2, 3.9, 0.9, C.accent5, C.white, 14);
  box(sl, "↓ HEART RATE\nBRADYCARDIA\n< 60 bpm", 7.9, 6.2, 3.9, 0.9, C.accentPu, C.white, 14);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 15 — TRAINING AND HEART RATE (Athletes)
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = pres.addSlide();
  sl.background = { color: C.lightBg };
  sectionHeader(sl, "CARDIAC TRAINING EFFECT & HEART RATE IN SPECIAL CONDITIONS", C.accent4);

  // Athlete bradycardia
  box(sl, "ATHLETIC TRAINING EFFECT", 4.3, 0.75, 4.7, 0.65, C.accent4, C.textDark, 14);
  arrowDown(sl, 6.65, 1.4, 0.35);
  box(sl, "Regular aerobic exercise over months/years", 4.3, 1.75, 4.7, 0.6, C.midBg, C.white, 12);
  arrowDown(sl, 6.65, 2.35, 0.35);
  box(sl, "↑ Stroke volume (larger heart, stronger contraction)", 4.3, 2.7, 4.7, 0.6, C.accent2, C.textDark, 12);
  arrowDown(sl, 6.65, 3.3, 0.35);
  box(sl, "Cardiac output maintained with LOWER heart rate", 4.3, 3.65, 4.7, 0.6, C.accent4, C.textDark, 12);
  arrowDown(sl, 6.65, 4.25, 0.35);
  box(sl, "ATHLETE'S BRADYCARDIA\nResting HR = 40–60 bpm (PHYSIOLOGICAL — not pathological)", 4.0, 4.6, 5.3, 0.85, C.accent4, C.textDark, 13);

  // Other special conditions table
  sl.addText("HEART RATE IN SPECIAL CONDITIONS:", { x: 0.5, y: 5.65, w: 12.3, h: 0.4, fontSize: 13, bold: true, color: C.textDark, align: "center", fontFace: "Calibri" });
  const conditions = [
    ["Condition", "HR Change", "Reason"],
    ["Fever (each 1°F rise)", "↑ ~10 bpm", "↑ SA node metabolic rate"],
    ["Hyperthyroidism", "↑↑ HR (>100 bpm)", "T3/T4 sensitize to catecholamines"],
    ["Hypothyroidism", "↓ HR (<60 bpm)", "↓ Catecholamine sensitivity"],
    ["Anemia", "↑ HR", "Compensate for ↓ O2 carrying capacity"],
    ["Heart Block", "↓ HR (30–40 bpm)", "AV block — ventricles use own pacemaker"],
  ];
  conditions.forEach((row, i) => {
    const y = 6.05 + i * 0.21;
    const colors = i === 0 ? [C.midBg, C.midBg, C.midBg] : [C.lightBg, "FFF8E1", "E8F5E9"];
    const textClrs = i === 0 ? [C.white, C.white, C.white] : [C.textDark, C.textDark, C.textDark];
    [row[0], row[1], row[2]].forEach((cell, j) => {
      sl.addShape("rect", { x: 0.5 + j * 4.1, y, w: 4.0, h: 0.2, fill: { color: colors[j] }, line: { color: C.gray, width: 0.5 } });
      sl.addText(cell, { x: 0.5 + j * 4.1, y, w: 4.0, h: 0.2, fontSize: 9, bold: i === 0, color: textClrs[j], align: "center", valign: "middle", fontFace: "Calibri" });
    });
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// WRITE FILE
// ═══════════════════════════════════════════════════════════════════════════════
pres.writeFile({ fileName: "/home/daytona/workspace/heart-rate-flowcharts/Heart_Rate_Flowcharts_Sembulingam.pptx" })
  .then(() => console.log("SUCCESS: File written!"))
  .catch(err => console.error("ERROR:", err));
Running Command

cd /home/daytona/workspace/heart-rate-flowcharts && node heart_rate_flowcharts.js 2>&1

Running Command

ls -lh /home/daytona/workspace/heart-rate-flowcharts/

Your Heart Rate flowchart presentation is ready!

Heart Rate Flowcharts Sembulingam

Presentation · PPTX


Here is what is included across 15 slides with long-line flowcharts, simple English, and a professional navy/blue color scheme:
SlideTopic
1Title Slide
2Definition & Normal Values (60-100 bpm, Bradycardia, Tachycardia)
3SA Node as Pacemaker - Origin of Heart Rate
4Overview of ALL Factors Affecting Heart Rate
5Sympathetic Nervous System - Step-by-step pathway
6Sympathetic Final Effect - Positive Chronotropic Effect (↑ HR)
7Parasympathetic (Vagus Nerve) - Step-by-step pathway
8Parasympathetic Final Effect - Negative Chronotropic Effect (↓ HR)
9Cardiovascular Center in Medulla - all inputs (baroreceptors, chemoreceptors, higher brain)
10Hormonal Regulation - Epinephrine, T3/T4, Acetylcholine, Adenosine
11Temperature, Blood Gases (O2/CO2), Electrolytes (K+, Ca2+), Exercise
12Age, Sex, Emotions, Posture, Pain
13Three Reflexes - Bainbridge, Baroreceptor, Chemoreceptor (side-by-side)
14Master Summary Flowchart - All factors in one diagram
15Athlete's Bradycardia & Special Conditions table
Each flowchart uses color-coded boxes: red = increases HR, purple = decreases HR, blue = mechanisms, green = positive effects - making it easy to follow during revision.
This is a shared conversation. Sign in to Orris to start your own chat.