How to use the polygon-generator.coordinates function in polygon-generator

To help you get started, we’ve selected a few polygon-generator 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 cruise-automation / webviz / docs / src / jsx / commands / FilledPolygons.js View on Github external
function Example() {
  const range = useRange();
  const sideLength = 5 * range + 5;
  const startingAngle = 15 * range;
  const numSides = Math.floor(range * 15) + 1;
  const randomPolygon = polygonGenerator.coordinates(numSides, sideLength, startingAngle);
  const vertices = randomPolygon.map(({ x, y }) => ({ x, y, z: 0 }));
  const polygons = [
    {
      points: vertices,
      color: { r: 1 - range * 0.5, g: range, b: 1, a: 1 - range * 0.3 },
      id: 1,
    },
  ];
  return (
    
      {polygons}
      
    
  );
}
// #END EXAMPLE
github cruise-automation / webviz / docs / src / jsx / commands / FilledPolygonsHitmap.js View on Github external
function Example() {
  const [clickedObj, setClickedObj] = useState(null);
  const randomPolygon = polygonGenerator.coordinates(5, 10, 30);

  const polygons = [
    {
      points: randomPolygon.map(({ x, y }) => ({ x, y, z: 0 })),
      color: { r: 1, g: 0, b: 1, a: 1 },
      id: 1,
    },
    {
      points: randomPolygon.map(({ x, y }) => ({ x: x - 20, y: y - 20, z: 0 })),
      color: { r: 1, g: 1, b: 1, a: 1 },
      id: 2,
    },
    {
      points: randomPolygon.map(({ x, y }) => ({ x, y: y - 20, z: 0 })),
      color: { r: 0, g: 0, b: 1, a: 1 },
      id: 3,
github cruise-automation / webviz / packages / regl-worldview / src / stories / Worldview.stories.js View on Github external
withRange((range) => {
      const sideLength = 5 * range + 5;
      const startingAngle = 15 * range;
      const numSides = Math.floor(range * 15) + 1;
      const randomPolygon = polygonGenerator.coordinates(numSides, sideLength, startingAngle);
      const vertices = randomPolygon.map(({ x, y }) => [x, y, 0]);
      const polygon = {
        points: vertices,
        color: [1 - range * 0.5, range, 1, 1 - range * 0.3],
        id: 1,
      };
      return (
        
          {[polygon]}
        
      );
    })
  );

polygon-generator

A utility to generate coordinates of an equilateral polygon.

BSD-2-Clause
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis

Popular polygon-generator functions