Swap incorrect width/height mapping (#409)

width and height were being set using the incorrect axes resulting in incorrect canvas dimensions

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
Jhon Adams 2022-06-01 12:13:39 -07:00 committed by GitHub
parent ed5b4cec49
commit b63aa9e375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View File

@ -10,6 +10,7 @@ current (development)
- Bugfix: Fix the selected/focused area. It used to be 1 cell larger/longer than - Bugfix: Fix the selected/focused area. It used to be 1 cell larger/longer than
requested requested
- Bugfix: Forward the selected/focused area from the child in gridbox. - Bugfix: Forward the selected/focused area from the child in gridbox.
- Bugfix: Fix incorrect Canvas computed dimensions.
### Screen ### Screen
- Feature: add `Box::Union(a,b) -> Box` - Feature: add `Box::Union(a,b) -> Box`

View File

@ -871,8 +871,8 @@ Element canvas(int width, int height, std::function<void(Canvas&)> fn) {
} }
void Render(Screen& screen) final { void Render(Screen& screen) final {
int width = (box_.y_max - box_.y_min + 1) * 2; int width = (box_.x_max - box_.x_min + 1) * 2;
int height = (box_.x_max - box_.x_min + 1) * 4; int height = (box_.y_max - box_.y_min + 1) * 4;
canvas_ = Canvas(width, height); canvas_ = Canvas(width, height);
fn_(canvas_); fn_(canvas_);
CanvasNodeBase::Render(screen); CanvasNodeBase::Render(screen);

View File

@ -39,7 +39,7 @@ TEST(CanvasTest, GoldPoint) {
}); });
Screen screen(30, 10); Screen screen(30, 10);
Render(screen, element); Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), -1195891837); EXPECT_EQ(Hash(screen.ToString()), 2143518726);
} }
TEST(CanvasTest, GoldPointColor) { TEST(CanvasTest, GoldPointColor) {
@ -54,7 +54,7 @@ TEST(CanvasTest, GoldPointColor) {
}); });
Screen screen(30, 10); Screen screen(30, 10);
Render(screen, element); Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 1109533029); EXPECT_EQ(Hash(screen.ToString()), 1264423298);
} }
TEST(CanvasTest, GoldBlock) { TEST(CanvasTest, GoldBlock) {
@ -72,7 +72,7 @@ TEST(CanvasTest, GoldBlock) {
}); });
Screen screen(30, 10); Screen screen(30, 10);
Render(screen, element); Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 817159424); EXPECT_EQ(Hash(screen.ToString()), 3826174883);
} }
TEST(CanvasTest, GoldBlockColor) { TEST(CanvasTest, GoldBlockColor) {
@ -87,7 +87,7 @@ TEST(CanvasTest, GoldBlockColor) {
}); });
Screen screen(30, 10); Screen screen(30, 10);
Render(screen, element); Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 2869205941); EXPECT_EQ(Hash(screen.ToString()), 3048712696);
} }
TEST(CanvasTest, GoldText) { TEST(CanvasTest, GoldText) {