Divooka Reference

Stroke Writing

3 nodes

On this page 3

Measure Ink

Function

The rectangle the ink of a run occupies, relative to the run's origin, without the nib's
own width.

Signature
MeasureInk -> (Low Accuracy Number, Low Accuracy Number, Low Accuracy Number, Low Accuracy Number)
    font: Stroke Font
    text: Text
    capHeight: Low Accuracy Number
    slant: Low Accuracy Number
(float, float, float, float) MeasureInk(
    StrokeFont font,
    string text,
    float capHeight,
    float slant = -0.1f)

Parameters

nametypedefaultdescription
fontStroke Font—
textText—
capHeightLow Accuracy Number—
slantLow Accuracy Number-0.1

Returns

result(Low Accuracy Number, Low Accuracy Number, Low Accuracy Number, Low Accuracy Number)

Remarks

Traced rather than derived from the font's metrics, because that is the only answer that is
right for a face whose glyphs lean and overshoot. A run that puts no ink on the paper at all -
nothing but spaces - reports its advance by the cap height instead, so that a caller sizing an
image around it gets a picture rather than a one-pixel sliver.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Stroke Writing
Package
Image Processing

Write Text

Function

Writes a run of text into a new image sized to the ink.

Signature
WriteText -> Pixel Image
    text: Text
    font: Stroke Font
    capHeight: Low Accuracy Number
    inkColor: Optional Color
    backgroundColor: Optional Color
    padding: Low Accuracy Number
    slant: Low Accuracy Number
    pen: Nib
    progress: Low Accuracy Number
PixelImage WriteText(
    string text,
    StrokeFont font,
    float capHeight = 64f,
    ColorElement? inkColor,
    ColorElement? backgroundColor,
    float padding = 16f,
    float slant = -0.1f,
    Nib pen,
    float progress = 1f)

Parameters

nametypedefaultdescription
textText—The text to write.
fontStroke Font—The face to write with; the embedded Hershey Script when not given.
capHeightLow Accuracy Number64Height from baseline to cap line, in pixels.
inkColorOptional Color—The ink. Black when not given.
backgroundColorOptional Color—The paper. Transparent when not given.
paddingLow Accuracy Number16Margin around the ink, in pixels.
slantLow Accuracy Number-0.1Shear per unit of height; negative leans right, as a hand does.
penNib—The nib to sweep; a fountain pen scaled to the cap height when not given.
progressLow Accuracy Number1How much of the pen's journey to show, 0 to 1.

Returns

resultPixel Image
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Stroke Writing
Package
Image Processing

Write Text Onto

Function

Writes a run of text onto an image the caller already has.

Signature
WriteTextOnto -> Pixel Image
    original: Pixel Image
    text: Text
    x: Low Accuracy Number
    baseline: Low Accuracy Number
    font: Stroke Font
    capHeight: Low Accuracy Number
    inkColor: Optional Color
    slant: Low Accuracy Number
    pen: Nib
    progress: Low Accuracy Number
    inPlace: Truth
PixelImage WriteTextOnto(
    PixelImage original,
    string text,
    float x,
    float baseline,
    StrokeFont font,
    float capHeight = 64f,
    ColorElement? inkColor,
    float slant = -0.1f,
    Nib pen,
    float progress = 1f,
    bool inPlace = true)

Parameters

nametypedefaultdescription
originalPixel Image—The image to write on.
textText—The text to write.
xLow Accuracy Number—Where the run starts.
baselineLow Accuracy Number—The baseline the run sits on.
fontStroke Font—The face to write with; the embedded Hershey Script when not given.
capHeightLow Accuracy Number64Height from baseline to cap line, in pixels.
inkColorOptional Color—The ink. Black when not given.
slantLow Accuracy Number-0.1Shear per unit of height; negative leans right, as a hand does.
penNib—The nib to sweep; a fountain pen scaled to the cap height when not given.
progressLow Accuracy Number1How much of the pen's journey to show, 0 to 1.
inPlaceTruthTrueWhether to write onto the caller's image or onto a copy.

Returns

resultPixel Image
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Stroke Writing
Package
Image Processing