Created
April 16, 2021 04:10
-
-
Save gorborukov/c5c870504504350e357a34ef4be5e34e to your computer and use it in GitHub Desktop.
Pseudo quadtree base. Ported from some p5.js scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct drawingLocation{ | |
int x,y,w,h; | |
}; | |
std::vector<drawingLocation> drawingLocations; | |
void recursion(int x, int y, int width) { | |
int index = 0; | |
int count = 2; | |
int size = width/count; | |
float upper_limit = 1.0; | |
float lower_limit = 0.1; | |
float randomValue = ((upper_limit-lower_limit)*rand())/RAND_MAX + lower_limit; | |
for(int i = 0; i < count; i++) { | |
for(int j = 0; j < count; j++) { | |
if(randomValue < 0.5 && size > 50) { | |
recursion(x + i * size, y + j * size, size); | |
} else { | |
drawingLocations.push_back({x+i*size, y+j*size, size, size}); | |
/*index++; | |
if (index > 3) { | |
index = 0; | |
}*/ | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment