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_rectangle [2020/11/28 02:50]
JSCAD Editor created
en:design_guide_rectangle [2022/04/13 07:16] (current)
rozek included "require" statements, corrected mistakes
Line 3: Line 3:
 A two dimensional shape made with four straight sides where all interior angles are right angles (90°). A two dimensional shape made with four straight sides where all interior angles are right angles (90°).
  
-{{ :wiki:mathisfun-rectangle.png?nolink |Rectangle}}+{{ :wiki:mathisfun-rectangle.png?nolink | Rectangle}} 
 //[[http://www.mathsisfun.com/geometry/rectangle.html|Learn about rectangles at MathIsFun.com]]// //[[http://www.mathsisfun.com/geometry/rectangle.html|Learn about rectangles at MathIsFun.com]]//
  
-The following show examples of creating rectangles. The radius specifies the size. Rectangles with different radius for X and Y axis can be specified by supplying an array of values.+The ''size'' specifies the size across X and Y axis. Rectangles can be created at a requested ''center''.
  
 Defaults: Defaults:
-  * radius 1 or [1,1+  * size : [22
-  * center : [0,0]+  * center : [0, 0]
  
 <code javascript> <code javascript>
-square(5);                                  /square 5 x 5 +const { rectangle } = require('@jscad/modeling').primitives 
-square([2,3]);                              // rectangle 2 x 3 + 
-square({size: [2,4], center: true});        // rectangle 2 x 4, centered on both X and Y axis+const myshape = rectangle({size: [3, 4]}
 +const myshape = rectangle({size: [3, 4], center: [5, 5]})
 </code> </code>
  
-The CSG library functions can also be used//NOTEDeprecated in the V2 API//+=== Square === 
 + 
 +{{ :wiki:mathisfun-square.png?nolink | Square}} 
 + 
 +The specialized square primitive also exists, but requires only one number value for all sides. 
 + 
 +Defaults: 
 +  * size : 2 
 +  * center [0, 0]
  
 <code javascript> <code javascript>
-CAG.rectangle({center: [0,0], radius: [510]})+const { square } = require('@jscad/modeling').primitives 
-CAG.roundedRectangle({center: [0,0], radius: [10, 50], roundradius1resolution4});+ 
 +const myshape = square({size: 3}) 
 +const myshape = square({size: 3, center: [55]}) 
 +</code> 
 + 
 +=== Rounded Rectangle === 
 + 
 +{{ :wiki:jscad-roundedRectangle.svg?nolink | Rectangle}} 
 + 
 +Rounded rectangles can be created by specifying a ''roundRadius'' for the corners. 
 + 
 +Defaults: 
 +  * size : [22] 
 +  * center : [00] 
 +  * roundedRadius: 0.2 
 +  * segments: 32 
 + 
 +<code javascript> 
 +const { roundedRectangle = require('@jscad/modeling').primitives 
 + 
 +const myshape = roundedRectangle({size: [1020], roundRadius: 2}) 
 +const myshape = roundedRectangle({size: [10, 20], roundRadius2, center: [5, 5]segments64})
 </code> </code>