using geomerativ to get the area of a shape
in
Contributed Library Questions
•
2 years ago
hi, I have a series of shapes and a series of ellipses placed at floats newLong, newLat. I want to test to see if an ellipse is overlapping any shape and then if it is, place it at a random location on that shape. To do this i am using the geomerative library to get every point contained in the area of a of a shape, and put those points into an array of points, so i can then select a random place in the array and place an ellipse at that point. This seems like it would work but when I run it the program freezes. There are no errors in the console. Is this just to much information to store? is there a geomerative method that gets every point in the area of a shape for you?
here is the code I am using (globe is the name of my svg)
void mapToPage(){
RPoint[] area = new RPoint[0];
RPoint p = new RPoint(newLong,newLat);
for(int j=0;j<globe.countChildren();j++){
if(globe.children[j].contains(p)){
for(int x=0; x<width; x++) {
for(int y=0; y<height; y++) {
RPoint a= new RPoint(x, y);
if(globe.children[j].contains(a)) {
area = (RPoint[])append(area, a);
}
}
}
}
}
here is the code I am using (globe is the name of my svg)
void mapToPage(){
RPoint[] area = new RPoint[0];
RPoint p = new RPoint(newLong,newLat);
for(int j=0;j<globe.countChildren();j++){
if(globe.children[j].contains(p)){
for(int x=0; x<width; x++) {
for(int y=0; y<height; y++) {
RPoint a= new RPoint(x, y);
if(globe.children[j].contains(a)) {
area = (RPoint[])append(area, a);
}
}
}
}
}
1