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.

type: "grids"component: caddie-gridsProtected placement

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.

SubjectsHole · Green
CoverageEntire image
OriginGreen center
Optional scopeGreen surface only
Buffered scopeGreen + 7.5 yards · faded tips
Primary spacing5 yards
Detailed gridOff · adaptive even subdivisions
Edge labelsOff · any edge · sticky or gutter
WidthsPrimary 2px · detail 1px
MovementLocked

Component options

Configure behavior and presentation.

OptionTypeDefaultDescription
type"grids"RequiredRequests a measured grid for the selected hole or green.
idstringAutomaticOptional stable 1–64 character instance ID using letters, numbers, underscores, or hyphens. Use IDs to independently control repeated Smart Components of the same type.
spacingYardsinteger5Primary 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.
bufferYardsnumber7.5Green-buffer only. Extends the protected surface from 1 through 25 yards before clipping and fading line tips.
detailedbooleanfalseAdds adaptive 1-, 2-, 5-, 10-, 20-, or 25-yard detail lines that divide each primary box evenly.
style.strokeColorGraphicColor"#FFFFFF"Grid-line color applied locally by the SVG renderer.
style.strokeWidthnumber2Primary non-scaling SVG line width from 1 through 8 image pixels.
style.detailStrokeWidthnumber1Width of adaptive detail subdivision lines.
style.strokeStyle"solid" | "dashed" | "dotted" | "dash-dot""solid"Visible SVG stroke pattern.
style.opacitynumber0.65Grid-line opacity from 0.05 through 1. Labels and paper gutters remain solid.
style.showHorizontalbooleantrueShows the width-running grid-line family and updates immediately in the local SVG.
style.showVerticalbooleantrueShows the depth-running grid-line family and updates immediately in the local SVG.
style.showLabelsbooleanfalseShows signed labels for primary lines on the selected photo edges.
style.labelEverypositive integer1Labels 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.labelEveryXpositive integerstyle.labelEveryOverrides cadence for vertical grid lines labeled on the top and bottom edges.
style.labelEveryYpositive integerstyle.labelEveryOverrides 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.labelEdgesArray<"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.labelSizeinteger16Positive whole-number edge-label text size in image pixels with no upper limit.
style.labelColorGraphicColor"#FFFFFF"Sticky-pill text color. Gutter text automatically contrasts with the paper theme.
style.labelBackgroundColorGraphicColor"#07110D"Sticky-pill background color. Gutters always use the graphic paper-theme color.
style.labelXPaddingnumber8Horizontal label padding from 0 through 32 image pixels.
style.labelYPaddingnumber6Vertical 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.
Protected course dataThe response contains only final visible line segments, their primary/detail kind, resolved origin name, and optional buffered-tip fade fractions. Green coverage, buffers, and measured dimension axes are resolved server-side. The response excludes protected polygons and cross-sections, longitude, latitude, course geometry, affine transforms, source control points, and the internal render sidecar.