Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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,
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]}
);
})
);