How to generate a random-looking pattern of hexagonal floor tiles?
java - Creating a hexagonal grid pattern - Stack Overflow
Random hexagonal Truchet pattern generator
How can I make a repeating hexagonal tile?
Videos
We are renovating our small bathroom (5ft x 8ft) For the floor tiles, we chose 7in x 8in hexagonal tiles. 67% of the tiles are grey. 33% are ivory. We want to just have a seemingly random smattering of the ivory tiles among the grey.
Tile subcontractor says he doesn't want to do the randomness himself in case we aren't happy with what he chooses, and has asked us for a pattern.
I'm shit at math, and was hoping to find an online tile pattern generator, bit haven't had much luck. There's one at clayhaustile.com that has an option for hex tile, but that's the only one I've found.
Any leads or tips to create a seemingly random or just understated pattern?
I think the first thing you need to do is link up your Tiles. Give them six references, one for each potential neighbor - Northwest, Northeast, East, Southeast, Southwest, and West. Then, given any tile, you can easily traverse all of its neighbors. Once you've created this graph of Tile objects, assign them Vector instances.
Assuming the Vector for each Tile is unique, the next step is to create a function that maps each of those Vector instances to cartesian coordinates. At that point, you could draw the points to see if you're putting tiles in the correct spaces on the screen.
Judging by the link you posted, it sounds like you're trying to make some kind of game (which is cool!). If that's the case, you have two things left to do after you get your vector2Cart() function working:
Render your hexagonal tiles "properly", not just as points or squares.
Create the inverse
cartToVector()method that takes cartesian coordinates and returns the Vector corresponding to theTilethat occupies that part of the screen. This way you can click on the screen and do stuff to theTile.
To build the grid, take advantage of the geometry/symmetry. Think of the grid in terms of depth, where the center is depth 0, and each successive layer has increasing depth. The grid above has depth = 3.
Each level has constant properties related to its depth (each has 6 sides, and the length of each side is proportional to the depth).
The following code will help build the grid:
public class HexagonGrid {
public static void main(String[] args) {
int size = 3;
buildHexagonGrid(size);
}
private static void buildHexagonGrid(int size) {
int totalTiles = 0;
int depth = 0;
// TODO: Build the center tile here
totalTiles++; // Center
System.out.printf("Current size (after depth=%d) = %d\n", depth, totalTiles);
for (depth=1; depth<=size; depth++) {
for (int side=1; side<=6; side++) {
for (int tile=1; tile<=depth; tile++)
// TODO: Build the Tiles along current side/depth
// There is a clear relationship between x/y/z and depth/side/tile
totalTiles++;
}
System.out.printf("Current size (after depth=%d) = %d\n", depth, totalTiles);
}
}
}
Showing how many tiles are created at each layer:
Current size (after depth=0) = 1
Current size (after depth=1) = 7
Current size (after depth=2) = 19
Current size (after depth=3) = 37