meta data for this page
  •  

Differences

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

Link to this comparison view

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 minimal and maximum points.//+//Note: The center of a shape is calculated as the midpoint between minimum and maximum points.// 
 + 
 +Defaults: 
 +  * axes : [true, true, true] 
 +  * relativeTo : [0, 0, 0]
  
 <code javascript> <code javascript>
-let obj = sphere(5) +const myshape = sphere({radius: 5}
-obj = center(true,cube(), obj)  // center the objects across all axes +let newshape = center({}myshape)  // center the shape across all axes 
-obj = center([true, true, false], obj)  // 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({relativeTo: [5, 6, 7]}, myshape)  // center the shape relative to the given point
 </code> </code>
  
-The CSG library functions can also be used. //NOTE: Deprecated in the V2 API//+There are also simple versions of this function to center the shape about the origin.
  
 <code javascript> <code javascript>
-cube().center(true               // center the object across all axes +const myshape = sphere({radius: 5}) 
-cube().center([true,true,false]  // center the object across only X and Y axis+let newshape = centerX(myshape
 +newshape = centerY(newshape) 
 +newshape = centerZ(newshape)
 </code> </code>
-