LayMeshDocs
中文

Basic concepts#

Purpose and concepts#

Create a page, define material, then use add to create instances. Material holds reusable content and default style; an instance holds this placement’s dimensions, transform and position. A definition alone draws nothing. Instance anchors have container coordinates.

Minimal complete example#

Run this file directly with laymesh validate or laymesh render; it contains its own canvas and required definitions.

canvas.lay
# Minimal complete example: canvaspage=canvas(size=(100mm,75mm),background="#ffffff")page.add(text("Physical page",font_size=12pt),offset=(5mm,5mm))

Preview

Background
Canvas
Original example
Total —
Details

Not run yet

Measured in this browser; excludes debounce.

Edits stay on this page
Dependencies
  • examples/manual/canvas.lay

Parameters and default behavior#

Unitless geometry uses the canvas unit; unitless type and stroke sizes use pt. Explicit call parameters override inherited/theme defaults. The linked interface reference lists accepted types, choices and defaults per parameter.

Composition#

Place one material repeatedly. Save the return from add so later instances can target its bounds or path. Changing a definition does not retroactively edit completed placements.

hello.lay
page = canvas(size=(160 mm, 100 mm), background="#ffffff") card = rect(size=(60 mm, 30 mm),            fill="#e7f4fa", border_color="#28618a", border_width=0.4 mm)left = page.add(card, target=page.top_left, offset=(12 mm, 15 mm))page.add(card, target=left.top_right, offset=(8 mm, 0 mm)) title = text(content="Hello LayMesh", font_size=14 pt, color="#203864")page.add(title, anchor=center, target=left.center)

Preview

Background
Hello
Original example
Total —
Details

Not run yet

Measured in this browser; excludes debounce.

Edits stay on this page
Dependencies
  • examples/hello.lay

Common errors and limits#

Do not query page anchors on rect(...) itself: first use placed=page.add(material). An entry has one canvas; modules provide material and functions.

Individual functions#

canvas#

Create a page with physical dimensions, a background and a default geometry unit. Place material with add. Unitless geometry initially uses mm; font sizes and line widths use pt.

Returns: A page that accepts placed material.

Required inputs: size.

Minimal complete source · Composition source · All parameters

Detailed behavior and further examples#

Parameters#

Parameter Purpose Default or requirement
canvas Create the entry canvas One entry canvas
add Create a placed instance Drawn in insertion order

Common usage#

Material definitions are reusable; add creates placed instances. A canvas is a page, a group is a local coordinate container, and a plot is a placeable material. Name an instance when later placement needs to reference it.

Complete parameters and rules

Installation and validation