obsidian-asymptote/README.md

1.3 KiB

Obsidian Asymptote

An Obsidian plugin for rendering Asymptote drawings within notes.

Demo

# Asymptote Demo
This note shows how you can use Asymptote to draw images directly in notes.

See for example this picture:

```asy
unitsize(1cm);

path radius = (0, 0) -- (1 / sqrt(2), 1 / sqrt(2));
currentpen = currentpen + white;
// Shading
fill(unitcircle, p = colorless(currentpen) + opacity(0.2) + dashed + blue);
// Boundary
draw(unitcircle, p = colorless(currentpen) + dashed + red);
// Radius
draw(radius, green, L = scale(0.5) * Label("$r$"));
// Centre
dot((0, 0), L = scale(0.5) * Label("$x_0$"));
```

Building From Source

> npm i
> npm run build

Dependencies

Due to Asymptote not having any real support for use as a pure library, this plugin works by calling an Asymptote installation on a file created in the file system's temporary directory.

As such, this plugin is not standalone, and Asymptote must be installed.

Styling

Asymptote SVGs have their width and height properties stripped so that they can be independently styled using CSS. See styles.css for an example. In short, asy-rendered is the class of the div that directly wraps the child svg with the drawing itself.