How to use the @jscad/modeling.scale 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 / hulls / hullChain.js View on Github external
const main = () => {
  const shell = []
  const hexagon = []

  for (let i = 0; i < 12; i++) { // -- shell like
    const x = sin(i / 12 * 180) * 10
    const y = cos(i / 12 * 180) * 10
    shell.push(
      translate([x, y, 0], scale(6 - i / 2, circle())) // { center: true }
    )
  }

  const n = 6
  for (let i = 0; i < n; i++) { // -- hexagon chain hulled
    const x = sin(i / n * 360) * 10
    const y = cos(i / n * 360) * 10
    hexagon.push(
      translate([x, y, 0], circle())// { center: true }
    )
  }

  return [
    translate([-20, 0, 0],
      extrudeLinear({ height: 5 }, hullChain(shell))
    ),
github jscad / OpenJSCAD.org / packages / examples / core / transforms / transformations.js View on Github external
const main = () => {
  const testCube = cube()

  return [
    translate([0, 10, 0], testCube), // simple translation
    translate([10, 0, 0], rotate([10, 5, 0], testCube)), // translate + rotate
    translate([-10, 0, 0], scale([0.5, 0.5, 5], testCube)), // translate + scale
    transform([ // matrix transform
      cos(15), -sin(15), 0, 0,
      sin(15), cos(15), 0, 0,
      0, 0, 1, 1,
      0, 0, 0, 1
    ], testCube)
  ]
}
github jscad / OpenJSCAD.org / packages / examples / core / extrusions / extrudeLinear.js View on Github external
const main = () => {
  return [
    scale(3, extrudeLinear({ height: 10 }, circle({ r: 1, fn: 5, center: true }))),
    scale(3, extrudeLinear({ height: 10, twist: 90 }, rectangle({ size: [1, 2], center: true }))
      .translate([0, 5, 0])),
    scale(3, extrudeLinear({ height: 10, twist: -500, slices: 50 }, translate([2, 0, 0], circle({ r: 1, fn: 8, center: true })))
      .translate([0, -6, 0])),
    scale(3, extrudeLinear({ height: 20, twist: -90, center: true }, polygon([[0, 0], [4, 1], [1, 1], [1, 4]]))
      .translate([0, -13, 0]))
  ]
}