Skip to content

yzsp-studio/mediakit-shared-suite / ppt

飞书幻灯片:创建和编辑幻灯片。创建演示文稿、读取幻灯片内容、管理幻灯片页面(创建、删除、读取、局部替换)。当用户需要创建或编辑幻灯片、读取或修改单个页面时使用。

FileKindSize
SKILL.mdskill md40.1 KB
references/cli/lark-slides-add-slide.mdmarkdown7.3 KB
references/cli/lark-slides-create.mdmarkdown10.5 KB
references/cli/lark-slides-delete-slide.mdmarkdown2.7 KB
references/cli/lark-slides-history.mdmarkdown6.9 KB
references/cli/lark-slides-media-upload.mdmarkdown5.5 KB
references/cli/lark-slides-replace-slide.mdmarkdown14.8 KB
references/cli/lark-slides-screenshot.mdmarkdown5.4 KB
references/cli/lark-slides-update-slide.mdmarkdown11.6 KB
references/cli/lark-slides-xml-presentation-slide-get.mdmarkdown3.6 KB
references/cli/lark-slides-xml-presentation-slide-replace.mdmarkdown7.3 KB
references/cli/lark-slides-xml-presentations-get.mdmarkdown9.4 KB
references/refine/academic-research.mdmarkdown7.3 KB
references/refine/brand-storytelling.mdmarkdown8.3 KB
references/refine/business-pitch.mdmarkdown8.0 KB
references/refine/business-review.mdmarkdown8.3 KB
references/refine/fallback.mdmarkdown7.8 KB
references/refine/learning-and-training.mdmarkdown8.5 KB
references/refine/strategy-and-analysis.mdmarkdown8.1 KB
references/refine/technical-presentation.mdmarkdown8.1 KB
references/style/academic-research.mdmarkdown18.5 KB
references/style/brand-storytelling.mdmarkdown34.1 KB
references/style/business-pitch.mdmarkdown12.2 KB
references/style/business-review.mdmarkdown19.6 KB
references/style/fallback.mdmarkdown8.7 KB
references/style/learning-and-training.mdmarkdown20.8 KB
references/style/slide-taxonomy.mdmarkdown13.6 KB
references/style/strategy-and-analysis.mdmarkdown8.4 KB
references/style/technical-presentation.mdmarkdown15.6 KB
references/workflow/error-handling.mdmarkdown9.6 KB
references/workflow/local-compat.mdmarkdown5.3 KB
references/workflow/slides-editing.mdmarkdown34.6 KB
references/workflow/template-editing-main.mdmarkdown36.6 KB
references/workflow/template-editing-organizer.mdmarkdown24.4 KB
references/workflow/validation-visual.mdmarkdown7.1 KB
references/workflow/validation-xml.mdmarkdown31.9 KB
references/workflow/windows-compat.mdmarkdown6.3 KB
references/xml/fonts.mdmarkdown7.6 KB
references/xml/iconpark-index.jsonconfig729.4 KB
references/xml/iconpark.mdmarkdown2.1 KB
references/xml/slides_chart_demo.xmlconfig69.2 KB
references/xml/slides_xml_schema_definition.xmlconfig228.6 KB
references/xml/xml-schema-quick-ref.mdmarkdown34.7 KB
scripts/atomize_svg_to_slide.pyscript80.2 KB
scripts/atomize_svg_to_slide_test.pyscript5.5 KB
scripts/color_contrast_check.pyscript36.4 KB
scripts/color_contrast_check_test.pyscript28.9 KB
scripts/embed_svg_validator.pyscript56.7 KB
scripts/embed_svg_validator_test.pyscript18.2 KB
scripts/gen_svg_charts.pyscript48.8 KB
scripts/gen_svg_relations.pyscript42.6 KB
scripts/iconpark_tool.pyscript12.1 KB
scripts/iconpark_tool_test.pyscript7.7 KB
scripts/lint_inspect.pyscript23.3 KB
scripts/lint_inspect_test.pyscript13.2 KB
scripts/parse_template.pyscript114.0 KB
scripts/purge_deck.pyscript11.4 KB
scripts/safe_update_slide.pyscript21.0 KB
scripts/svg_lib/_baseline.pyscript50.9 KB
scripts/svg_lib/_boxplot_skin.pyscript21.5 KB
scripts/svg_lib/_common.pyscript46.6 KB
scripts/svg_lib/charts/__init__.pyscript853 B
scripts/svg_lib/charts/_shared.pyscript8.6 KB
scripts/svg_lib/charts/boxplot.pyscript26.9 KB
scripts/svg_lib/charts/calheat.pyscript45.7 KB
scripts/svg_lib/charts/candle.pyscript39.1 KB
scripts/svg_lib/charts/event_timeline.pyscript66.6 KB
scripts/svg_lib/charts/funnel.pyscript54.6 KB
scripts/svg_lib/charts/gantt.pyscript53.6 KB
scripts/svg_lib/charts/marimekko.pyscript26.9 KB
scripts/svg_lib/charts/matrix_heat.pyscript52.3 KB
scripts/svg_lib/charts/nested_donut.pyscript61.2 KB
scripts/svg_lib/charts/percent_grid.pyscript38.6 KB
scripts/svg_lib/charts/pyramid.pyscript44.8 KB
scripts/svg_lib/charts/quadrant.pyscript76.8 KB
scripts/svg_lib/charts/ridge.pyscript28.7 KB
scripts/svg_lib/charts/sankey.pyscript48.9 KB
scripts/svg_lib/charts/violin.pyscript37.2 KB
scripts/svg_lib/charts/waterfall.pyscript52.3 KB
scripts/svg_lib/svg_palettes.pyscript52.7 KB
scripts/svg_relation_lib/__init__.pyscript2.0 KB
scripts/svg_relation_lib/_viewbox.pyscript10.5 KB
scripts/svg_relation_lib/attributes/__init__.pyscript1.4 KB
scripts/svg_relation_lib/attributes/_resolver.pyscript1.3 KB
scripts/svg_relation_lib/attributes/_test_attrs.pyscript11.8 KB
scripts/svg_relation_lib/attributes/_test_pipeline.pyscript12.5 KB
scripts/svg_relation_lib/attributes/apply.pyscript5.3 KB
scripts/svg_relation_lib/attributes/category.pyscript1.5 KB
scripts/svg_relation_lib/attributes/confidence.pyscript1.5 KB
scripts/svg_relation_lib/attributes/directional.pyscript1.4 KB
scripts/svg_relation_lib/attributes/highlight.pyscript1.6 KB
scripts/svg_relation_lib/attributes/signed.pyscript1.7 KB
scripts/svg_relation_lib/attributes/size.pyscript1.3 KB
scripts/svg_relation_lib/attributes/status.pyscript2.1 KB
scripts/svg_relation_lib/attributes/temporal.pyscript2.5 KB
scripts/svg_relation_lib/attributes/typed.pyscript1.6 KB
scripts/svg_relation_lib/attributes/weighted.pyscript1.4 KB
scripts/svg_relation_lib/chrome.pyscript9.1 KB
scripts/svg_relation_lib/engine.pyscript11.5 KB
scripts/svg_relation_lib/layouts/__init__.pyscript383 B
scripts/svg_relation_lib/layouts/bloom_v2.pyscript37.9 KB
scripts/svg_relation_lib/layouts/c4_container_v2.pyscript35.1 KB
scripts/svg_relation_lib/layouts/column_stack.pyscript5.3 KB
scripts/svg_relation_lib/layouts/fishbone_v2.pyscript38.1 KB
scripts/svg_relation_lib/layouts/hub_fanout.pyscript15.5 KB
scripts/svg_relation_lib/layouts/osi_stack_v2.pyscript32.8 KB
scripts/svg_relation_lib/layouts/vertical_chain.pyscript4.5 KB
scripts/svg_relation_lib/palettes.pyscript8.9 KB
scripts/svg_relation_lib/palettes_ext.pyscript17.2 KB
scripts/svg_relation_lib/presets/__init__.pyscript297 B
scripts/svg_relation_lib/presets/_chrome.pyscript1.6 KB
scripts/svg_relation_lib/presets/hero_embed_01_AL_fishbone_v2.pyscript21.7 KB
scripts/svg_relation_lib/presets/hero_embed_02_PY_pmf_v2.pyscript16.5 KB
scripts/svg_relation_lib/presets/hero_embed_03_BL_bloom_v2.pyscript44.0 KB
scripts/svg_relation_lib/presets/hero_embed_04_J1_osi_v2.pyscript46.2 KB
scripts/svg_relation_lib/presets/hero_embed_05_MP_mindmap_v2.pyscript28.6 KB
scripts/svg_relation_lib/presets/hero_embed_07_TX_taxonomy_v2.pyscript64.7 KB
scripts/svg_relation_lib/presets/hero_embed_08_KP_kpi_v2.pyscript79.5 KB
scripts/svg_relation_lib/presets/hero_embed_09_E2_5why_v2.pyscript39.4 KB
scripts/svg_relation_lib/presets/hero_embed_10_CS_c4_v2.pyscript173.5 KB
scripts/svg_relation_lib/presets/hero_embed_32_CU2_curriculum_v2.pyscript66.1 KB
scripts/svg_relation_lib/presets/hero_embed_49_FT_faulttree_v2.pyscript69.4 KB
scripts/svg_relation_lib/render.pyscript28.0 KB
scripts/svg_relation_lib/render/render_bl_bloom_tests.pyscript8.2 KB
scripts/svg_relation_lib/render/render_cu2_curriculum_variants.pyscript19.6 KB
scripts/svg_relation_lib/render/render_e2_5why_variants.pyscript8.9 KB
scripts/svg_relation_lib/render/render_ft_faulttree_variants.pyscript12.8 KB
scripts/svg_relation_lib/render/render_j1_osi_tests.pyscript12.0 KB
scripts/svg_relation_lib/render/render_py_pmf_variants.pyscript13.0 KB
scripts/svg_relation_lib/render/render_tx_taxonomy_variants.pyscript17.6 KB
scripts/svg_relation_lib/schemas/__init__.pyscript280 B
scripts/svg_relation_lib/schemas/graph.pyscript1.5 KB
scripts/svg_relation_lib/schemas/tree.pyscript11.2 KB
scripts/svg_relation_lib/skeletons.pyscript15.3 KB
scripts/svg_relation_lib/skins/__init__.pyscript1.3 KB
scripts/svg_relation_lib/skins/_base.pyscript10.0 KB
scripts/svg_relation_lib/skins/annual_report_ivory.pyscript9.1 KB
scripts/svg_relation_lib/skins/art_deco.pyscript27.1 KB
scripts/svg_relation_lib/skins/arxiv_clean.pyscript9.1 KB
scripts/svg_relation_lib/skins/arxiv_pastel.pyscript9.0 KB
scripts/svg_relation_lib/skins/bain_scarlet.pyscript9.0 KB
scripts/svg_relation_lib/skins/bauhaus_primary.pyscript9.2 KB
scripts/svg_relation_lib/skins/bcg_forest.pyscript9.0 KB
scripts/svg_relation_lib/skins/bloomberg_amber.pyscript9.2 KB
scripts/svg_relation_lib/skins/blueprint_grid.pyscript9.6 KB
scripts/svg_relation_lib/skins/boardroom_navy.pyscript29.9 KB
scripts/svg_relation_lib/skins/chalkboard_slate.pyscript9.0 KB
scripts/svg_relation_lib/skins/coursera_indigo.pyscript9.0 KB
scripts/svg_relation_lib/skins/couture_noir.pyscript33.0 KB
scripts/svg_relation_lib/skins/deloitte_lime.pyscript8.9 KB
scripts/svg_relation_lib/skins/duolingo_cream.pyscript20.4 KB
scripts/svg_relation_lib/skins/editorial.pyscript6.4 KB
scripts/svg_relation_lib/skins/editorial_atelier.pyscript60.7 KB
scripts/svg_relation_lib/skins/editorial_atelier_lark.pyscript19.6 KB
scripts/svg_relation_lib/skins/editorial_atelier_tokens.mdmarkdown13.6 KB
scripts/svg_relation_lib/skins/engineering_kraft.pyscript9.0 KB
scripts/svg_relation_lib/skins/goldman_slate.pyscript9.1 KB
scripts/svg_relation_lib/skins/hermes_orange.pyscript9.0 KB
scripts/svg_relation_lib/skins/ib_editorial.pyscript28.9 KB
scripts/svg_relation_lib/skins/journal_ivory.pyscript29.7 KB
scripts/svg_relation_lib/skins/khan_teal.pyscript9.0 KB
scripts/svg_relation_lib/skins/luxury_manual.pyscript20.4 KB
scripts/svg_relation_lib/skins/manuscript_sepia.pyscript9.1 KB
scripts/svg_relation_lib/skins/mbb_consulting.pyscript32.8 KB
scripts/svg_relation_lib/skins/medical_chart.pyscript22.6 KB
scripts/svg_relation_lib/skins/monocle_ecru.pyscript9.1 KB
scripts/svg_relation_lib/skins/napkin.pyscript6.3 KB
scripts/svg_relation_lib/skins/notebook_grid.pyscript9.2 KB
scripts/svg_relation_lib/skins/oxford_indigo.pyscript9.1 KB
scripts/svg_relation_lib/skins/pitch_bauhaus.pyscript9.1 KB
scripts/svg_relation_lib/skins/pitch_ivory.pyscript18.7 KB
scripts/svg_relation_lib/skins/pitch_midnight.pyscript9.1 KB
scripts/svg_relation_lib/skins/pitch_neon.pyscript32.2 KB
scripts/svg_relation_lib/skins/pitch_sunset.pyscript9.1 KB
scripts/svg_relation_lib/skins/registry.pyscript8.5 KB
scripts/svg_relation_lib/skins/riso_duotone.pyscript9.0 KB
scripts/svg_relation_lib/skins/roland_terracotta.pyscript9.0 KB
scripts/svg_relation_lib/skins/saas_product.pyscript38.6 KB
scripts/svg_relation_lib/skins/strategic_briefing.pyscript31.3 KB
scripts/svg_relation_lib/skins/swiss_grid.pyscript8.9 KB
scripts/svg_relation_lib/skins/symposium_ash.pyscript9.2 KB
scripts/svg_relation_lib/skins/technical_whitepaper.pyscript23.7 KB
scripts/svg_relation_lib/skins/terminal_matrix.pyscript9.2 KB
scripts/svg_relation_lib/skins/wabi_sabi.pyscript9.3 KB
scripts/svg_relation_lib/skins/wsj_broadsheet.pyscript9.1 KB
scripts/sxsd_validator.pyscript38.4 KB
scripts/template_lint_all.pyscript48.1 KB
scripts/xml_inspect.pyscript19.8 KB
scripts/xml_inspect_test.pyscript17.7 KB
scripts/xml_lint.pyscript226.8 KB
scripts/xml_lint_test.pyscript346.9 KB

scripts/svg_relation_lib/layouts/hub_fanout.py

View on GitHub
"""Hub fanout layout · dandelion sql_tree 风格 hero canvas mindmap.

参考 dandelion/sql_tree.svg 的顶级视觉设计:
  - 中心圆形 hub · deep bg + gold kicker + serif 大字 + stat + dashed 内环
  - 5-8 branches 左右分布 (奇数时左多右少) · S 形贝塞尔曲线连 hub 边
  - branch card 180×46 · 左 hue bar + M{i}·{meta} kicker + name + subtitle + 右上 N LEAVES
  - leaf pill 170×22 · dot + L01 编号 + name + · + note
  - 顶部 KPI 带 (与 fishbone 同款)

输出 kinds:
    hub_shadow, hub_circle, hub_inner_ring, hub_kicker,
    hub_divider, hub_name, hub_stat, hub_note,
    branch_curve, branch_card, leaf_curve, leaf_pill,
    (右侧 legend 由 preset render 单独处理)
"""
from __future__ import annotations

from dataclasses import dataclass
from math import cos, sin, radians, atan2, sqrt
from typing import Any, Dict, List, Optional

from ..skins._base import _visual_width, _wrap_lines

__all__ = ["hub_fanout_layout", "LayoutOverflow", "HubFanoutParams"]


class LayoutOverflow(RuntimeError):
    pass


@dataclass
class HubFanoutParams:
    # canvas · 1400×720
    canvas_w: float = 1400.0
    canvas_h: float = 720.0
    # hub 圆心 (略偏下 · 顶部让位给 KPI 带 y=110~142)
    hub_cx: float = 680.0
    hub_cy: float = 420.0
    hub_r: float = 96.0
    hub_inner_r_delta: float = 10.0
    # branch card
    card_w: float = 210.0
    card_h: float = 78.0
    # branch anchor 位置
    left_card_x: float = 260.0
    right_card_x: float = 880.0
    # branch 竖向分布参数 · 左 3 右 2 时: 左侧 3 项分布 [hub_cy-210, hub_cy, hub_cy+210]
    branch_row_h: float = 240.0
    # leaf pill
    leaf_w: float = 190.0
    leaf_h: float = 32.0
    leaf_row_h: float = 38.0
    # leaf x offset
    leaf_x_offset_left: float = 200.0
    leaf_x_offset_right: float = 200.0
    leaf_card_gap: float = 26.0
    # branch curve control ratio
    branch_curve_ctrl_ratio: float = 0.5


def _iter_branches(tree: Any) -> List[Any]:
    root = getattr(tree, "root", None)
    if root is None:
        return []
    return list(getattr(root, "children", []) or [])


def hub_fanout_layout(
    tree: Any,
    x0: float, y0: float, x1: float, y1: float,
    *,
    params: Optional[HubFanoutParams] = None,
) -> List[Dict[str, Any]]:
    """sql_tree 风格 hero canvas mindmap layout.

    x0/y0/x1/y1 参数保留兼容 · 实际几何由 params 决定 (hero canvas 固定).

    Data schema (Tree):
        root: TreeNode
          label: hub 大字 (如 "SQL 5D")
          extra:
            kicker: 圆内顶部小字 (如 "CORE CURRICULUM")
            stat: 大 stat (如 "25 HOURS")
            stat_note: 底部微字 (如 "15 LESSONS · 5 MODULES")
          children: 3-8 branch nodes
            label: branch name (如 "SELECT / FROM")
            group: hue ("rust"/"blue"/"green"/"magenta"/"olive"/"cinnamon")
            extra:
              subtitle: str (如 "projection · scope")
              kicker: str (如 "M1 · 5 h" · 若未传则 f"M{idx+1}")
              n_leaf_label: str (如 "3 LESSONS" · 若未传则 f"{len(children)} LEAVES")
            children: leaf nodes
              label: leaf 显示文本 (如 "字段选择 · column pick")
              extra:
                code: str (如 "L01" · 若未传则 f"L{i:02d}" 全局编号)
    """
    p = params or HubFanoutParams()
    root = getattr(tree, "root", None)
    if root is None:
        return []

    branches = _iter_branches(tree)
    n = len(branches)
    if n == 0:
        return []
    if n > 8:
        raise LayoutOverflow(f"too many branches: {n} > 8")

    # ── hub_cy 按 branch 数动态: 少 branch 时上移让主体紧贴 KPI 带 ─
    n_left = (n + 1) // 2   # idx 0/2/4... 左
    n_right = n // 2        # idx 1/3/5... 右
    n_side_max = max(n_left, n_right, 1)
    # 计算最大 leaf 数 · 决定单个 branch 的实际内容半高
    max_leaves = max(
        (len(list(getattr(br, "children", []) or [])) for br in branches),
        default=0,
    )
    # 单个 branch 的内容半高 = max(card_h/2, leaves 总高/2)
    leaves_stack_h = max_leaves * p.leaf_row_h if max_leaves else 0
    single_branch_half_h = max(p.card_h / 2, leaves_stack_h / 2)
    # 主体总半高 = (n_side_max-1)*行距/2 + 单 branch 内容半高
    content_half_h = (n_side_max - 1) * p.branch_row_h / 2 + single_branch_half_h
    content_half_h = max(content_half_h, p.hub_r + 12)
    # 让主体顶 = KPI 底(180) + top_pad(20)
    top_of_content = 180 + 20
    hub_cy_dynamic = top_of_content + content_half_h
    # 兼容手动传 params.hub_cy
    if abs(p.hub_cy - 420.0) < 0.1:
        p_hub_cy = hub_cy_dynamic
    else:
        p_hub_cy = p.hub_cy

    out: List[Dict[str, Any]] = []

    # ── 1. hub 圆 ─────────────────────────────
    root_extra = getattr(root, "extra", {}) or {}
    out.append({
        "kind": "hub_shadow",
        "cx": p.hub_cx + 3, "cy": p_hub_cy + 4, "r": p.hub_r,
    })
    out.append({
        "kind": "hub_circle",
        "cx": p.hub_cx, "cy": p_hub_cy, "r": p.hub_r,
    })
    out.append({
        "kind": "hub_inner_ring",
        "cx": p.hub_cx, "cy": p_hub_cy, "r": p.hub_r - p.hub_inner_r_delta,
    })
    kicker = root_extra.get("kicker", "")
    if kicker:
        out.append({
            "kind": "hub_kicker",
            "cx": p.hub_cx, "cy": p_hub_cy - 44,
            "label": kicker,
        })
        out.append({
            "kind": "hub_divider",
            "x1": p.hub_cx - 30, "x2": p.hub_cx + 30,
            "y": p_hub_cy - 34,
        })
    name = str(getattr(root, "label", ""))
    if name:
        out.append({
            "kind": "hub_name",
            "cx": p.hub_cx, "cy": p_hub_cy - 8,
            "label": name,
        })
    stat = str(root_extra.get("stat", ""))
    if stat:
        out.append({
            "kind": "hub_stat",
            "cx": p.hub_cx, "cy": p_hub_cy + 24,
            "label": stat,
        })
    stat_note = str(root_extra.get("stat_note", ""))
    if stat_note:
        out.append({
            "kind": "hub_note",
            "cx": p.hub_cx, "cy": p_hub_cy + 52,
            "label": stat_note,
        })

    # ── 2. branch 分左右 · 奇数时左多右少 ─────────
    # 分配规则: idx 0 左, idx 1 右, idx 2 左, idx 3 右... 交替
    left_bs: List[Any] = []
    right_bs: List[Any] = []
    for i, br in enumerate(branches):
        (left_bs if i % 2 == 0 else right_bs).append(br)

    def _y_positions(count: int, hub_cy: float, row_h: float) -> List[float]:
        """竖向均分 count 个位置 · 以 hub_cy 为中心."""
        if count == 0:
            return []
        if count == 1:
            return [hub_cy]
        # count 项均分 · 总高 (count-1)*row_h · 顶端 = cy - (count-1)*row_h/2
        top = hub_cy - (count - 1) * row_h / 2
        return [top + i * row_h for i in range(count)]

    left_ys = _y_positions(len(left_bs), p_hub_cy, p.branch_row_h)
    right_ys = _y_positions(len(right_bs), p_hub_cy, p.branch_row_h)

    # ── 3. 遍历生成 branch + leaves ─────────
    global_leaf_idx = 0  # 全局 leaf 编号 L01, L02...
    for side, bs, ys, card_x_base in [
        ("left", left_bs, left_ys, p.left_card_x),
        ("right", right_bs, right_ys, p.right_card_x),
    ]:
        for k, br in enumerate(bs):
            hue = str(getattr(br, "group", "") or "rust")
            b_label = str(getattr(br, "label", ""))
            b_id = getattr(br, "id", f"b_{side}_{k}") or f"b_{side}_{k}"
            b_extra = getattr(br, "extra", {}) or {}
            subtitle = str(b_extra.get("subtitle", ""))
            leaves = list(getattr(br, "children", []) or [])
            n_leaf = len(leaves)
            # global_idx (M1..Mn) 由数据里传的 kicker 覆盖 · 否则按 branches 原序编号
            gi = branches.index(br)
            b_kicker = str(b_extra.get("kicker", f"M{gi + 1}"))
            n_leaf_label = str(b_extra.get("n_leaf_label", f"{n_leaf} LEAVES"))

            card_x = card_x_base
            card_y = ys[k] - p.card_h / 2

            # branch card
            # NOTE (R4 fix, 2026-09-13): anchor points on card edges (hub-side + leaf-side)
            # are stored explicitly so downstream draws never miss the line-endpoint.
            card_hub_anchor_x = card_x + p.card_w if side == "left" else card_x
            card_leaf_anchor_x = card_x if side == "left" else card_x + p.card_w
            card_anchor_y = card_y + p.card_h / 2

            out.append({
                "kind": "branch_card",
                "hue": hue,
                "x": card_x, "y": card_y,
                "w": p.card_w, "h": p.card_h,
                "label": b_label,
                "kicker": b_kicker,
                "subtitle": subtitle,
                "n_leaf_label": n_leaf_label,
                "n_leaf": n_leaf,
                "side": side,
                "index": gi,
                "id": b_id,
                # side-aware anchor points on card edges
                "hub_anchor_x": card_hub_anchor_x,
                "hub_anchor_y": card_anchor_y,
                "leaf_anchor_x": card_leaf_anchor_x,
                "leaf_anchor_y": card_anchor_y,
            })

            # branch → hub 的 S 形贝塞尔曲线
            # hub 侧端点: hub 圆边缘 (指向 card 中心方向)
            card_cx = card_x + p.card_w / 2
            card_cy = card_y + p.card_h / 2
            # 方向角
            dx = card_cx - p.hub_cx
            dy = card_cy - p_hub_cy
            dist = sqrt(dx * dx + dy * dy)
            ux = dx / dist if dist else 0
            uy = dy / dist if dist else 0
            # hub 表面端点
            hub_edge_x = p.hub_cx + ux * p.hub_r
            hub_edge_y = p_hub_cy + uy * p.hub_r
            # card 侧端点: 用之前计算的 hub_anchor (side-aware edge midpoint)
            card_edge_x = card_hub_anchor_x
            card_edge_y = card_anchor_y

            # S 形 Bezier: 控制点 1 在 hub 边右侧 · 控制点 2 在 card 边左侧 (side=left)
            # 用两个中垂线上的控制点
            mid_x = (hub_edge_x + card_edge_x) / 2
            ctrl1_x = mid_x
            ctrl1_y = hub_edge_y
            ctrl2_x = mid_x
            ctrl2_y = card_edge_y
            out.append({
                "kind": "branch_curve",
                "hue": hue,
                "d": f"M {hub_edge_x:.1f} {hub_edge_y:.1f} "
                     f"C {ctrl1_x:.1f} {ctrl1_y:.1f}, "
                     f"{ctrl2_x:.1f} {ctrl2_y:.1f}, "
                     f"{card_edge_x:.1f} {card_edge_y:.1f}",
                # 端点圆 (在 card 一侧)
                "dot_cx": card_edge_x,
                "dot_cy": card_edge_y,
                # explicit anchor endpoints for downstream verify (grep)
                "hub_anchor_x": hub_edge_x,
                "hub_anchor_y": hub_edge_y,
                "card_anchor_x": card_edge_x,
                "card_anchor_y": card_edge_y,
                # visibility hint · preset should honour this so curves are
                # not sub-pixel when SVG is scaled into small figure slots
                "stroke_width": 2.2,
            })

            # ── leaves ─────────
            if n_leaf == 0:
                continue
            # Measure the whole visible leaf row. The renderer places the dot at
            # the connector endpoint and aligns this combined label beside it.
            leaf_measures: List[Dict[str, Any]] = []
            for leaf in leaves:
                leaf_extra = getattr(leaf, "extra", {}) or {}
                l_code = str(leaf_extra.get("code", ""))
                l_label = str(getattr(leaf, "label", ""))
                display_label = f"{l_code}  {l_label}".strip() if l_code else l_label
                text_avail = p.leaf_w - 50
                # measure with font-size 15, char_w = size * 0.55 = 8.25
                char_w = 15.0 * 0.55
                lines = _wrap_lines(display_label, text_avail, char_w=char_w, max_lines=2)
                leaf_measures.append({
                    "leaf": leaf,
                    "code": l_code,
                    "label": l_label,
                    "display_label": display_label,
                    "lines": lines,
                    "n_lines": max(1, len(lines)),
                })
            # per-row pill height: base leaf_h if single line, else scale
            per_row_h = max(
                p.leaf_h,
                max((m["n_lines"] for m in leaf_measures), default=1) * (p.leaf_h * 0.72) + 6,
            )
            # per-row spacing must fit taller pills
            per_row_spacing = max(p.leaf_row_h, per_row_h + 6)
            total_leaf_h = n_leaf * per_row_spacing
            leaves_top = card_cy - total_leaf_h / 2 + per_row_spacing / 2 - per_row_h / 2

            if side == "left":
                leaf_x = card_x - p.leaf_card_gap - p.leaf_w
            else:
                leaf_x = card_x + p.card_w + p.leaf_card_gap

            for j, m in enumerate(leaf_measures):
                global_leaf_idx += 1
                leaf = m["leaf"]
                l_code = m["code"]
                l_label = m["label"]
                l_lines = m["lines"]
                l_y = leaves_top + j * per_row_spacing
                l_cy = l_y + per_row_h / 2

                # R4 fix: leaf pill's card-facing edge anchor (guarantee non-orphan)
                leaf_card_side_x = leaf_x + p.leaf_w if side == "left" else leaf_x
                leaf_anchor_x = leaf_card_side_x
                leaf_anchor_y = l_cy

                out.append({
                    "kind": "leaf_pill",
                    "hue": hue,
                    "x": leaf_x, "y": l_y,
                    "w": p.leaf_w, "h": per_row_h,
                    "code": l_code,
                    "label": l_label,
                    "display_label": m["display_label"],
                    "lines": l_lines,          # R4: pre-wrapped lines (list)
                    "n_lines": m["n_lines"],
                    "side": side,
                    "parent": b_id,
                    "index": j,
                    # R4: side-aware anchor · line endpoint MUST match this
                    "anchor_x": leaf_anchor_x,
                    "anchor_y": leaf_anchor_y,
                })

                # 从 branch card 到 leaf 的短 S 曲线
                # R4 fix: start point uses card's leaf_anchor (side-aware midpoint)
                # · end point uses leaf's card-facing anchor. Both are stored in
                # curve dict so grep-based unit tests can verify endpoint = leaf anchor.
                b_edge_x = card_leaf_anchor_x
                b_edge_y = card_anchor_y
                l_edge_x = leaf_anchor_x
                l_edge_y = leaf_anchor_y

                mid_lx = (b_edge_x + l_edge_x) / 2
                out.append({
                    "kind": "leaf_curve",
                    "hue": hue,
                    "d": f"M {b_edge_x:.1f} {b_edge_y:.1f} "
                         f"C {mid_lx:.1f} {b_edge_y:.1f}, "
                         f"{mid_lx:.1f} {l_edge_y:.1f}, "
                         f"{l_edge_x:.1f} {l_edge_y:.1f}",
                    # explicit endpoints for verify-by-grep
                    "card_anchor_x": b_edge_x,
                    "card_anchor_y": b_edge_y,
                    "leaf_anchor_x": l_edge_x,
                    "leaf_anchor_y": l_edge_y,
                    "parent": b_id,
                    "leaf_index": j,
                    # visibility hint · was 0.9 which is sub-pixel in tiny figure
                    # slots; bump to 1.4 so preset gets a non-zero stroke.
                    "stroke_width": 1.4,
                })

    return out
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall