Stroke Writing
3 nodes
On this page 3
Measure Ink
FunctionThe 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
| name | type | default | description |
|---|---|---|---|
| font | Stroke Font | — | |
| text | Text | — | |
| capHeight | Low Accuracy Number | — | |
| slant | Low 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
FunctionWrites 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 NumberPixelImage 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
| name | type | default | description |
|---|---|---|---|
| text | Text | — | The text to write. |
| font | Stroke Font | — | The face to write with; the embedded Hershey Script when not given. |
| capHeight | Low Accuracy Number | 64 | Height from baseline to cap line, in pixels. |
| inkColor | Optional Color | — | The ink. Black when not given. |
| backgroundColor | Optional Color | — | The paper. Transparent when not given. |
| padding | Low Accuracy Number | 16 | Margin around the ink, in pixels. |
| slant | Low Accuracy Number | -0.1 | Shear per unit of height; negative leans right, as a hand does. |
| pen | Nib | — | The nib to sweep; a fountain pen scaled to the cap height when not given. |
| progress | Low Accuracy Number | 1 | How much of the pen's journey to show, 0 to 1. |
Returns
| result | Pixel Image |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Stroke Writing
- Package
- Image Processing
Write Text Onto
FunctionWrites 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: TruthPixelImage 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
| name | type | default | description |
|---|---|---|---|
| original | Pixel Image | — | The image to write on. |
| text | Text | — | The text to write. |
| x | Low Accuracy Number | — | Where the run starts. |
| baseline | Low Accuracy Number | — | The baseline the run sits on. |
| font | Stroke Font | — | The face to write with; the embedded Hershey Script when not given. |
| capHeight | Low Accuracy Number | 64 | Height from baseline to cap line, in pixels. |
| inkColor | Optional Color | — | The ink. Black when not given. |
| slant | Low Accuracy Number | -0.1 | Shear per unit of height; negative leans right, as a hand does. |
| pen | Nib | — | The nib to sweep; a fountain pen scaled to the cap height when not given. |
| progress | Low Accuracy Number | 1 | How much of the pen's journey to show, 0 to 1. |
| inPlace | Truth | True | Whether to write onto the caller's image or onto a copy. |
Returns
| result | Pixel Image |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Stroke Writing
- Package
- Image Processing