Interface ElementTextConfig

interface ElementTextConfig {
    distance?: number;
    inside?: boolean;
    insideFill?: string;
    insideStroke?: string;
    layoutRect?: RectLike;
    local?: boolean;
    offset?: number[];
    origin?: "center" | (string | number)[];
    outsideFill?: string;
    outsideStroke?: string;
    position?: BuiltinTextPosition | (string | number)[];
    rotation?: number;
}

Properties

distance?: number

Distance to the rect

Default

5
inside?: boolean

Tell render2d I can sure this text is inside or not. In case position is not using builtin inside hints.

insideFill?: string

insideFill is a color string or left empty. If a textContent is "inside", its final fill will be picked by this priority: textContent.style.fill > textConfig.insideFill > "auto-calculated-fill" In most cases, "auto-calculated-fill" is white.

insideStroke?: string

insideStroke is a color string or left empty. If a textContent is "inside", its final stroke will be picked by this priority: textContent.style.stroke > textConfig.insideStroke > "auto-calculated-stroke"

The rule of getting "auto-calculated-stroke": If (A) the fill is specified in style (either in textContent.style or textContent.style.rich) or (B) needed to draw text background (either defined in textContent.style or textContent.style.rich) "auto-calculated-stroke" will be null. Otherwise, "auto-calculated-stroke" will be the same as fill of this element if possible, or null.

The reason of (A) is not decisive:

  1. If users specify fill in style and still use "auto-calculated-stroke", the effect is not good and unexpected in some cases. It not easy and seams uncessary to auto calculate a proper stroke for the given fill, since they can specify stroke themselve.
  2. Backward compat.
layoutRect?: RectLike

Rect that text will be positioned. Default to be the rect of element.

local?: boolean

If use local user space. Which will apply host's transform

Default

false
offset?: number[]

Offset of the label. The difference of offset and position is that it will be applied in the rotation

origin?: "center" | (string | number)[]

Origin or rotation. Which is relative to the bounding box of the attached element. Can be percent value. Relative to the bounding box. If specified center. It will be center of the bounding box.

Only available when position and rotation are both set.

outsideFill?: string

outsideFill is a color string or left empty. If a textContent is "inside", its final fill will be picked by this priority: textContent.style.fill > textConfig.outsideFill > #000

outsideStroke?: string

outsideStroke is a color string or left empth. If a textContent is not "inside", its final stroke will be picked by this priority: textContent.style.stroke > textConfig.outsideStroke > "auto-calculated-stroke"

The rule of getting "auto-calculated-stroke": If (A) the fill is specified in style (either in textContent.style or textContent.style.rich) or (B) needed to draw text background (either defined in textContent.style or textContent.style.rich) "auto-calculated-stroke" will be null. Otherwise, "auto-calculated-stroke" will be a neer white color to distinguish "front end" label with messy background (like other text label, line or other graphic).

position?: BuiltinTextPosition | (string | number)[]

Position relative to the element bounding rect

Default

'inside'
rotation?: number

Rotation of the label.