Circle adjusted to work better but now I think hirdrac was right that it's easier to just calculate a distance from center and use that to determine light levels rather than a whole dpath.

This commit is contained in:
Zed A. Shaw 2024-12-25 06:03:11 -05:00
parent 8a94108874
commit 9ac8da30ea
7 changed files with 23 additions and 22 deletions

View file

@ -180,24 +180,24 @@ namespace matrix {
}
circle::circle(Matrix &mat, Point center, int radius) :
center(center), radius(radius)
circle::circle(Matrix &mat, Point center, float radius) :
center_x(center.x), center_y(center.y), radius(radius)
{
width = matrix::width(mat);
height = matrix::height(mat);
top = max(int(center.y - radius), 0);
bottom = min(int(center.y + radius), height);
top = max(int(floor(center_y - radius)), 0);
bottom = min(int(floor(center_y + radius)), height - 1);
y = top;
}
bool circle::next() {
y++;
if(y < bottom) {
dy = y - center.y;
if(y <= bottom) {
dy = y - center_y;
dx = floor(sqrt(radius * radius - dy * dy));
left = max(0, int(center.x - dx));
right = min(width, int(center.x + dx));
left = max(0, int(center_x) - dx);
right = min(width, int(center_x) + dx + 1);
return true;
} else {
return false;