LayMesh文档
EN

Functions

完整源码
functions.lay
# Built-in functions, units, loops, conditions and a user function.page = canvas(name="LayMesh functions", size=(120 mm, 55 mm), background="#ffffff")font = "DejaVu Sans" function twice(value) { return value * 2 }values = [2, 4]values = append(values, 6)count = 0for value in values { count = count + value }for index in range(3) { count = count + index }while count < 18 { count = count + 1 }status = "pending"if count == 18 { status = "ready" } else { status = "error" } small = min(5 mm, 3 mm, 8 mm)large = max(5 mm, 3 mm, 8 mm)distance = abs(-4 mm) title = text(content="Functions and control flow", font_family=font, font_size=13 pt, color="#087f8c")page.add(title, target=page.top_left, offset=(7 mm, 6 mm))summary = text(content="len=" + str(len(values)) + "  total=" + str(count) + "  " + status,               font_family=font, font_size=10 pt)page.add(summary, target=page.top_left, offset=(7 mm, 24 mm))units = text(content="min=" + str(small) + "  max=" + str(large) +                     "  abs=" + str(distance) + "  twice=" + str(twice(2 mm)),             font_family=font, font_size=8 pt)page.add(units, target=page.top_left, offset=(7 mm, 36 mm))

预览

背景
正在准备预览…
Functions
正在准备预览…
合计 —
详情

尚未运行

本设备浏览器实测;不含防抖等待。

修改仅保留在本页
依赖文件
  • examples/functions.lay

复现

sh
laymesh validate examples/functions.laylaymesh render examples/functions.lay -o figure.svglaymesh render examples/functions.lay -o figure.pdflaymesh render examples/functions.lay -o figure.png --dpi 300