Skip to content

Commit 9d0507b

Browse files
author
Matt Lythgoe
committed
Update the image to the 2021 Challenge plot
1 parent e017b75 commit 9d0507b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/main/java/com/team319/ui/Plotter.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@
1818
public class Plotter extends JPanel {
1919

2020
private static final long serialVersionUID = 1L;
21-
private static String fieldImage = "/field_image_2020_large.png";
21+
private static String fieldImage = "/2021_at_home.png";
2222
private BufferedImage img;
2323
private static double scale;
2424
private int fieldHeight;
2525
private WaypointListener waypointListener;
2626
private String pathName;
2727

28+
private static final double FIELD_HEIGHT = 15.0;
29+
2830
public Plotter(String pathName) {
2931
waypointListener = new WaypointListener(this);
3032
try {
3133
this.pathName = pathName;
3234
img = ImageIO.read(getClass().getResourceAsStream(fieldImage));
33-
scale = img.getHeight() / 27.0;
35+
scale = img.getHeight() / FIELD_HEIGHT;
3436
fieldHeight = img.getHeight();
3537
} catch (IOException e) {
3638
e.printStackTrace();
@@ -87,11 +89,11 @@ public static double convertXFromPixel(double pixel) {
8789
}
8890

8991
public static int convertYToPixel(double value) {
90-
return (int)((13.5 - value) * scale);
92+
return (int)((FIELD_HEIGHT/2 - value) * scale);
9193
}
9294

9395
public static double convertYFromPixel(double pixel) {
94-
return (27 - pixel / scale) - 13.5;
96+
return (FIELD_HEIGHT - pixel / scale) - FIELD_HEIGHT/2;
9597
}
9698

9799
public BobPath getPath() {

src/main/resources/2021_at_home.png

23.3 KB
Loading

0 commit comments

Comments
 (0)