Release v0.6.1

µcad

This release brings SVG paths as a new 2D primitive, a much richer web viewer with own documents, code completion and stepping of literals via keyboard, a new format of shared links, and some fixes in the lexer and the formatter.

Incompatible changes

  • Shared links have a new format: the code is compressed with Brotli behind the magic µ and a version byte, so that links start with wrUB. Links of µcad 0.6.0 cannot be opened anymore.
  • mucad format exits with an error, if the code cannot be parsed or formatted, instead of exiting successfully.
  • Formatted code changes slightly: block comments have no space in front of separators and closing brackets anymore, e.g. f(1 /* c */, 2) instead of f(1 /* c */ , 2), and no space after opening brackets, e.g. (/* c */).

Added

Language and standard library

  • SVG paths: std::geo2d::SvgPath(d, closed = true, flip = true) (built-in __mu::geo2d::SvgPath) makes a 2D geometry of the d attribute of an SVG path in millimeters. All path commands are supported, also relative ones and arcs. The y axis is flipped by default, because it points down in SVG. An invalid path is reported as error, the other models are rendered. See the Rust Gear example in order to get to know how it is used :)
  • Built-in primitives may have bool parameters.

Web viewer

Most visible changes happened in the web viewer.

  • Own documents: the example selection is a name field with a list of documents. Renaming an example or shared code creates an own document, own documents can be renamed and deleted. Examples can only be copied, not changed.
  • Saving with Save or Ctrl+S formats and compiles the code, unsaved documents are marked with ●. Own documents are stored in the browser, the browser asks before unsaved changes are lost by a reload.
  • The URL shows the link of the saved code, e.g. to bookmark it, without a new entry in the history.
  • Code completion of paths, names, keywords and types, with the documentation of each symbol. The suggestions open after :: and ..
  • Stepping of literals: Alt+↑/↓ steps the literal under the cursor by the digit at the cursor, e.g. by 0.1 in front of the first decimal, Alt+Shift+↑/↓ by ten times it. Quantities keep their unit and decimals, bools are toggled, the stepped digit is selected. Consecutive steps are undone at once and compiled at once with auto-update.
  • Shared links contain the name of the shared document, which is shown for opened links, e.g. brick.mu (shared).
  • Phone layout: the panels are a vertical stack with one panel at a time, which starts with the view, the actions and links are in a menu.
  • The export of STL and SVG is in the Share menu.

Tooling and APIs

  • Literals in code can be found and stepped: lang-parse literal_at, lang-types Value::step and Value::literal, driver literal_at and step_literal_at, wasm literalAt and stepLiteralAt.
  • Code completion in the wasm API (Mucad.complete).
  • SVG and Bézier modules: core::svg::parse_path parses SVG paths into cubic Bézier curves, render::bezier::render_curves renders Bézier curves into lines or polygons with the linear resolution, as finely as circles.
  • cargo xtask change-version sets the version of the whole workspace and updates Cargo.lock, --dry-run lists the changes.
  • A banner image in images/banner.png.

Fixed

  • Subtraction of floats without whitespace, e.g. a-1.5 and 3.0-1.5, is parsed: the minus in front of a float is an operator, like in front of an integer.
  • value_from_str reads negative quantities and integers, e.g. -10mm and -3.
  • The formatter writes named tuple types with colons, e.g. (x: Length, y: Length), so that formatted code with them can be parsed again, e.g. std/geo2d.mu.
  • An error of the formatter, which makes code invalid, is reported as such at the formatted code, and the file is not changed.
  • Block comments have a space in front of them in indented lines, e.g. in broken lists.
  • The header of the web viewer has an even layout without wrapped buttons.

Changed

  • Examples are improved, e.g. logo.mu, rust_gear.mu and footpad.mu, and there is a new example brick_parametric.mu.

Known issues

  • The arguments of built-ins and Bool parameters of the standard library are not type checked when they are called, e.g. SvgPath(closed = 1) is accepted.
  • mucad export does not export, if one model cannot be rendered, e.g. of an invalid SVG path.