Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 38 additions & 11 deletions docs/elements/board.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ Learn more about [the Autorouting API here](../web-apis/autorouting-api.mdx)

### Custom Board Outlines

You can specify a custom outline for your board by passing an `outline` prop.
The PCB you get will have this outline cut out, this is great when you want a
board that's not a rectangle!
<CircuitPreview defaultView="pcb" code={`
You can specify a custom outline for your board by passing an `outline` prop.
The PCB you get will have this outline cut out, this is great when you want a
board that's not a rectangle!

<CircuitPreview defaultView="pcb" code={`

export default () => (
<board
Expand Down Expand Up @@ -155,12 +155,39 @@ export default () => (
// https://github.com/tscircuit/core/issues/564
width="50mm"
height="50mm"
/>
)

`} />

### Offseting the board origin
/>
)

`} />

If you'd like a circular PCB, you can generate evenly spaced points around a
circle and pass them as the outline. In the example below a `radiusMm` variable
controls the size of the board—changing it automatically updates both the
outline points and the board's bounding box:

<CircuitPreview defaultView="pcb" code={`
import { range } from "@tscircuit/math-utils"

const steps = 120
const radiusMm = 12

export default () => (
<board
width={`\${radiusMm * 2}mm`}
height={`\${radiusMm * 2}mm`}
Comment on lines +176 to +177

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Escape nested template literals in CircuitPreview snippet

The new circular board example embeds template literal syntax inside the string passed to code={ without escaping the inner backticks. The sequences width={ and height={ at this location close the outer template literal, so the MDX file is no longer valid JavaScript/JSX and Docusaurus will fail to compile the page. The inner template strings should escape their backticks (e.g., width={\${radiusMm * 2}mm`}) so the entire example remains inside the code` string.

Useful? React with 👍 / 👎.

outline={range(steps).map((step) => {
const angle = (step / steps) * Math.PI * 2

return {
x: Math.cos(angle) * radiusMm,
y: Math.sin(angle) * radiusMm,
}
})}
/>
)
`} />

### Offseting the board origin

`width` and `height` set the board's bounding box (and thus the `pcbX`/`pcbY`
coordinate system) even when you're using a custom outline. Add
Expand Down
Loading