-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathXDrawer.java
More file actions
30 lines (24 loc) · 1.08 KB
/
XDrawer.java
File metadata and controls
30 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package javacodes.lightdraw;
public class XDrawer extends AbstractDrawer {
private static final String X_CHARACTER = "X";
private int size;
public XDrawer(Window window, int xCoordinate, int yCoordinate, int size) {
super(window, xCoordinate, yCoordinate);
this.size = size;
}
@Override
public void draw() {
drawPixel(this.getxCoordinate(), this.getyCoordinate(), X_CHARACTER);
for (int offset = 1; offset < size; offset++) {
drawPixel(this.getxCoordinate() + offset, this.getyCoordinate() + offset, X_CHARACTER);
drawPixel(this.getxCoordinate() - offset, this.getyCoordinate() - offset, X_CHARACTER);
drawPixel(this.getxCoordinate() + offset, this.getyCoordinate() - offset, X_CHARACTER);
drawPixel(this.getxCoordinate() - offset, this.getyCoordinate() + offset, X_CHARACTER);
}
}
@Override
public String toString() {
return "XDrawer [size=" + size + ", getxCoordinate()=" + getxCoordinate() + ", getyCoordinate()="
+ getyCoordinate() + "]";
}
}