Here is some documentation of my reverse engineering of the implementation of Scribe notebooks.
Scribe notebooks are in KDF format which contains KFX content in an SQLite database with embedded "fingerprint" data to deter reading or modification by non-Amazon software.
Hand drawn content is contained within a canvas (page). The information for each page is:
- Canvas width (pixels)
- Canvas height (pixels)
- PPI (pixels per inch)
Resolution is always 2520 ppi (99.2 pixels per mm). Notebook pages are 15624 by 20832 pixels (6.2 by 8.27 inches). Sticky notes are 13726 by 7350 pixels (5.45 by 2.92 inches).
Each stroke is composed of:
- Color - always zero (black) so far
- Brush type - 0=original pen, 1=highlighter, 5=pencil, 6=fountain pen, 7=new pen (if constant thickness) or marker (if variable thickness)
- Random seed - for generating random pencil density
- Stroke bounds - X/Y coordinate limits of the stroke in pixels (upper left and lower right), measured from top left of the canvas
- Thickness - in pixels, chosen from a set of five values that are different for each brush type
- List of points - see below
It has not yet been confirmed whether points are generated at a constant rate while a stroke is being created. The highest measured rate is approximately 368 points per second, however that might include interpolated points added for smoothness. Subsequent points at the same position are eliminated from the list in newer firmware.
The information provided for each point is:
- X position - offset from left side of stroke bounds
- Y position - offset from top of stroke bounds
- Thickness adjustment factor - multiplier for stroke thickness (percent)
- Density adjustment factor - amount of random fill for pencil strokes (percent)
- X tilt - angle in degrees, -63 (left) to +63 (right), 0 is upright
- Y tilt - angle in degrees, -63 (up) to +63 (down), 0 is upright
- Pressure - 1 (light) to 4095 (heavy)
The first four of these can be used to replicate the strokes as rendered by the Scribe fairly well. The other three values (tilt and pressure) are not needed directly for rendering but are instead raw data from the digitizer that go into the calculation of the two adjustment factors.
Derivation of stroke thickness and density adjustment factors from raw data
The Scribe user selects one of five stroke thicknesses (fine, thin, medium, thick, or heavy). The base thickness in pixels for each selection varies by brush type. The actual thickness of drawn strokes is also influenced by other factors and can vary from point to point along the stroke. The density of the stroke, the amount of dithered fill, can likewise vary.
The handing of stroke thickness and density depends on the brush type.
- Stroke thickness and density do not vary for pen and highlighter.
- Stroke thickness for marker and pencil takes into account the pressure applied and the angle that the pen is tilted from upright.
- Stroke density for pencil also uses the same factors but they influence it differently. Density is constant for all other brush types.
- Stroke thickness for fountain pen uses the above factors and also the direction of motion of the pen along the screen.
The raw data of pressure, tilt, and direction of motion from the pen are each used to derive a factor. The transformation of raw data into each factor is performed by computing a
cubic Bézier curve, allowing non-linear behavior. Slightly different curves are used for each brush type and selected base thickness.
All of the factors that apply to a particular brush type are multiplied by the base thickness selected by the user to calculate the actual thickness produced along the stroke. Different factors are computed for stroke density and these are also combined by multiplication.
While the Bézier curves used to transform raw data are all different there is some commonality and how they function.
- Higher pressure produces thicker strokes. Changes in pressure at mid-level pressures have little effect. The effect of changes in pressure on line thickness is greatest at both low and high pressure.
- More tilt from upright (0 degrees) toward flat against the screen (90 degrees) produces thicker but less dense strokes. The effect tilt increases as the tilt angle increases. The direction that the pen is tilted (left, right, up, down) has no effect, only the angle with respect to the screen is significant.
- Direction of motion produces thinner strokes when moving toward the top of the screen and thicker strokes when moving toward the bottom of the screen. Moving left or right is neutral.
Examples of the Bézier curves are attached.