Has anyone succeeded in using getCentroid method on geomerative's RShape ?
in
Contributed Library Questions
•
2 years ago
Hello,
I can't succeed in extracting the centroid from a RShape.
I proceed this way:
1. I load the shape from an SVG file:
RShape myShape = RG.loadShape("test3-2.svg");
2. I use this instruction, which seems mandatory (althought I don't really understand what it does) :
myShape = RG.centerIn(myShape, g);
3. I draw the shape:
RG.shape(myShape);
4. I use the getCentroid method like this:
RPoint myShapeCent= myShape.getCentroid();
There is no error message caused by the former instruction but if I try to use the RPoint's data (myShapeCent.x for instance) I get a null pointer error message.
So, what's wrong ???
I can't succeed in extracting the centroid from a RShape.
I proceed this way:
1. I load the shape from an SVG file:
RShape myShape = RG.loadShape("test3-2.svg");
2. I use this instruction, which seems mandatory (althought I don't really understand what it does) :
myShape = RG.centerIn(myShape, g);
3. I draw the shape:
RG.shape(myShape);
4. I use the getCentroid method like this:
RPoint myShapeCent= myShape.getCentroid();
There is no error message caused by the former instruction but if I try to use the RPoint's data (myShapeCent.x for instance) I get a null pointer error message.
So, what's wrong ???
1