Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions docs/web-apis/image-generation-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ For 3D renderings of PCBs, use the dedicated endpoints:
### Basic Usage

```
https://svg.tscircuit.com/?svg_type=3d&code=<compressed-code>
https://svg.tscircuit.com/?svg_type=3d&background_color=%23ffffff&code=<compressed-code>
```

### Parameters
Expand All @@ -153,7 +153,7 @@ import React from 'react';
import { createSvgUrl } from '@tscircuit/create-snippet-url';

const Circuit3DViewer = ({ circuitCode }) => {
const viewerUrl = createSvgUrl(circuitCode, "3d");
const viewerUrl = `${createSvgUrl(circuitCode, "3d")}&background_color=%23ffffff`;

return (
<iframe
Expand Down
5 changes: 3 additions & 2 deletions src/components/CircuitPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default function CircuitPreview({
)
const threeDUrl = useMemo(() => {
if (browser3dView && typeof fsMapOrCode === "string") {
return createPngUrl(fsMapOrCode, "3d")
return `${createPngUrl(fsMapOrCode, "3d")}&background_color=%23ffffff`
}

// If fsMap is provided, use fs_map parameter instead of code
Expand All @@ -183,6 +183,7 @@ export default function CircuitPreview({
png_width: "800",
png_height: "600",
show_infinite_grid: "true",
background_color: "%23ffffff",
fs_map: encodeURIComponent(encodedFsMap),
main_component_path: mainComponentPath
? encodeURIComponent(mainComponentPath)
Expand All @@ -198,7 +199,7 @@ export default function CircuitPreview({
const encodedCode = encodeURIComponent(
getCompressedBase64SnippetString(code),
)
return `https://svg.tscircuit.com/?svg_type=3d&format=png&png_width=800&png_height=600&show_infinite_grid=true&code=${encodedCode}`
return `https://svg.tscircuit.com/?svg_type=3d&format=png&png_width=800&png_height=600&show_infinite_grid=true&background_color=%23ffffff&code=${encodedCode}`
}, [code, browser3dView, fsMap])

const shouldSplitCode = _splitView && windowSize !== "mobile"
Expand Down