# Jh Math Geometry

> >

- **Type:** Skill
- **Install:** `agentstack add skill-mathruffian-dot-teaching-exam-skills-jh-math-geometry`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [mathruffian-dot](https://agentstack.voostack.com/s/mathruffian-dot)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [mathruffian-dot](https://github.com/mathruffian-dot)
- **Source:** https://github.com/mathruffian-dot/teaching-exam-skills/tree/master/skills/jh-math-geometry

## Install

```sh
agentstack add skill-mathruffian-dot-teaching-exam-skills-jh-math-geometry
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 國中數學幾何圖形技能（jh-math-geometry）

## 技能概覽

本技能生成適合試卷、簡報、教材的幾何 SVG 圖形，並輸出為 PNG 圖片檔，
可直接插入 Word 文件或 PowerPoint 投影片。

**核心腳本位置**（請在任何使用前確認）：
```bash
GEOM_DIR=""
for d in /mnt/skills/user/jh-math-geometry/scripts \
          /tmp/jh-math-geometry/scripts; do
  [ -f "$d/geometry_renderer.py" ] && GEOM_DIR="$d" && break
done
echo "腳本目錄：$GEOM_DIR"
```

---

## 處理流程

### Step 1：理解需求

根據使用者的描述，判斷需要哪些圖形。若不確定，先快速確認：
- 哪個單元（三角形/四邊形/圓/立體...）？
- 需要標哪些字母/數字？
- 是否有特殊標記（直角符號、等邊刻度、角弧）？
- 輸出目標：Word、PPTX 或純圖片下載？

### Step 2：建立圖形規格 JSON

依需求建立 spec，儲存至 `/home/claude/geometry_spec.json`：

```json
{
  "figures": [
    {
      "id": "fig1",
      "type": "triangle",
      "config": {
        "subtype": "right",
        "vertex_labels": ["A", "B", "C"],
        "right_angle_at": "C",
        "side_labels": {"AB": "5", "BC": "3", "CA": "4"}
      },
      "canvas": {"width": 280, "height": 220}
    }
  ],
  "options": {"format": "png", "dpi": 150}
}
```

> 詳細參數見 `references/figure-catalog.md`（用 view 工具讀取）。

### Step 3：安裝依賴並執行渲染

```bash
pip install cairosvg python-docx python-pptx --break-system-packages -q

mkdir -p /home/claude/geometry_output

python3 "$GEOM_DIR/geometry_renderer.py" \
    /home/claude/geometry_spec.json \
    /home/claude/geometry_output/

ls /home/claude/geometry_output/
```

### Step 4：視覺確認

```bash
# 用 view 工具看 SVG（快速確認）
```

使用 `view` 工具查看產生的 `.svg` 檔案確認圖形是否正確。
若有錯誤（標籤偏移、比例不佳），調整 `config` 後重新執行。

### Step 5：輸出

#### 純圖片下載
```bash
cp /home/claude/geometry_output/fig1.png /mnt/user-data/outputs/
```

#### 插入 Word
```bash
python3 -  /home/claude/geometry_spec.json << 'SPEC'
{
  "figures": [
    {"id": "q3_fig", "type": "triangle", "config": {...}, "canvas": {"width":250,"height":200}}
  ],
  "options": {"format": "png", "dpi": 150}
}
SPEC

# 3. 渲染
mkdir -p /home/claude/geometry_output
python3 "$GEOM_DIR/geometry_renderer.py" /home/claude/geometry_spec.json /home/claude/geometry_output/

# 4. 取得 PNG 路徑供插入
FIGURE_PNG="/home/claude/geometry_output/q3_fig.png"
```

---

## 圖形類型速查表

| type 值 | 說明 | 常用 subtype |
|---------|------|------------|
| `triangle` | 三角形 | `general` `right` `isosceles` `equilateral` |
| `quadrilateral` | 四邊形 | `parallelogram` `rectangle` `rhombus` `square` `trapezoid` `right_trapezoid` |
| `circle` | 圓 | （無 subtype，用 elements 控制）|
| `coordinate_plane` | 坐標平面 | （含直線、拋物線、點、線段）|
| `solid_3d` | 立體圖形 | `rectangular_prism` `cylinder` `cone` `triangular_prism` `square_pyramid` `triangular_pyramid` |
| `parallel_lines` | 平行線截角 | （n_parallel 控制條數）|
| `triangle_center` | 三角形的心 | `centroid` `circumcenter` `incenter` |
| `similar_triangles` | 相似三角形 | （triangle1 + triangle2 各自設定）|

---

## 標記系統

| 功能 | 參數 | 說明 |
|------|------|------|
| 頂點標籤 | `vertex_labels` | 預設 `["A","B","C"]` |
| 直角符號 | `right_angle_at` | 指定頂點 |
| 角弧 | `angle_arcs` | `{"A":1}` = 一條弧，`{"A":2}` = 兩條弧（全等角）|
| 等邊刻度 | `equal_marks` | `{"AB":1,"CD":1}` = 同一組，`{"EF":2}` = 另一組 |
| 邊長/邊名 | `side_labels` | `{"AB":"5"}` 或 `{"AB":"a"}` |
| 虛線邊 | `dashed_sides` | `["AB"]` |
| 高 | `altitude_from` | 從指定頂點畫高 |
| 中線 | `median_from` | 從指定頂點畫中線 |

---

## 參考資料位置

| 需要什麼 | 讀取哪個檔案 |
|----------|-------------|
| 所有圖形類型的完整參數 + 快速複製範例 | `references/figure-catalog.md` |
| SVG 產生引擎原始碼 | `scripts/geometry_renderer.py` |
| SVG → PNG 轉換 | `scripts/svg_to_image.py` |
| 插入 Word 的函式 | `scripts/insert_to_docx.py` |
| 插入 PPTX 的函式 | `scripts/insert_to_pptx.py` |

---

## 注意事項

1. **cairosvg 安裝**：每次新對話開始前都要重新 `pip install`
2. **座標確認**：用 `view` 工具看 `.svg` 確認後再插入文件
3. **畫布尺寸**：試卷用圖建議 `280×220`；簡報用圖建議 `360×280`
4. **字體**：SVG 使用 serif，匯出 PNG 後在 Word/PPTX 中外觀一致
5. **多圖批次**：figures 陣列可一次放多個圖形，manifest.json 記錄所有輸出路徑

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [mathruffian-dot](https://github.com/mathruffian-dot)
- **Source:** [mathruffian-dot/teaching-exam-skills](https://github.com/mathruffian-dot/teaching-exam-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-mathruffian-dot-teaching-exam-skills-jh-math-geometry
- Seller: https://agentstack.voostack.com/s/mathruffian-dot
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
