Scripted
import { card } from "./components/card.lay" page = canvas(name="LayMesh components", size=(180 mm, 90 mm), background="#ffffff")spacing = 58 mmfor index in range(3) { label = "Card " + str(index + 1) tile = card(label) placed = page.add(tile,size=(42 mm, auto), target=page.top_left, offset=(8 mm + index * spacing, 12 mm), opacity=0.95)}import { card } from "./components/card.lay" page = canvas(name="LayMesh components", size=(180 mm, 90 mm), background="#ffffff")spacing = 58 mmfor index in range(3) { label = "Card " + str(index + 1) tile = card(label) placed = page.add(tile,size=(42 mm, auto), target=page.top_left, offset=(8 mm + index * spacing, 12 mm), opacity=0.95)}import { photo, icon, gap, accent } from "./materials.lay" ## @lang zh-CN## 创建带有标题和图标的可复用照片卡片。## @param {string} label - 标题,可包含行内公式。## @param {length} width - 照片宽度;显式单位固定其物理尺寸。## @returns {group} 带有测量边界和定位锚点的可复用卡片。## @example## item = card("结果", width=34mm)## @lang en## Build a reusable photo card with a caption and icon.## @param {string} label - Caption, including optional inline mathematics.## @param {length} width - Photo width; an explicit unit fixes its physical size.## @returns {group} A reusable card with measured bounds and placement anchors.## @example## item = card("Result", width=34mm)export function card(label, width=34 mm) { picture = group() picture.add(photo,size=(width, auto), target=picture.top_left) caption = group() title = text(content=label, font_family="DejaVu Sans", font_size=9 pt, color=accent) caption.add(title, target=caption.top_left) caption.add(icon,size=(7 mm, auto), target=caption.top_left, offset=(0 mm, 6 mm)) content = group() placed = content.add(picture, target=content.top_left) content.add(caption, target=placed.bottom_left, offset=(0 mm, gap)) return content}# Paths belong to this module, even when another module imports these values.## Reusable photograph shared by card components.## @type {image}export photo = image(src="../assets/photo.png")## Reusable vector icon for card captions.## @type {image}export icon = image(src="../assets/icon.svg")## Physical spacing between the photograph and its caption.## @type {length}export gap = 3 mm## @lang zh-CN## 标题默认强调色。## @type {color}## @lang en## Default caption accent color.## @type {color}export accent = "#087f8c"Preview
Background
Dependencies
examples/assets/icon.svgexamples/assets/photo.pngexamples/components/card.layexamples/components/materials.layexamples/scripted.lay
Reproduce
laymesh validate examples/scripted.laylaymesh render examples/scripted.lay -o figure.svglaymesh render examples/scripted.lay -o figure.pdflaymesh render examples/scripted.lay -o figure.png --dpi 300