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

# Pens and hatches

> Line weights, dash patterns and hatch patterns.

## Import

```typescript theme={null}
import {
  resolvePen,
  penFor,
  penContextFor,
  resolveInk,
  visibleUnder,
  lineWeightFor,
  stepUp,
  stepDown,
  hatchLines,
  PEN_TABLE,
  PEN_LADDER_MM,
  EDGE_CLASS_MODIFIER,
  HATCH_PATTERNS,
  DASH_HIDDEN,
  DASH_CENTRE,
  DASH_PHANTOM,
  DASH_CUTTING,
} from '@opengeometry/floorkit';
```

## resolvePen

```typescript theme={null}
function resolvePen(style?: DrawingStyle): Pen;
```

## penFor

The ink a primitive is drawn with.

```typescript theme={null}
function penFor(primitive: DrawingPrimitive, ctx?: PenContext): Pen;
```

## penContextFor

The per-viewport context: the policy plus an empty memo.

```typescript theme={null}
function penContextFor(policy: SheetPolicy): PenContext;
```

## resolveInk

Class resolution, memoised per `$&#123;ogType&#125;|$&#123;edgeClass&#125;|$&#123;kind&#125;`, then the producer's own overlay: an explicit width always wins (a producer that measured something — and `placeDrawing` bakes the resolved width back on, so the common case is a float compare and no allocation); an explicit fill wins only where the style allows it.

```typescript theme={null}
function resolveInk(
  style: DrawingStyle | undefined,
  kind: PrimitiveKind,
  ctx: PenContext,
  ruled?: boolean,
): Pen;
```

## visibleUnder

Whether a style draws this primitive at all (`ClassStyle.visible`).

```typescript theme={null}
function visibleUnder(primitive: DrawingPrimitive, ctx: PenContext): boolean;
```

## lineWeightFor

```typescript theme={null}
function lineWeightFor(ogType?: string): number;
```

## stepUp

One rung heavier on PEN\_LADDER\_MM — the sibling of stepDown, with the same rule for weights that are not on the ladder: returned unchanged, never snapped.

```typescript theme={null}
function stepUp(weightMm: number): number;
```

## stepDown

One rung lighter on PEN\_LADDER\_MM.

```typescript theme={null}
function stepDown(weightMm: number): number;
```

## hatchLines

Hatch lines for a region, in the region's own coordinates (paper mm when the region has already been placed).

```typescript theme={null}
function hatchLines(region: DrawingRegion | DrawingCurvedRegion, spec: HatchSpec): VectorLine[];
```

## PEN\_TABLE

The drafting palette, keyed by `ElementType`.

```typescript theme={null}
const PEN_TABLE: Record<string, Pen>;
```

## PEN\_LADDER\_MM

ISO 128 line-width ladder, in millimetres.

```typescript theme={null}
const PEN_LADDER_MM: readonly [0.13, 0.18, 0.25, 0.35, 0.5, 0.7, 1, 1.4, 2];
```

## EDGE\_CLASS\_MODIFIER

How an HLR edge class modifies the pen its element already resolved to.

```typescript theme={null}
const EDGE_CLASS_MODIFIER: Record<string, (pen: Pen) => Pen>;
```

## HATCH\_PATTERNS

Material hatches, for the drawings that want them.

```typescript theme={null}
const HATCH_PATTERNS: Record<string, HatchSpec>;
```

## DASH\_HIDDEN

Dashed narrow — hidden edges, things concealed by what is in front.

```typescript theme={null}
const DASH_HIDDEN: number[];
```

## DASH\_CENTRE

Long-dashed dotted narrow — centre lines, axes of symmetry.

```typescript theme={null}
const DASH_CENTRE: number[];
```

## DASH\_PHANTOM

Long-dashed double-dotted narrow — adjacent parts, outlines beyond the cut.

```typescript theme={null}
const DASH_PHANTOM: number[];
```

## DASH\_CUTTING

Long-dashed dotted wide — cutting planes.

```typescript theme={null}
const DASH_CUTTING: number[];
```

## Types

### Pen

How one primitive is inked on paper.

```typescript theme={null}
interface Pen {
  color: string;
  weightMm: number;
  dash?: number[];
  fill?: string;
  hatch?: HatchSpec;
  cap?: 'butt' | 'round';
  outline?: false;
}
```

<ResponseField name="color" type="string" required>
  Drafting ink, as a CSS colour. Never the element's 3D material colour.
</ResponseField>

<ResponseField name="weightMm" type="number" required>
  Lineweight in paper millimetres — a rung on PEN\_LADDER\_MM.
</ResponseField>

<ResponseField name="dash" type="number[]">
  Dash runs in paper mm. Absent or empty means continuous.
</ResponseField>

<ResponseField name="fill" type="string">
  Solid poché for `region` primitives. Mutually exclusive with `hatch`.
</ResponseField>

<ResponseField name="hatch" type="HatchSpec">
  Hatched poché for `region` primitives. Mutually exclusive with `fill`.
</ResponseField>

<ResponseField name="cap" type="'butt' | 'round'">
  Line cap. Absent is the renderer's default (butt); a hand stroke wants round. Unset on every pen
  the shipped table resolves.
</ResponseField>

<ResponseField name="outline" type="false">
  `false` draws a `region` as fill only, with no outline at all — `stroke="none"`, never a zero
  width, which PDF renders as the thinnest line the device can make. Unset on every pen the shipped
  table resolves.
</ResponseField>

### PenContext

Built once per viewport in `placeDrawing`; the memo lives here, never at module level, so a render is a pure function of its inputs.

```typescript theme={null}
interface PenContext {
  readonly style: PaperStyle;
  readonly sheetSalt: number;
  readonly inkCache: Map<string, Pen>;
}
```

### PrimitiveKind

```typescript theme={null}
type PrimitiveKind = DrawingPrimitive['kind'];
```

### HatchSpec

A region's hatch.

```typescript theme={null}
interface HatchSpec {
  angleDeg: number;
  spacingMm: number;
  weightMm: number;
  color: string;
  crossAngleDeg?: number;
}
```

<ResponseField name="angleDeg" type="number" required />

<ResponseField name="spacingMm" type="number" required />

<ResponseField name="weightMm" type="number" required />

<ResponseField name="color" type="string" required />

<ResponseField name="crossAngleDeg" type="number">
  A second pass at this angle — how cross-hatched materials are drawn.
</ResponseField>

## Related

* [`DrawingCurvedRegion`](/floorkit/api/drawings/draw-project-view#drawingcurvedregion)
* [`DrawingPrimitive`](/floorkit/api/drawings/draw-project-view#drawingprimitive)
* [`DrawingRegion`](/floorkit/api/drawings/draw-project-view#drawingregion)
* [`DrawingStyle`](/floorkit/api/drawings/draw-project-view#drawingstyle)
* [`PaperStyle`](/floorkit/api/drawings/sheet-documents#paperstyle)
* [`SheetPolicy`](/floorkit/api/drawings/viewport-placement#sheetpolicy)
* [`VectorLine`](/floorkit/api/drawings/draw-project-view#vectorline)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.