In a perfect left-right gradient pattern of tiles, there are as many colors as there are columns. But this is not very practical for building because tiles are usually not manufactured in hundreds of different colors. And, if a few tiles break or are misplaced, the overall impression of the pattern becomes incomplete.
This posts presents an alternative method to create a gradient pattern, using a limited number of tiles.
To start with, 3 graphs describes the probability range of each of the 3 colors at specific positions.
For example, if we want the left side to be dark, we adjust the graphs so that the values on the left side are high for the darkest brick, and low for the others. For examples, if the numbers of the graph at the left side are:
Dark: 0.70
Medium: 0.20
Light: 0.10
Then we generate a random float value between 0 and 1.
If the random number is less than 0.70 --> Dark color
If the random number is less than 0.70+0.20 --> Medium color
Else (if the random number is larger than 0.70+0.20) --> Light color
So if the random number is 0.23, for example, the tile will be dark. If it is 0.65 it will also be dark. But if it is 0.95 it will be light.
In this way, the tiles will be irregularly selected, with various probabilities resulting in a gradient pattern than can be adjusted by manipulating the input graphs.
コメントをするにはログインしてください。