{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "fx-hexagon",
  "type": "registry:component",
  "title": "Hexagon",
  "description": "A tiled hexagon outline field generated for its box",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-components.json",
    "https://gpuixui.sudokw.com/gpuix-motion.json"
  ],
  "files": [
    {
      "path": "packages/fx/src/hexagon.tsx",
      "target": "@ui/gpuixui/fx/hexagon.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { Props } from \"@gpuix/react\";\nimport type { StateStyle } from \"@gpuix/react/floating\";\nimport type { MotionLevel } from \"../motion/timing.js\";\nimport type { ReactNode } from \"react\";\nimport { hexagonField, hexagonRadius, hexagonStroke } from \"./hexagon/logic.js\";\nimport {\n  PatternField,\n  type PatternFieldState,\n  useTheme,\n} from \"../components/authoring.js\";\n\nexport type HexagonState = PatternFieldState;\n\nexport interface HexagonProps extends Omit<Props, \"children\" | \"style\"> {\n  readonly radius?: number;\n\n  readonly stroke?: number;\n\n  readonly color?: string;\n\n  readonly breatheMs?: number;\n\n  readonly level?: MotionLevel;\n\n  readonly className?: string;\n\n  readonly style?: StateStyle<HexagonState>;\n\n  readonly children?: ReactNode;\n}\n\nexport const Hexagon = ({\n  radius,\n  stroke,\n  color,\n  breatheMs,\n  level,\n  className,\n  style,\n  children,\n  ...rest\n}: HexagonProps) => {\n  const theme = useTheme();\n  const ink = color ?? theme.colors.border;\n\n  return (\n    <PatternField\n      {...rest}\n      markup={(box) =>\n        hexagonField({\n          ...box,\n          radius: radius ?? hexagonRadius,\n          stroke: stroke ?? hexagonStroke,\n        }).markup\n      }\n      color={ink}\n      breatheMs={breatheMs}\n      level={level}\n      className={className}\n      style={style}\n    >\n      {children}\n    </PatternField>\n  );\n};\n\nexport const hexagonMeta = {\n  name: \"Hexagon\",\n  tier: 5,\n  status: \"done\",\n  gpuixSupport: \"partial\",\n  limitations: [\n    \"the field is one generated `<svg source>` path painted as a mask in the element's colour: the runtime paints a markup as one tint, so a multi-colour field is several elements, and a per-shape palette inside one element is not available\",\n    \"the view box is generated for the measured box because a `<svg>` path is scaled by the element's width alone and its centred content area is not clipped by the element (the `svg-pattern` probe); a caller that resizes the box re-generates the grid\",\n    \"the grid cannot rotate, pan or scale: the runtime has no `transform` (upstream issue #102), so the only motion is a slow opacity breath\",\n    \"a radius small enough to exceed the cell cap is grown to the radius the cap allows, and the field reports the drawn radius from its logic rather than dropping cells\",\n    \"the field measures its own box, so the caller must bound it; before the first layout it paints nothing\",\n    \"the field publishes no accessibility node and takes no pointer input: name and describe the content it sits behind\",\n    \"a hidden field keeps breathing (the runtime exposes no visibility query), so unmount it when it is off screen\",\n  ],\n  docs: \"docs/hexagon.mdx\",\n  example: \"examples/hexagon.example.tsx\",\n  testFile: \"src/behaviour/hexagon.test.tsx\",\n} as const;\n"
    },
    {
      "path": "packages/fx/src/hexagon/logic.ts",
      "target": "@ui/gpuixui/fx/hexagon/logic.ts",
      "type": "registry:lib",
      "content": "import * as Arr from \"effect/Array\";\nimport {\n  tenth,\n  paintableBox,\n  svgPatternMarkup,\n  type PatternBox,\n} from \"../../components/authoring.js\";\n\nexport const hexagonRadius = 30;\n\nexport const hexagonMinRadius = 10;\nexport const hexagonMaxRadius = 160;\n\nexport const hexagonStroke = 1;\n\nexport const hexagonMaxStroke = 6;\n\nexport const hexagonMaxCells = 900;\n\nconst cellArea = (radius: number): number => 2.598_076_211 * radius * radius;\n\nexport const hexagonRadiusOf = (radius: number): number =>\n  Number.isFinite(radius) && radius > 0\n    ? Math.min(Math.max(radius, hexagonMinRadius), hexagonMaxRadius)\n    : hexagonRadius;\n\nexport const hexagonStrokeOf = (stroke: number): number =>\n  Number.isFinite(stroke) && stroke > 0\n    ? Math.min(Math.max(stroke, 0.5), hexagonMaxStroke)\n    : hexagonStroke;\n\nexport interface HexagonFieldOptions extends PatternBox {\n  readonly radius: number;\n  readonly stroke: number;\n}\n\nexport interface HexagonField {\n  readonly markup: string;\n  readonly cells: number;\n\n  readonly radius: number;\n}\n\nconst radiusForCap = (box: PatternBox): number =>\n  Math.sqrt((box.width * box.height) / (hexagonMaxCells * cellArea(1)));\n\nconst gridOf = (\n  box: PatternBox,\n  radius: number,\n): {\n  readonly columns: number;\n  readonly rows: number;\n  readonly horizontal: number;\n  readonly vertical: number;\n} => {\n  const horizontal = radius * 1.5;\n  const vertical = Math.sqrt(3) * radius;\n  return {\n    columns: Math.ceil(box.width / horizontal) + 1,\n    rows: Math.ceil(box.height / vertical) + 1,\n    horizontal,\n    vertical,\n  };\n};\n\nconst cellsOf = (box: PatternBox, radius: number): number => {\n  const { columns, rows } = gridOf(box, radius);\n  return columns * rows;\n};\n\nconst fitToCap = (box: PatternBox, radius: number): number =>\n  cellsOf(box, radius) <= hexagonMaxCells || radius >= hexagonMaxRadius\n    ? radius\n    : fitToCap(box, Math.min(radius * 1.1, hexagonMaxRadius));\n\nconst hexagonPath = (cx: number, cy: number, radius: number): string => {\n  const vertices = Arr.map(Arr.range(0, 5), (vertex) => {\n    const angle = (Math.PI / 3) * vertex;\n    const command = vertex === 0 ? \"M\" : \"L\";\n    return `${command} ${tenth(cx + radius * Math.cos(angle))} ${tenth(cy + radius * Math.sin(angle))}`;\n  });\n  return `${Arr.join(vertices, \" \")} Z`;\n};\n\nexport const hexagonField = ({\n  width,\n  height,\n  radius,\n  stroke,\n}: HexagonFieldOptions): HexagonField => {\n  if (!paintableBox({ width, height })) {\n    return { markup: \"\", cells: 0, radius: hexagonRadiusOf(radius) };\n  }\n\n  const box = { width, height };\n  const requested = Math.max(hexagonRadiusOf(radius), radiusForCap(box));\n  const drawn = fitToCap(box, requested);\n  const { columns, rows, horizontal, vertical } = gridOf(box, drawn);\n\n  const paths = Arr.flatMap(Arr.range(0, columns - 1), (column) => {\n    const cx = drawn + column * horizontal;\n    const offset = column % 2 === 1 ? vertical / 2 : 0;\n    return Arr.map(Arr.range(0, rows - 1), (row) =>\n      hexagonPath(cx, vertical / 2 + row * vertical + offset, drawn),\n    );\n  });\n\n  return {\n    markup: svgPatternMarkup(\n      box,\n      Arr.join(paths, \" \"),\n      hexagonStrokeOf(stroke),\n    ),\n    cells: Arr.length(paths),\n    radius: drawn,\n  };\n};\n"
    }
  ],
  "docs": "[Hexagon](https://gpuixui.sudokw.com/effects/hexagon) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/effects/hexagon",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}