How can I draw a ‘Type 1’ roadtile in JavaFX as shown in the image? It’s a quarter circle that changes orientation based on degrees (0, 90, 180, 270). Any guidance on how to implement this would be greatly appreciated!
enter image description here
Example Road Types;
Type0
public void drawType0Road(Group group, double cellWidth, double cellHeight, int rotation) {
double roadWidth = cellWidth;
double roadHeight = cellHeight - 10;
double roadX = x * cellWidth;
double roadY = y * cellHeight + 5;
Rectangle road = new Rectangle(roadX, roadY, roadWidth, roadHeight);
road.setFill(Color.web("#FEFEFE"));
road.setRotate(rotation);
group.getChildren().add(road);
}
Type2
public void drawType2Road(Group group, double cellWidth, double cellHeight, int rotation) {
Group roadGroup;
double padding = 0.2;
double roadWidth = cellWidth;
double roadHeight = cellHeight - (cellHeight * padding);
double roadX = x * cellWidth;
double roadY = y * cellHeight + (cellHeight * padding/2);
Rectangle road = new Rectangle(roadX, roadY, roadWidth, roadHeight);
road.setFill(Color.web("#FEFEFE"));
double road2Width = cellWidth - (cellWidth * padding);
double road2Height = cellHeight;
double road2X = x * cellWidth + (cellWidth * padding/2);
double road2Y = y * cellHeight;
Rectangle road2 = new Rectangle(road2X, road2Y, road2Width, road2Height);
road2.setFill(Color.web("#FEFEFE"));
roadGroup = new Group(road, road2);
roadGroup.setRotate(rotation);
group.getChildren().add(roadGroup);
}
I tried to draw it using Arc of the round type. But I couldn’t give it the shape I wanted.
Burakcan TOKSES is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.