Flying Chalk

Home / Guides / Why simulating chalk on a tablet is hard

Why simulating chalk on a tablet is hard

Six specific problems that turn a plausible chalk brush into flat grey, polygonal strokes or a smeared blob — and the storage decision that makes replay, layers and changing the board possible.

Chalk is a poor fit for the way drawing software is normally built. Almost every convenient default — draw a smooth path, sprinkle in some noise, read the latest touch position, save the pixels — happens to be wrong for dry media in a way that is not wrong for ink. What follows is the list of specific failures, written for someone who wants to understand the problem rather than implement it.

1. Randomness inside the stamp averages itself away

A stroke is not drawn as a shape. It is drawn as a chain of overlapping stamps placed along the path your hand took, close enough together that they merge into a line. That is a good and standard way to build a brush.

The obvious way to make it look grainy is to put random noise inside the stamp. It works for a single isolated stamp and it fails for a stroke, because of the overlaps. Where two stamps overlap you get the average of two independent random patterns; where ten overlap you get the average of ten. Averaging independent noise converges on its mean. So the thin, sparsely stamped ends of a stroke look convincingly speckled, and the body of the stroke — where the stamps pile up — turns into flat grey. That is the most common way digital chalk goes wrong, and it is why so many chalk brushes look right in a quick test scribble and wrong in an actual drawing.

The fix is to move the randomness out of the stamp and into the canvas. Flying Chalk anchors a surface-roughness texture to canvas coordinates and samples it per canvas point, so every stamp landing on a given spot reads the same roughness value and reinforces it instead of cancelling it out — the way real powder accumulates in the same pits. Two scales are used: fine noise for the grains, and a slower undulation so they clump rather than scatter like salt.

2. A dry mark is not dots piling up to solid

The intuitive model of a powdery medium is accumulation: lots of little semi-transparent dots, and as they build up the mark becomes solid. This produces smoke. It looks soft and cloudy, and increasing the density just gives denser smoke.

The physical picture is the reverse. A chalk mark is a solid deposit of pigment with holes bitten out of it by the surface. The default state is opaque; the surface subtracts. Flying Chalk uses a deposition threshold that decides whether a point receives a deposit at all, giving the mark a hard, irregular edge at the pit boundaries rather than a soft falloff. A brush tuned too transparent never crosses that threshold, and extra passes only make it foggier.

3. Barrel direction is unreliable exactly when you need it

Tilt shading needs two things from the stylus: how far it is leaned over, and which way it is pointing. The second one has a nasty property. When the stylus is close to vertical there is almost no horizontal projection of the barrel left to measure, so the reported direction can swing wildly between consecutive samples even though your hand is perfectly still.

Feed that raw angle straight into the rotation of a stamp and marks visibly shimmer under an upright stylus. Worse, interpolating naively between two angles on opposite sides of the compass makes a stamp spin most of the way around instead of taking the short way. Flying Chalk takes the barrel direction as a unit vector rather than a raw angle, which sidesteps both problems: vectors average sensibly where angles do not.

4. A fast stroke produces more samples than there are frames

On a high-refresh screen the system can collect several touch samples inside a single frame and hand them over as a batch, newest on top. The convenient way to write a drawing app reads only that newest position and throws the batch away.

For slow drawing that is invisible. For a fast flick it is a disaster: you sampled a curve four times per frame and kept one, so the curve becomes three or four straight segments with visible corners. Users report it as lag, which sends everyone looking in the wrong place — the positions arrived on time and were discarded.

The consequence is architectural rather than cosmetic. Flying Chalk builds its canvas on the low-level touch handling rather than on a convenience gesture API, because only that path exposes the coalesced samples — a decision you make at the start or pay for later.

5. Speed has to fade and thin the mark, or you never get dry skip

Drag a real stick slowly and the powder packs into a dense, solid mark. Whip it across and it skips — the mark thins, breaks up, and leaves gaps where the stick failed to bite. That broken fast mark is one of the few things that read instantly as "chalk", and an engine that ignores speed will never produce it.

So speed has to feed back into both the opacity and the width of the mark, as tunable amounts rather than as a fixed rule, because different materials skip differently. In Flying Chalk those are two of the numbers that define a tool. They also do something else: a fingertip reports nothing but position, so speed is the entire expressive channel a finger has, and getting it right is what makes finger drawing a real path rather than a degraded one.

6. A finger has no angle, and pretending otherwise is worse than nothing

A fingertip reports no tilt and no barrel direction. The trap is that "no tilt" often arrives as a zero, and zero altitude means "the barrel is lying flat on the glass" — maximum tilt. An engine that forwards touch data without checking what kind of touch it is will stretch every finger mark into an extreme smear pointing in an arbitrary direction.

The correct behaviour is to check the touch type first and degrade honestly: read pressure, tilt and direction only when the touch really is a stylus, and give a finger a round mark at a fixed mid-range pressure. Flying Chalk also clamps stylus pressure to a floor, so a feather-light touch still leaves something rather than nothing — a stroke that vanishes because you were gentle is a bug.

The decision underneath all of it: keep the points, not the pixels

Every problem above is about producing one convincing mark. The last decision is about what happens to the mark afterwards, and it shapes what the whole application can do.

The obvious approach is to render each stroke into a bitmap and keep the bitmap. It is simple, it is fast, and it throws away the drawing. Flying Chalk stores a drawing as a list of strokes, each a list of sample points plus a random seed, and redraws the picture by replaying those points. The thumbnail is the only bitmap, and it is not even saved.

Four things fall out of that. The archive is small, because a stroke is a handful of numbers rather than a screen of pixels. Undo and redo are exact — every speck of grain lands where it was, because the same points and the same seed regenerate the same mark, whereas a bitmap canvas has to store a full image per step to promise the same thing. Layers cost one integer per stroke instead of a full-screen image each. And the board material can be changed underneath a finished drawing, because the drawing was never baked into a particular surface — possible only because the grain belongs to the canvas rather than to the stroke, which closes the loop with the first problem on this list.

The same replay machinery pays off in two more places. Shapes — line, rectangle, ellipse, arrow, triangle, diamond, star, polygons — are sampled into point lists and fed through the identical stroke code, so a drawn rectangle carries the same grain and dry skip as a freehand line rather than being a clean vector pasted on top. And clearing the board is animated as real eraser strokes sweeping across in rows with a wobble, using the same stamping engine, so the edge is dusty. It is not a cross-fade, because a cross-fade is the one moment that would give the whole illusion away.

Frequently asked questions

Why does digital chalk go flat grey in the middle of a stroke?

Because the randomness lives inside the stamp. A stroke is many overlapping stamps, and averaging independent noise converges on its mean, so the thin ends stay speckled and the overlapped body flattens out.

Why do fast strokes come out with corners?

The app is reading only the newest touch position each frame and discarding the extra samples the system batched up. On a high-refresh screen a fast flick can carry several per frame, so a curve collapses into a polygon.

Why does a chalk brush sometimes look like smoke?

It is modelled as transparent dots accumulating toward solid. A dry mark is better modelled as a solid deposit with holes bitten out of it by the surface — if the brush never crosses that threshold, it stays foggy.

Why does my mark shimmer when I hold the stylus upright?

Near vertical there is almost no horizontal barrel projection left to measure, so the reported direction swings between samples. Treating it as a direction vector rather than a raw angle keeps it steady.

Why store points instead of pixels?

Because it keeps the drawing rather than a picture of it. The files stay small, undo is exact down to each speck of grain, layers cost almost nothing, and the board material can be swapped under a finished drawing.

Related guides

Try it on a chalkboard

Flying Chalk is a free chalkboard drawing app for iPad and iPhone. Pressure and tilt on Apple Pencil, eight chalk-family sticks, eleven surfaces. No ads, no account, no in-app purchases.

Download on the App Store