This program will convert .png and .jpg images into a version of the image drawn only using triangles.
- Each image in the same directory as the java executable is read and 'converted' when one is completed the program looks for another, if there are none it will wait for 10 seconds before looking again.
- Once it has found an image it will divide it into almost equal portions to 'convert' separately called Blocks.
- Each Block has its own thread and will attempt to draw triangles to match the original image.
- When all Block files are completed the program will compile all of the images into a new image and save it, along with a ".trifi" file which contains the triangle data.
- The only input Block has is the 'Score' it gets when its solution is compared to the original.
- The Block file 'submits' a set of triangles to be scored.
- The Block file gets back a score based on the pixel color values and how far off or how close they are to the original.
- This score is represented as a double value from 0 -> 1;
- The Block file will place a random triangle on the blank 'field'.
- The triangle goes through multiple stages until it is deemed 'stagnant' or when it has not improved for a set amount of comparisons.
- First a Triangle is randomly moved and the color is changed to find a rough area that needs to be improved on.
- Next the color is modified by a factor of at most 10%, this narrows down the average color that the triangle is covering
- The shape of the triangle is modified until it has found any better locations.
- The shape is modified further by a factor of 10% to narrow down the exact perfect position.
- The triangle is checked if it can be removed without decreasing the score, so if the triangle is useless or behind another triangle.
- Another Triangle is added and the process repeats until the maximum number of triangles is hit.
- The Block file then outputs an image along with a file of the triangle data.