meta data for this page
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
en:design_guide_center [2020/11/28 02:58] JSCAD Editor created |
en:design_guide_center [2021/11/07 07:33] (current) JSCAD Editor |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ==== Center ==== | ==== Center ==== | ||
| - | Shapes can be centered about the X, Y or Z axis. | + | Shapes can be centered about the X, Y or Z axis, or centered relative to a given point. |
| - | //Note: The center of a shape is calculated as the midpoint between | + | //Note: The center of a shape is calculated as the midpoint between |
| + | |||
| + | Defaults: | ||
| + | * axes : [true, true, true] | ||
| + | * relativeTo : [0, 0, 0] | ||
| <code javascript> | <code javascript> | ||
| - | let obj = sphere(5) | + | const myshape |
| - | obj = center(true,cube(), obj) // center the objects | + | let newshape |
| - | obj = center([true, | + | newshape |
| + | newshape = center({relativeTo: | ||
| </ | </ | ||
| - | The CSG library functions can also be used. //NOTE: Deprecated in the V2 API// | + | There are also simple versions of this function to center |
| <code javascript> | <code javascript> | ||
| - | cube().center(true) // center the object across all axes | + | const myshape = sphere({radius: 5}) |
| - | cube().center([true, | + | let newshape = centerX(myshape) |
| + | newshape = centerY(newshape) | ||
| + | newshape = centerZ(newshape) | ||
| </ | </ | ||
| - | |||