Fix separator() (#100)

separator() should modify only the character, not the background color.
This commit is contained in:
Arthur Sonzogni 2021-05-17 01:34:53 +02:00 committed by GitHub
parent 30a85c4c5b
commit ab9d6feaa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,15 +29,9 @@ class Separator : public Node {
else else
c = U''; c = U'';
Pixel p;
p.character = c;
RenderWithPixel(screen, p);
}
void RenderWithPixel(Screen& screen, Pixel pixel) {
for (int y = box_.y_min; y <= box_.y_max; ++y) { for (int y = box_.y_min; y <= box_.y_max; ++y) {
for (int x = box_.x_min; x <= box_.x_max; ++x) { for (int x = box_.x_min; x <= box_.x_max; ++x) {
screen.PixelAt(x, y) = pixel; screen.PixelAt(x, y).character = c;
} }
} }
} }
@ -47,7 +41,13 @@ class SeparatorWithPixel : public Separator {
public: public:
SeparatorWithPixel(Pixel pixel) : pixel_(pixel) {} SeparatorWithPixel(Pixel pixel) : pixel_(pixel) {}
~SeparatorWithPixel() override {} ~SeparatorWithPixel() override {}
void Render(Screen& screen) override { RenderWithPixel(screen, pixel_); } void Render(Screen& screen) override {
for (int y = box_.y_min; y <= box_.y_max; ++y) {
for (int x = box_.x_min; x <= box_.x_max; ++x) {
screen.PixelAt(x, y) = pixel_;
}
}
}
private: private:
Pixel pixel_; Pixel pixel_;