Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show code examples on usage site #90

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion examples/array-based-subtraction.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Example from "src/Example"
import { designCodeArray } from "src/designCode"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { Colorize, Cuboid, Sphere, Subtract } from "../lib/jscad-fns"
import { Cuboid, Subtract } from "../lib/jscad-fns"

export default () => (
<Example designCode={designCodeArray}>
<JsCadFixture zAxisUp showGrid>
<Subtract>
<Cuboid size={[10, 5, 2]} />
Expand All @@ -10,4 +13,5 @@ export default () => (
))}
</Subtract>
</JsCadFixture>
</Example>
)
9 changes: 7 additions & 2 deletions examples/circle.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Circle } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { designCodeCircle } from "src/designCode";
import Example from "src/Example";
import { Circle } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";


export default () => (
<Example designCode={designCodeCircle}>
<JsCadFixture>
<Circle radius={10} />
</JsCadFixture>
</Example>
)
4 changes: 4 additions & 0 deletions examples/colorize.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import Example from "src/Example"
import { designCodeColorizeCube } from "src/designCode"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { Colorize, Cube } from "../lib/jscad-fns"

export default () => (
<Example designCode={designCodeColorizeCube}>
<JsCadFixture>
<Colorize color={"red"}>
<Cube size={10} />
</Colorize>
</JsCadFixture>
</Example>
)
8 changes: 6 additions & 2 deletions examples/cone.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { CylinderElliptic } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { designCodeCone } from "src/designCode";
import Example from "src/Example";
import { CylinderElliptic } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";

export default () => (
<Example designCode={designCodeCone}>
<JsCadFixture wireframe>
<CylinderElliptic
height={5}
Expand All @@ -14,4 +17,5 @@ export default () => (
center={[0, 5, 5]}
/>
</JsCadFixture>
</Example>
)
8 changes: 6 additions & 2 deletions examples/cube.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Cube } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { designCodeCube } from "src/designCode";
import Example from "src/Example";
import { Cube } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";

export default () => (
<Example designCode={designCodeCube}>
<JsCadFixture>
<Cube size={10} color="orange" center={[0, 0, 10]} />
</JsCadFixture>
</Example>
)
8 changes: 6 additions & 2 deletions examples/cuboid.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Cuboid } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { designCodeCuboid } from "src/designCode";
import Example from "src/Example";
import { Cuboid } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";

export default () => (
<Example designCode={designCodeCuboid}>
<JsCadFixture zAxisUp showGrid>
<Cuboid color="blue" offset={{ x: 0, y: 0, z: 0 }} size={[15, 10, 10]} />
</JsCadFixture>
</Example>
)
8 changes: 6 additions & 2 deletions examples/custom-sphere.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Sphere } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { designCodeCustomSphere } from "src/designCode";
import Example from "src/Example";
import { Sphere } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";

export default () => (
<Example designCode={designCodeCustomSphere}>
<JsCadFixture wireframe>
<Sphere radius={10} segments={64} />
</JsCadFixture>
</Example>
)
8 changes: 6 additions & 2 deletions examples/custom-torus.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Torus } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { designCodeCustomTorus } from "src/designCode";
import Example from "src/Example";
import { Torus } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";

export default () => (
<Example designCode={designCodeCustomTorus}>
<JsCadFixture wireframe>
<Torus
innerRadius={15}
Expand All @@ -13,4 +16,5 @@ export default () => (
startAngle={0}
/>
</JsCadFixture>
</Example>
)
10 changes: 7 additions & 3 deletions examples/custom.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { booleans, primitives } from "@jscad/modeling"
import { Custom } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { booleans, primitives } from "@jscad/modeling";
import { designCodeCustom } from "src/designCode";
import Example from "src/Example";
import { Custom } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";

const cube = primitives.cube({ size: 10 })
const sphere = primitives.sphere({ radius: 6, segments: 32 })

const intersected = booleans.subtract(cube, sphere)

export default () => (
<Example designCode={designCodeCustom}>
<JsCadFixture>
<Custom geometry={intersected} />
</JsCadFixture>
</Example>
)
8 changes: 6 additions & 2 deletions examples/cylinder.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Cylinder } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { designCodeCylinder } from "src/designCode";
import Example from "src/Example";
import { Cylinder } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";

export default () => (
<Example designCode={designCodeCylinder}>
<JsCadFixture showGrid zAxisUp>
<Cylinder
radius={5}
Expand All @@ -12,4 +15,5 @@ export default () => (
/>
<Cylinder radius={5} height={10} color="#F7E8AA" center={[20, 0, 0]} />
</JsCadFixture>
</Example>
)
8 changes: 6 additions & 2 deletions examples/ellipsoid.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Ellipsoid } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { designCodeEllipsoid } from "src/designCode";
import Example from "src/Example";
import { Ellipsoid } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";

export default () => (
<Example designCode={designCodeEllipsoid}>
<JsCadFixture wireframe>
<Ellipsoid radius={[15, 10, 10]} color="brown" center={[0, 0, 10]} />
</JsCadFixture>
</Example>
)
10 changes: 7 additions & 3 deletions examples/extrude-from-slices.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ExtrudeFromSlices } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import jscad from "@jscad/modeling"
import jscad from "@jscad/modeling";
import { designCodeExtrudeFromSlices } from "src/designCode";
import Example from "src/Example";
import { ExtrudeFromSlices } from "../lib";
import { JsCadFixture } from "../lib/components/jscad-fixture";

const { bezier } = jscad.curves
const { circle, line, polygon, rectangle, roundedRectangle, star } =
Expand All @@ -20,6 +22,7 @@ const xCurve = bezier.create([1, 1.8, 0.4, 1])
const yCurve = bezier.create([1, 1.8, 0.5])

export default () => (
<Example designCode={designCodeExtrudeFromSlices}>
<JsCadFixture zAxisUp showGrid>
<ExtrudeFromSlices
numberOfSlices={10}
Expand Down Expand Up @@ -53,4 +56,5 @@ export default () => (
}}
/>
</JsCadFixture>
</Example>
)
11 changes: 8 additions & 3 deletions examples/extrude-linear.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { ExtrudeLinear } from "../lib/jscad-fns"
import { Polygon } from "../lib/jscad-fns/polygon"
import { designCodeExtrudeLinear } from "src/designCode";
import Example from "src/Example";
import { JsCadFixture } from "../lib/components/jscad-fixture";
import { ExtrudeLinear } from "../lib/jscad-fns";
import { Polygon } from "../lib/jscad-fns/polygon";

export default () => (
<Example designCode={designCodeExtrudeLinear}>

<JsCadFixture>
<ExtrudeLinear height={2} color="lightgreen" center={[0, 0, 4]}>
<Polygon
Expand All @@ -18,4 +22,5 @@ export default () => (
/>
</ExtrudeLinear>
</JsCadFixture>
</Example>
)
4 changes: 4 additions & 0 deletions examples/extrude-rectangular.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { designCodeExtrudeRectangular } from "src/designCode"
import Example from "src/Example"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { ExtrudeRectangular } from "../lib/jscad-fns"
import { Polygon } from "../lib/jscad-fns/polygon"

export default () => (
<Example designCode={designCodeExtrudeRectangular}>
<JsCadFixture>
<ExtrudeRectangular
size={10}
Expand All @@ -23,4 +26,5 @@ export default () => (
/>
</ExtrudeRectangular>
</JsCadFixture>
</Example>
)
4 changes: 4 additions & 0 deletions examples/high-geodesic-sphere.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { designCodeHighGeodesicsphere } from "src/designCode"
import Example from "src/Example"
import { GeodesicSphere } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"

export default () => (
<Example designCode={designCodeHighGeodesicsphere}>
<JsCadFixture wireframe>
<GeodesicSphere
radius={10}
Expand All @@ -10,4 +13,5 @@ export default () => (
center={[10, 5, 0]}
/>
</JsCadFixture>
</Example>
)
4 changes: 4 additions & 0 deletions examples/hull-chain.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { designCodeHullChain } from "src/designCode"
import Example from "src/Example"
import { Cuboid, Ellipsoid, HullChain } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"

export default () => (
<Example designCode={designCodeHullChain}>
<JsCadFixture>
<HullChain color="lightgreen" center={[0, 0, -10]}>
<Cuboid size={[10, 10, 10]} />
<Ellipsoid radius={[10, 10, 12]} center={[0, 0, 10]} />
<Cuboid size={[10, 10, 10]} center={[0, 0, 20]} />
</HullChain>
</JsCadFixture>
</Example>
)
6 changes: 5 additions & 1 deletion examples/hull.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Cuboid, Ellipsoid, Hull, Translate } from "../lib"
import { designCodeHull } from "src/designCode"
import Example from "src/Example"
import { Cuboid, Ellipsoid, Hull } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"

export default () => (
<Example designCode={designCodeHull}>
<JsCadFixture>
<Hull color="lightblue" center={[0, -5, -10]}>
<Cuboid size={[10, 10, 10]} />
<Ellipsoid radius={[10, 10, 10]} center={[0, 0, 15]} />
</Hull>
</JsCadFixture>
</Example>
)
4 changes: 4 additions & 0 deletions examples/low-geodesic-sphere.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { designCodeGeodesicSphere } from "src/designCode"
import Example from "src/Example"
import { GeodesicSphere } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"

export default () => (
<Example designCode={designCodeGeodesicSphere}>
<JsCadFixture wireframe>
<GeodesicSphere radius={10} frequency={6} />
</JsCadFixture>
</Example>
)
6 changes: 5 additions & 1 deletion examples/partial-cylindrical-elliptic.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { designCodeCylinderElliptic } from "src/designCode"
import Example from "src/Example"
import { CylinderElliptic } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"

export default () => (
<JsCadFixture wireframe>
<Example designCode={designCodeCylinderElliptic}>
<JsCadFixture wireframe>
<CylinderElliptic
height={6}
startRadius={[1, 2]}
Expand All @@ -12,4 +15,5 @@ export default () => (
endAngle={Math.PI / 2}
/>
</JsCadFixture>
</Example>
)
4 changes: 4 additions & 0 deletions examples/polygon.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { designCodePolygon } from "src/designCode"
import Example from "src/Example"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { Polygon } from "../lib/jscad-fns/polygon"

export default () => (
<Example designCode={designCodePolygon}>
<JsCadFixture>
<Polygon
points={[
Expand All @@ -15,4 +18,5 @@ export default () => (
]}
/>
</JsCadFixture>
</Example>
)
4 changes: 4 additions & 0 deletions examples/project.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { designCodeProject } from "src/designCode"
import Example from "src/Example"
import { JsCadFixture } from "../lib/components/jscad-fixture"
import { Project } from "../lib/jscad-fns"
import { Polygon } from "../lib/jscad-fns/polygon"

export default () => (
<Example designCode={designCodeProject}>
<JsCadFixture>
<Project axis={[0, 0, 1]} origin={[0, 0, 0]}>
<Polygon
Expand All @@ -18,4 +21,5 @@ export default () => (
/>
</Project>
</JsCadFixture>
</Example>
)
5 changes: 5 additions & 0 deletions examples/rectangle.fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { designCodeRectangle } from "src/designCode"
import Example from "src/Example"
import { Rectangle } from "../lib"
import { JsCadFixture } from "../lib/components/jscad-fixture"


export default () => (
<Example designCode={designCodeRectangle}>
<JsCadFixture>
<Rectangle size={[10, 20]} />
</JsCadFixture>
</Example>
)
Loading