Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PageShape

Shapes the left and right margins of drawn text to flow text around shaped edges. A shape is defined in terms of insets relative to the original margins specified by the region passed to draw. A MarkupBox will query the PageShape with a range of Y-positions covered by a line of text, and the shape must return the narrowest (largest) inset within that range. Positive inset values reduce the margins by moving a side inward; negative values increase them. A zero inset leaves the margin unchanged.

To create a new shape, subclass PageShape and override getLeftInset and getRightInset. Optionally, you can also override debugDraw to draw lines indicating how the margins have changed. If you do not override this method, then no margin lines (dashed blue lines) will be drawn when Show Regions is active.

In addition to creating your own shapes, a number of predefined shapes are available to handle common cases.

Hierarchy

  • PageShape

Implements

Index

Constructors

constructor

Properties

Static RECTANGLE_SHAPE

RECTANGLE_SHAPE: PageShape

A shared instance of the default shape, which has no effect on the text margins.

Methods

debugDraw

  • Called when a markup box is drawn and Show Regions is active. This method should draw lines or curves to indicate the shape visually. The passed-in graphics context will already have been initialized with an appropriate stroke, paint, and transform.

    Parameters

    Returns void

getLeftInset

  • getLeftInset(y1: number, y2: number): number
  • Returns the narrowest left edge inset between y1 and y2. It is guaranteed that y1 <= y2.

    Parameters

    • y1: number

      the top of the Y-range

    • y2: number

      the bottom of the Y-range

    Returns number

    the maximum inset within the specified range

getRightInset

  • getRightInset(y1: number, y2: number): number
  • Returns the narrowest right edge inset between y1 and y2. It is guaranteed that y1 <= y2.

    Parameters

    • y1: number

      the top of the Y-range

    • y2: number

      the bottom of the Y-range

    Returns number

    the maximum inset within the specified range