> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supernote.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Geometry

> How to work with geometry elements in NOTE and DOC, with examples.

Geometry is both “drawing” and “data”. In NOTE and DOC, geometry elements can be used for annotation, composition, or to present structured information alongside note content. This chapter covers three common capabilities: insert, read from lasso selection, and modify.

## Insert Geometry

Call [`insertGeometry`](/en/api-reference/supernote-plugin/plugin-comm-api/insert-geometry) to insert a geometry element:

* In NOTE: inserted into the current page on the current layer of the currently opened note
* In DOC: inserted into the current page of the currently opened document

```ts wrap theme={null}
import { PluginCommAPI } from 'sn-plugin-lib';

/**
 * Insert a circle geometry into the current page.
 */
async function insertCircle() {
  const geometry = {
    penColor: 0x9d,     // Pen color for drawing the geometry
    penType: 10,        // Pen type for drawing the geometry
    penWidth: 200,      // Line width (min 100)
    type: 'GEO_circle', // Geometry type
    ellipseCenterPoint: { x: 300, y: 400 }, // Center point (pixel coordinates)
    ellipseMajorAxisRadius: 120,            // Major axis radius
    ellipseMinorAxisRadius: 120,            // Minor axis radius
    ellipseAngle: 0,                        // Rotation angle (radians)
  };
  const res = await PluginCommAPI.insertGeometry(geometry);
  console.log('insertGeometry:', res);
}
```

<Tip>
  The `type` field values and data structure are defined in [`Geometry`](/en/api-reference/supernote-plugin/types/geometry). Point coordinates use pixel coordinates.
</Tip>

## Get Lasso Geometries

After selecting geometry elements with the lasso tool, call [`getLassoGeometries`](/en/api-reference/supernote-plugin/plugin-comm-api/get-lasso-geometries) to read the selected geometry list.

```ts wrap theme={null}
import { PluginCommAPI } from 'sn-plugin-lib';

/**
 * Read geometries in the current lasso selection.
 */
async function readLassoGeos() {
  const res = await PluginCommAPI.getLassoGeometries();
  if (!res?.success) {
    console.error('getLassoGeometries error:', res?.error);
    return;
  }
  const list = res.result ?? [];
  console.log('lasso geometries:', list);
}
```

`result` is a list of [`Geometry`](/en/api-reference/supernote-plugin/types/geometry).

<Warning>
  You must create a lasso selection before calling this API. If there are no geometry elements in the lasso selection, the returned array is empty.
</Warning>

## Modify Lasso Geometry

You can modify the currently lasso-selected geometry, for example adjust a circle radius or change a line point set.
Call [`modifyLassoGeometry`](/en/api-reference/supernote-plugin/plugin-comm-api/modify-lasso-geometry) to apply the modification:

```ts wrap theme={null}
import { PluginCommAPI } from 'sn-plugin-lib';

/**
 * Modify the radius of a single circle geometry selected by lasso.
 */
async function updateLassoCircle() {
  const res = await PluginCommAPI.getLassoGeometries();
  if (!res?.success || !res.result || res.result.length !== 1) {
    console.error('You must lasso-select exactly one geometry element to modify it');
    return;
  }
  const geo = res.result[0];

  if (geo.type === 'GEO_circle' || geo.type === 'GEO_ellipse') {
    geo.ellipseMajorAxisRadius = (geo.ellipseMajorAxisRadius ?? 100) + 20;
    geo.ellipseMinorAxisRadius = (geo.ellipseMinorAxisRadius ?? 100) + 20;
  }

  const mod = await PluginCommAPI.modifyLassoGeometry(geo);
  console.log('modifyLassoGeometry:', mod);
}
```

<Warning>
  This operation requires the current lasso selection to contain exactly one geometry element. Calling it with no lasso selection or multiple geometries will fail.
</Warning>

## Related Types and APIs

* Geometry data structure: [`Geometry`](/en/api-reference/supernote-plugin/types/geometry)
* Insert geometry: [`insertGeometry`](/en/api-reference/supernote-plugin/plugin-comm-api/insert-geometry)
* Get lasso geometries: [`getLassoGeometries`](/en/api-reference/supernote-plugin/plugin-comm-api/get-lasso-geometries)
* Modify lasso geometry: [`modifyLassoGeometry`](/en/api-reference/supernote-plugin/plugin-comm-api/modify-lasso-geometry)
