Skip to content

Create a new polygon from existing vertexes #260

@das-dias

Description

@das-dias

I am trying to create a polygon from an existing Polygon object's points. However, when setting the vertices of the polygon, they are ignored, and a triangle is created.

The snippet of code I am using is presented below.

const polygonPoints = Object.values(polygon.points)
        .map(point => ({
          x: point.x ? point.x : 0.0,
          y: point.y ? point.y : 0.0
        }));

const poly = new draw2d.shape.basic.Polygon({
        id: `${polygon.layer}-${polygon.datatype}-${k}`,
        vertices: polygonPoints,
        bgColor: "#FFF222",
        color: "#777222",
        alpha: .7,
        //composite: cellId,
        selectable: false,
        draggable: false,
      });
      app.view.add(poly);
      cellGroup.assignFigure(poly);

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions