diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2018-11-07 10:09:47 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2018-11-07 10:09:47 -0800 |
commit | c388759ed67b792201b99bf7d73d036c34b47d87 (patch) | |
tree | d16e7bdba8e1f226bd97b9a774fcb519c2bebd42 /Source/Panel.cpp | |
parent | 5ad08f6611c8c777c43cfa0d2380b6ad6554a54d (diff) | |
download | witness-tutorializer-c388759ed67b792201b99bf7d73d036c34b47d87.tar.gz witness-tutorializer-c388759ed67b792201b99bf7d73d036c34b47d87.tar.bz2 witness-tutorializer-c388759ed67b792201b99bf7d73d036c34b47d87.zip |
Working on some consistency
Diffstat (limited to 'Source/Panel.cpp')
-rw-r--r-- | Source/Panel.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Source/Panel.cpp b/Source/Panel.cpp index 8642461..b6aa504 100644 --- a/Source/Panel.cpp +++ b/Source/Panel.cpp | |||
@@ -22,6 +22,9 @@ Panel::Panel(int id) { | |||
22 | ReadDecorations(id); | 22 | ReadDecorations(id); |
23 | } | 23 | } |
24 | 24 | ||
25 | // For testing | ||
26 | Panel::Panel() {} | ||
27 | |||
25 | void Panel::Write(int id) { | 28 | void Panel::Write(int id) { |
26 | WriteIntersections(id); | 29 | WriteIntersections(id); |
27 | WriteDecorations(id); | 30 | WriteDecorations(id); |
@@ -147,8 +150,7 @@ void Panel::ReadIntersections(int id) { | |||
147 | } else { | 150 | } else { |
148 | dir = Endpoint::Direction::DOWN; | 151 | dir = Endpoint::Direction::DOWN; |
149 | } | 152 | } |
150 | int x = 2 * (location % ((_width + 1) / 2)); | 153 | auto [x, y] = loc_to_xy(location); |
151 | int y = (_height - 1) - 2 * (location / ((_width + 1) / 2)); | ||
152 | _endpoints.push_back(Endpoint(x, y, dir)); | 154 | _endpoints.push_back(Endpoint(x, y, dir)); |
153 | } | 155 | } |
154 | } | 156 | } |
@@ -163,15 +165,15 @@ void Panel::WriteIntersections(int id) { | |||
163 | 165 | ||
164 | double min = 0.1; | 166 | double min = 0.1; |
165 | double max = 0.9; | 167 | double max = 0.9; |
166 | double width_interval = (max - min) / (_width - 1); | 168 | double width_interval = (max - min) / (_width/2); |
167 | double height_interval = (max - min) / (_height - 1); | 169 | double height_interval = (max - min) / (_height/2); |
168 | 170 | ||
169 | for (int y=0; y<_height; y++) { | 171 | for (int y=0; y<_height/2; y++) { |
170 | for (int x=0; x<_width; x++) { | 172 | for (int x=0; x<_width/2; x++) { |
171 | intersections.push_back(static_cast<float>(min + x * width_interval)); | 173 | intersections.push_back(static_cast<float>(min + x * width_interval)); |
172 | intersections.push_back(static_cast<float>(min + y * height_interval)); | 174 | intersections.push_back(static_cast<float>(min + y * height_interval)); |
173 | int flags = 0; | 175 | int flags = 0; |
174 | if (find(_startpoints, {x, y}) != -1) flags |= IntersectionFlags::IS_STARTPOINT; | 176 | if (find(_startpoints, {2*x, 2*y}) != -1) flags |= IntersectionFlags::IS_STARTPOINT; |
175 | intersectionFlags.push_back(flags); | 177 | intersectionFlags.push_back(flags); |
176 | if (y > 0) { | 178 | if (y > 0) { |
177 | connections.first.push_back(y * _width + x); | 179 | connections.first.push_back(y * _width + x); |