Frage

I'm trying to make a circle out of a Polygon (I know I could just use for example the shape renderer, but I need it like this).

The circle should consist out of 4 Nodes and 4 curved Edges.The nodes are rendered by a ShapeRenderer and are positioned like a "+", the edges by an edge renderer to curve them. Right now I have the problem, that the edges enter all the nodes on the sides, which is OK for the top and bottom node, but does not work for the left and the right node as they should enter the nodes on top and the bottom, and so I don't get a perfect circle but more something egg-shaped.

Does anybody know how I can change the position the edges enter the nodes or how to rotate this nodes for 90 degrees?

War es hilfreich?

Lösung

The method to set control points in EdgeRenderer looks very simple:

protected void getCurveControlPoints(EdgeItem eitem, Point2D[] cp, 
                double x1, double y1, double x2, double y2) 
{
    double dx = x2-x1, dy = y2-y1;      
    cp[0].setLocation(x1+2*dx/3,y1);
    cp[1].setLocation(x2-dx/8,y2-dy/8);
}

Probably, you have to override it to set achieve the curve you want.

Please share your solution here for other, if that is the case.

Andere Tipps

OK, i was trying some stuff and came up mwith the following:

      protected void getCurveControlPoints(EdgeItem eitem, Point2D[] cp, 
                    double x1, double y1, double x2, double y2) 
    {
        double dx = x2-x1, dy = y2-y1;      
//        cp[0].setLocation(x1+2*dx/3,y1);
//        cp[1].setLocation(x2-dx/8,y2-dy/8);
        cp[0].setLocation(x1+2*dx/3,y1);
        cp[1].setLocation(x2,y2-dy/3);
    }

This works for me, i'm not sure if it is a perfect circle, but i can't spot a difference. I also dont really understand why it works, because I add 2*dx/3 to x1, but substracted only dy/3 from y2. Does anybody have a clue why this works?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top