How to use the @jscad/modeling.expand function in @jscad/modeling

To help you get started, we’ve selected a few @jscad/modeling examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jscad / OpenJSCAD.org / packages / examples / core / expansions / expand.js View on Github external
const main = () => {
  // you can expand 2d paths
  const points = [
    [10, 0],
    [9.510565162951535, 3.090169943749474],
    [8.090169943749475, 5.877852522924732],
    [5.877852522924732, 8.090169943749475],
    [3.0901699437494745, 9.510565162951535],
    [6.123233995736766e-16, 10]
  ]
  const path2Example = color('black',
    path2.fromPoints({ }, points) // it also works with ccw points ie points.reverse()
  )
  const expandedPath2 = expand({ delta: 2, corners: 'round', segments: 8 }, path2Example)

  // but also 2d geometry
  const geom2Example = geom2.fromPoints([[-8, -8], [8, -8], [8, 8], [-8, 8]])
  const expandedGeom2 = color('red',
    expand({ delta: 2, corners: 'round', segments: 8 }, geom2Example)
  )
  const contractedGeom2 = color('red',
    expand({ delta: -2, corners: 'round', segments: 8 }, geom2Example)
  )

  // aaand 3d geometry
  const geom3Example = color('black',
    cuboid()
  )
  const expandedGeom3 = color('red',
    expand({ delta: 2, corners: 'round', segments: 8 }, geom2Example)
github jscad / OpenJSCAD.org / packages / examples / core / expansions / expand.js View on Github external
// but also 2d geometry
  const geom2Example = geom2.fromPoints([[-8, -8], [8, -8], [8, 8], [-8, 8]])
  const expandedGeom2 = color('red',
    expand({ delta: 2, corners: 'round', segments: 8 }, geom2Example)
  )
  const contractedGeom2 = color('red',
    expand({ delta: -2, corners: 'round', segments: 8 }, geom2Example)
  )

  // aaand 3d geometry
  const geom3Example = color('black',
    cuboid()
  )
  const expandedGeom3 = color('red',
    expand({ delta: 2, corners: 'round', segments: 8 }, geom2Example)
  )
  const contractedGeom3 = color('red',
    expand({ delta: -2, corners: 'round', segments: 8 }, geom2Example)
  )

  return [
    path2Example,
    expandedPath2,
    //
    geom2Example,
    expandedGeom2,
    contractedGeom2,
    //
    geom3Example,
    expandedGeom3,
    contractedGeom3