Skip to main content

Why a Stylus Mark Drifts Away from the Drawing Beneath It

Diagnose misplaced ink on a tablet plan viewer by tracing document coordinates, pointer cancellation, predicted samples and exported annotations.

R
Written by Reiko

A surveyor circles a cracked joint on a floor plan. On the tablet, the red circle neatly surrounds the joint. On the exported page, it lands in the next room. A second surveyor opens the original document, zooms in and finds the same error. The red line was saved successfully. The problem is the meaning of the numbers that were saved.

A plan viewer deals with a document, a viewport onto one page and a physical input surface. They happen to line up in a simple demonstration with one page at its original scale. Introduce a side inspector, a rotated page or a cropped export and the coincidence falls apart. A good diagnosis starts with a deliberately boring document: a single numbered page, four labelled corners, a cross at the centre and a second cross several centimetres away.

Work one coordinate through the whole pipeline

Suppose the drawing’s origin appears at screen position (80, 40) and the viewer scales each document unit to two screen units. A pen contact at screen position (280, 200) belongs at document position (100, 80). Subtract the origin first, then divide by two. Storing (280, 200) in the page record writes a screen position into a document. Dividing by two first and subtracting the unscaled origin produces (60, 60). Testing just the origin of an unpanned page can hide either mistake.

Make the renderer and input interpreter share an explicit transform. The renderer maps the document to the visible surface; input uses the inverse of that mapping. Include page rotation, the crop origin and any displacement caused by fitting the page inside a larger view. Name each space in function arguments and traces. A method accepting an unqualified pair called x and y can receive points expressed in pixels, logical units or PDF page coordinates without a compiler ever complaining.

The printed page deserves its own check. An export library may use a different vertical origin, a page crop box or rotation metadata. Take the saved centre of the surveyor’s red circle and project it through the export mapping. Open the resulting file in an independent reader. If reopening in the original viewer looks perfect but the independent reader shows a shift, investigate the export path before adjusting pen input. An equal and opposite pair of mistakes can cancel out inside one application.

Own the stroke from first contact to final sample

On pen-down, create a provisional stroke tied to a page identifier, a tool and a pointer identity. Decide what should happen if the page moves while that stroke is active. A viewer might freeze pan and zoom until pen-up. Another might allow a second hand to move the canvas, mapping each sample through the transform that applied when it was captured. Both can be implemented coherently. Using the latest transform to reinterpret the entire history at the end can bend a straight line around a newly opened inspector.

Pointer identity matters when several contacts arrive. The operating system can report a pen and the side of a hand in the same sequence. Record which contact began each provisional stroke. If a later event cancels a contact, remove its provisional marks and redraw the affected region. The exact cancellation information available varies across platform versions and input devices. An implementation that commits every contact irrevocably at first sight has no clean way to discard the grey slash left by a resting palm.

Try cancelling an eraser gesture as well. An eraser that immediately deletes committed strokes may erase a surveyor’s note before the system classifies the gesture as accidental. Keep enough information to restore the affected marks or model the erase as a provisional command. For an object eraser, recording the identifiers of affected strokes may suffice. A pixel eraser over a raster layer has different storage requirements. Define undo and cancellation semantics when choosing the eraser model.

Separate what the hand sees from what the file records

A renderer can display predictions to reduce the visible gap between the pen tip and the ink. A prediction is a guess about the next sample. When measured input arrives, replace the predicted tail. Persisting that tail as if it were observed can leave a hook beyond the end of a ruler line. For a field annotation, the final geometry should be derived from the accepted samples and the editor’s documented smoothing rules.

Measure the path from contact to display in stages. A device can deliver a batch of input samples together; keeping only the final point may turn a tight circle into a polygon. At the opposite extreme, writing a full page image to storage on every sample competes with rendering for time. Keep the immediate stroke cheap to update, consolidate completed strokes and decide how often to checkpoint an unfinished one. Test that decision by interrupting a long handwritten note midway through a word.

Watch the join between provisional ink and the committed layer. If the preview is removed one frame before the committed stroke appears, a line can blink on pen-up even when all geometry is correct. If both layers remain visible with partial opacity, the line can briefly darken. A frame recording with a contrasting background makes these transitions easier to see. Timing a save operation in isolation will tell you little about what the surveyor saw under the pen.

Decide what a line width means

A two-unit drafting line and a two-pixel cursor halo have different purposes. The drafting line belongs to the page and normally scales with the drawing. The halo helps the user locate the pen and may stay a similar size on screen. Store each according to that purpose. Reconstructing a saved line width from the current zoom causes a printed annotation to gain or lose weight depending on how closely the surveyor inspected the crack.

Pressure is another source of variation. Some pens supply usable pressure changes; a finger or a different accessory may supply no meaningful variation. Define a default width that produces legible marks and bound the pressure-to-width mapping. Test a light dot, a slow heavy stroke and a stroke made with a device that lacks pressure information. A zero-length tap can legitimately be a dot marking a screw position. A renderer that requires two distinct points silently drops that annotation.

The eraser’s hit area also needs a unit. A worker may expect a comfortably sized screen target when zoomed out, yet want precise removal at high magnification. Convert the chosen tolerance into document units before testing intersections. Include the stroke thickness in the hit test. On a page rotated ninety degrees, a test performed in unrotated screen coordinates may delete a neighbouring dimension line even though the eraser cursor is drawn at the correct spot.

Undo under the conditions of a real inspection

The surveyor draws three circles, changes pages, adds a note, then goes back to page one and taps Undo. Decide whether Undo follows chronological document history or the active page. Both have implications for discoverability. If Undo removes a note on another page without showing which note disappeared, the worker may press it again. Store each edit as a meaningful operation with its page identity. A long circle made of 400 samples should generally take one Undo, not 400.

Rotating or replacing the underlying plan is a different event from rotating the tablet. A revised architectural drawing can move walls relative to the original page coordinate system. Attach annotations to a document revision and page identity so that the application can distinguish those cases. Silently projecting yesterday’s red circles onto a newly cropped revision can be more misleading than showing the original marked sheet and asking for a review. Preserve a way to identify the revision in an exported inspection record.

Work through partial persistence. Suppose the page thumbnail has been updated but the new stroke record has not reached durable storage. After a restart the thumbnail can show a circle that disappears when the page opens. Treat thumbnail images as derived data and rebuild them from the committed page revision when their version lags or leads. An engineer should be able to delete the thumbnail cache during testing without losing a single accepted mark.

A four-corner fixture for the test bench

Mark the top-left, top-right, bottom-left and bottom-right targets with four different symbols. Draw a diagonal across the centre, add a pressure-sensitive dot and erase a small mark near the lower edge. Repeat with the plan panned away from its origin and at two zoom levels. Reopen the document after closing the process, then inspect an exported page. Mirrored symbols point to an axis conversion problem; a constant shift suggests an origin mismatch; a shift that grows with distance suggests a scale error.

Run a separate cancellation exercise with the actual pen and tablet used in the field. Rest a palm before the pen lands, then after it lands. Lift the pen while the palm stays down. Change tools, invoke Undo and pan across the area. Look for stray dots that appear only after a redraw. If the stray mark survives reopening, inspect the saved operation log. If it disappears after panning, inspect invalidation and the provisional layer. These observations split a vague report about palm rejection into two different engineering problems.

Agree on a tolerance for the exported fixture in the units the inspection actually requires. A tablet intended to annotate a general site photograph and a tool used to mark a dimensioned engineering drawing need different acceptance limits. Record the page identifier, page rotation, scale and transform at contact alongside synthetic sample coordinates. With those values, a developer can reproduce the mapping at a desk. The surveyor’s marked-up customer plans can stay on the device.

Did this answer your question?