meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:design_guide_center [2020/12/01 00:34]
JSCAD Editor
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 minimal and maximum points.//+//Note: The center of a shape is calculated as the midpoint between minimum and maximum points.//
  
 Defaults: Defaults:
   * axes : [true, true, true]   * axes : [true, true, true]
-  * center : [0, 0, 0]+  * relativeTo : [0, 0, 0]
  
 <code javascript> <code javascript>
-let myshape = sphere({radius: 5})+const myshape = sphere({radius: 5})
 let newshape = center({}, myshape)  // center the shape across all axes let newshape = center({}, myshape)  // center the shape across all axes
 newshape = center({axes: [true, true, false]}, myshape)  // center the object across only X and Y axis newshape = center({axes: [true, true, false]}, myshape)  // center the object across only X and Y axis
-newshape = center({center: [5, 6, 7]}, myshape)  // center the shape at the given center+newshape = center({relativeTo: [5, 6, 7]}, myshape)  // center the shape relative to the given point
 </code> </code>
  
-There are also simple version of this function to center about only one axis.+There are also simple versions of this function to center the shape about the origin.
  
 <code javascript> <code javascript>
-let myshape = sphere({radius: 5})+const myshape = sphere({radius: 5})
 let newshape = centerX(myshape) let newshape = centerX(myshape)
 newshape = centerY(newshape) newshape = centerY(newshape)
 newshape = centerZ(newshape) newshape = centerZ(newshape)
 </code> </code>