examples/components/card.lay 1import { photo, icon, gap, accent } from "./materials.lay"2 3## @lang zh-CN4## 创建带有标题和图标的可复用照片卡片。5## @param {string} label - 标题,可包含行内公式。6## @param {length} width - 照片宽度;显式单位固定其物理尺寸。7## @returns {group} 带有测量边界和定位锚点的可复用卡片。8## @example9## item = card("结果", width=34mm)10## @lang en11## Build a reusable photo card with a caption and icon.12## @param {string} label - Caption, including optional inline mathematics.13## @param {length} width - Photo width; an explicit unit fixes its physical size.14## @returns {group} A reusable card with measured bounds and placement anchors.15## @example16## item = card("Result", width=34mm)17export function card(label, width=34 mm) {18 picture = group()19 picture.add(photo,size=(width, auto), target=picture.top_left)20 21 caption = group()22 title = text(content=label, font_family="DejaVu Sans", font_size=9 pt, color=accent)23 caption.add(title, target=caption.top_left)24 caption.add(icon,size=(7 mm, auto), target=caption.top_left, offset=(0 mm, 6 mm))25 26 content = group()27 placed = content.add(picture, target=content.top_left)28 content.add(caption, target=placed.bottom_left, offset=(0 mm, gap))29 return content30}