Smart Component 07
Grids.
Grids turn a Hole or Green graphic into a visual measuring surface without baking lines into the downloadable image. The full-image scope and green-center origin are the defaults. Maximum dimensions aligns to mapped measurement geometry. Green front uses the exact resolved Green composition bearing, including approach, north, approach-edge, and explicit rotation choices, while beginning depth spacing at the front green extent. Green and Green buffer scopes return only final clipped SVG segments and optional fade stops.
Usage
Add the grids to a graphic.
Include the component in the initial mount call, reconcile it through view.setSmartComponents, or append it with view.addSmartComponent. Types may repeat. Give repeated instances stable id values to style, show, hide, move, reset, or remove one instance independently. The selected Smart Component type, instance ID, render receipt, and protected selection options such as yardages, grid spacing, coverage, measured origin, buffer distance, detail, limits, or targets are sent to the overlay service. Marker-image origins, images, presentation styles, supported labels, and movement remain local.
const view = await caddie.mount(container, graphicRequest, [
{
type: "grids",
spacingYards: 5,
scope: "image",
origin: "green-center",
detailed: true,
style: {
strokeColor: "#FFFFFF",
strokeWidth: 2,
detailStrokeWidth: 1,
strokeStyle: "solid",
opacity: 0.65,
showLabels: true,
labelEveryX: 2,
labelEveryY: 1,
labelMode: "sticky",
labelEdges: ["left", "bottom"],
},
},
]);
// Use measured green axes and extend past the putting surface.
await view.setSmartComponents([{
type: "grids",
spacingYards: 5,
scope: "green-buffer",
origin: "maximum-dimensions",
bufferYards: 7.5,
detailed: true,
style: { strokeColor: "#FFFFFF", opacity: 0.45 },
}]);
// Presentation-only changes remain local.
view.setSmartComponentStyle({
type: "grids",
style: { strokeColor: "#00D5FF", opacity: 0.8, showHorizontal: true, showVertical: true, showLabels: true, labelMode: "gutter", labelEdges: ["top", "right", "bottom", "left"] },
});Defaults
Built-in presentation.
Component options
Configure behavior and presentation.
| Option | Type | Default | Description |
|---|---|---|---|
| type | "grids" | Required | Requests a measured grid for the selected hole or green. |
| id | string | Automatic | Optional stable 1–64 character instance ID using letters, numbers, underscores, or hyphens. Use IDs to independently control repeated Smart Components of the same type. |
| spacingYards | integer | 5 | Primary whole-yard box spacing from 1 through 50. |
| scope | "image" | "green" | "green-buffer" | "image" | Covers the image, clips to the putting surface, or clips to a metric green buffer with faded exposed tips. |
| origin | "green-center" | "maximum-dimensions" | "green-front" | "green-center" | Uses image-aligned axes through green center, orthogonalized mapped depth/width axes, or the Green graphic's resolved composition axes with depth spacing beginning at the front green extent. Protected modes safely fall back to green center. |
| bufferYards | number | 7.5 | Green-buffer only. Extends the protected surface from 1 through 25 yards before clipping and fading line tips. |
| detailed | boolean | false | Adds adaptive 1-, 2-, 5-, 10-, 20-, or 25-yard detail lines that divide each primary box evenly. |
| style.strokeColor | GraphicColor | "#FFFFFF" | Grid-line color applied locally by the SVG renderer. |
| style.strokeWidth | number | 2 | Primary non-scaling SVG line width from 1 through 8 image pixels. |
| style.detailStrokeWidth | number | 1 | Width of adaptive detail subdivision lines. |
| style.strokeStyle | "solid" | "dashed" | "dotted" | "dash-dot" | "solid" | Visible SVG stroke pattern. |
| style.opacity | number | 0.65 | Grid-line opacity from 0.05 through 1. Labels and paper gutters remain solid. |
| style.showHorizontal | boolean | true | Shows the width-running grid-line family and updates immediately in the local SVG. |
| style.showVertical | boolean | true | Shows the depth-running grid-line family and updates immediately in the local SVG. |
| style.showLabels | boolean | false | Shows signed labels for primary lines on the selected photo edges. |
| style.labelEvery | positive integer | 1 | Labels every Nth primary grid line without hiding any lines. The cadence is anchored at zero, so 2 on a 5-yard grid shows ..., -20, -10, 0, 10, 20, ... . |
| style.labelEveryX | positive integer | style.labelEvery | Overrides cadence for vertical grid lines labeled on the top and bottom edges. |
| style.labelEveryY | positive integer | style.labelEvery | Overrides cadence for horizontal grid lines labeled on the left and right edges. |
| style.labelMode | "sticky" | "gutter" | "sticky" | Uses edge-flush pills or solid paper-theme edge bands. |
| style.labelEdges | Array<"top" | "right" | "bottom" | "left"> | ["left"] | Selects one through four unique edges. Left/right label horizontal lines; top/bottom label vertical lines. Gutters omit labels too close to either end of the graphic, even with a single edge selected. Overlapping corner labels favor the left/right scale. |
| style.labelPosition | "sticky-left" | "sticky-right" | "gutter-left" | "gutter-right" | "gutters" | "sticky-left" | Deprecated compatibility shortcut. Prefer labelMode and labelEdges for arbitrary edge combinations. |
| style.labelSize | integer | 16 | Positive whole-number edge-label text size in image pixels with no upper limit. |
| style.labelColor | GraphicColor | "#FFFFFF" | Sticky-pill text color. Gutter text automatically contrasts with the paper theme. |
| style.labelBackgroundColor | GraphicColor | "#07110D" | Sticky-pill background color. Gutters always use the graphic paper-theme color. |
| style.labelXPadding | number | 8 | Horizontal label padding from 0 through 32 image pixels. |
| style.labelYPadding | number | 6 | Vertical label padding from 0 through 20 image pixels. |
Behavior
Important implementation details.
- Green-center origin uses image-aligned axes through the protected center-green pixel. Maximum-dimensions uses the mapped depth axis and preferred maximum-width cross-section. Green-front finds the approach-facing polygon extent along the mapped depth axis for front/back spacing while preserving center green for left/right spacing. Protected modes fall back to green center when required geometry is unavailable.
- Every primary line uses the same width, including lines passing through the origin. Detailed mode selects a nice-number interval that divides each primary box evenly—for example 5→1, 10→2, 20→5, and 50→10 yards. Horizontal and vertical visibility are independent local presentation controls. Left/right edges label horizontal lines with positive values above and negative values below. Top/bottom edges label vertical lines with negative values left and positive values right. Every target/origin line is 0 yd. Sticky mode uses pills; gutter mode uses compact signed values in any selected solid paper-theme bands. Gutter labels too close to either end of the graphic are omitted, even with a single edge selected. Perpendicular gutters also omit covered values and suppress the top/bottom value when padded corner labels overlap.
- Metric vector spacing preserves equal ground-yard measurements even when measured axes are rotated or artifact scale differs by direction.
- Changing spacing, scope, origin, buffer distance, or detail requests new instructions against the cached sidecar. Changing color, widths, pattern, opacity, visibility, or label presentation is an immediate local DOM update.
- Green scope is clipped to the measured putting surface. Green buffer expands that shape by the requested ground-yard distance and sends only final segment fade fractions. The browser never receives either polygon, measured dimension geometry, the pixel-to-meter transform, geographic coordinates, or the internal sidecar.
- The component is available on Hole and Green graphics. Course-wide scope is not included in this version.
- Grids are measurement drawings and remain locked rather than movable.