The Embroidery Canvas is La Casa del Bordadito’s signature interactive feature. Users choose a pattern from a grid of thumbnails, then paint each cell of the canvas by selecting a colour from the palette and tapping matching cells. The canvas validates every tap — only the correct colour fills a cell — making it a guided, gamified recreation of the traditional Punto de Cruz (cross-stitch) technique. Progress is persisted to Firebase Realtime Database so users can close the app and continue exactly where they left off.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AndresLopezCorrales/La-casa-del-bordadito/llms.txt
Use this file to discover all available pages before exploring further.
Data models
PatronBordado
Each embroidery pattern stored in Firebase Realtime Database maps to this Kotlin class:| Field | Type | Description |
|---|---|---|
id | String | Realtime Database key, assigned after fetch |
nombre | String | Display name of the pattern |
columnas | Int | Number of columns in the grid |
filas | Int | Number of rows in the grid |
urlImagen | String | Thumbnail URL shown in the pattern selector |
paleta | List<ColorPatron> | Ordered list of colours used in this pattern |
matriz | List<List<Int>> | 2-D grid of colour IDs; 0 means the cell is transparent/empty |
porcentaje | Int | Cached completion percentage |
activo | Boolean | Only true patterns are shown to customers |
ColorPatron
paleta list describes one colour swatch. The numeric id matches the values stored in matriz, linking every cell to its required colour.
ProgresoUsuario
"fila_columna" (e.g. "3_7"), and the value is the colour ID that was painted.
How the canvas works
BordadoCanvasView is a custom View subclass that draws the entire grid directly on a Canvas.
Grid layout
Cell size is calculated as
canvasWidth / columnas. Every cell in the matriz is drawn as a rectangle. Cells with a colour ID of 0 are left blank (transparent border only). Unpainted cells display the required colour number as centred text so users know which palette swatch to select.Colour selection
The palette bar below the canvas renders one coloured square per
ColorPatron. Tapping a swatch sets colorSeleccionadoId on the canvas view and highlights the selected square with a black border stroke.Painting a cell
When the user taps the canvas, the touch coordinates are transformed back to model space by reversing the current scale and pan offset:If
matriz[fila][col] matches colorSeleccionadoId, the cell is added to puntosPintados and the canvas redraws.Wrong-colour feedback
Selecting the wrong colour does not paint the cell. Instead, a red border (
paintError) flashes over the tapped cell for 500 ms via a Handler delay, giving immediate tactile feedback without penalising the user permanently.Progress saved
Every successful paint triggers
onPuntoPintado, which writes the full ProgresoUsuario object to progreso/{uid}/{patronId} in Firebase Realtime Database. The progress bar and percentage label update at the same time.Zoom and pan
The canvas supports multi-touch pinch-to-zoom throughScaleGestureDetector:
| Behaviour | Detail |
|---|---|
| Minimum zoom | 1.0× — canvas fills the view with no white borders |
| Maximum zoom | 10.0× |
| Pan bounds | Enforced by applyBounds() so the canvas cannot be scrolled past its own edges |
| Zoom focus | Zooms toward the midpoint between the two pinch fingers |
| Grid line width | Scaled inversely (strokeWidth = 1f / mScaleFactor) so lines stay visually consistent at all zoom levels |
Admin: uploading patterns
Admins see a FAB in the pattern-selection screen. Tapping it opens a dialog where a raw JSON string can be pasted and uploaded directly topatrones/{id} in Realtime Database. New patterns are forced to activo = false on upload and must be manually activated by an admin before customers can see them.