Skip to content

API reference / Common / Engine types / Brush

Type Alias: Brush ​

ts
type Brush = 
  | {
  solid: Color;
}
  | {
  pattern: {
     patternId: PatternId;
     underlyingColor: Color | null;
  };
};

The source of color used to fill or stroke a shape (PDF editing model).

Mirrors PDF's non-solid color sources: a solid color or a registered Pattern (tiling or shading). Image fills (OOXML blipFill, SVG <pattern> with <image>) are not a primitive here — callers that want to fill with an image wrap it in a tiling Pattern.

Whether a side actually paints is gated by other fields on the owning object — e.g. PathObject::fill / stroke, or TextStyle::render_mode. The brush always carries what to paint with if that side paints, never "no paint"; PDF's gs has a complete color state at all times (initial state is solid black in DeviceGray, PDF spec 8.4.3.1), so the model mirrors that.

This is the editing-side, id-addressed shape; the rendering-side Brush in core::graphics carries gradients and patterns inline by Arc after layout pre-records them.