Signature Pad and Calligraphy Grids: uView Pro X’s Cross-Platform Canvas Component
Cross-platform signature capture usually forces developers to write per-platform canvas logic for pixel alignment, undo stacks, and export quirks. ux-signature collapses that into one tag, so teams building for app, web, mini-program, and Harmony targets skip a whole class of canvas and coordinate-mapping bugs.
Handwritten signature capture in uni-app x usually means wrestling with touch coordinate alignment, pixel ratios, undo state, and export formats on each target platform. uView Pro X 2.0.15 bundles that into ux-signature: one canvas 2D component with built-in drawing, undo, clear, and export, supporting App, H5, WeChat mini-programs, and HarmonyOS from a single codebase.
The component exports the canvas as a base64 dataURL via a submit event, with PNG/JPEG format options, a quality clamp for JPEG, and separate on-screen vs. export background colors. Below the surface, it also offers a writing grid system—field grid, cross grid, nine-grid—with hand-drawn dashed lines that render identically across platforms, and guide-text for tracing characters. Events like start, signing, end, and submit, plus methods like done(), revoke(), and resize(), give developers control without touching platform-specific canvas code.
The undo implementation splits by platform—pixel snapshots on non-Harmony, stroke redraw on Harmony—so the component isn't just a wrapper; it has to branch on the runtime's canvas capabilities.
Hand-drawing dashed grid lines instead of relying on setLineDash points to how much uni-app's canvas APIs deviate across targets; even a simple line style needs manual work to look identical everywhere.
Separating on-screen background from export background, and keeping tracing guides out of exports unless export-grid is on, allows one component to serve both interactive writing and clean document output without extra image processing.