41 lines
1.3 KiB
Markdown
41 lines
1.3 KiB
Markdown
|
# Obsidian Asymptote
|
||
|
An Obsidian plugin for rendering [Asymptote](https://asymptote.sourceforge.io/) drawings within notes.
|
||
|
|
||
|
## Demo
|
||
|
````md
|
||
|
# 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](https://asymptote.sourceforge.io/binaries.html) 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.
|
||
|
|