top of page

nc_Week8: Video Player
GENETIC ALGORITHMS
Topic
For this week's homework, I want to re-create Piet Mondrian's Composition with Red, Blue and Yellow. The P5 sketch uses genetic algorithms to gradually turn blue, yellow, and black in random squares.
I modified its To be or not to be example to make it suitable for RGB colors
nc_Week8: 內嵌
GENETIC ALGORITHMS
Topic
For this week's homework, I want to re-create Piet Mondrian's Composition with Red, Blue and Yellow. The P5 sketch uses genetic algorithms to gradually turn blue, yellow, and black in random squares.
I modified its To be or not to be example to make it suitable for RGB colors
nc_Week8: 內嵌
nc_Week8: 內嵌
nc_Week8: 內嵌
After that, I designed a black random line layout. The basic principle :
1. First, randomly generate the Y coordinate of the interval random (50, 100 into an array and draw the line.
2. Randomly generate the X coordinate of the interval random (50, 100) Store it into an array.
3. Iterate over each x coordinate, and randomly select a Y coordinate, connect two points.
4. Iterate through every two x coordinates, and randomly select two Y coordinates, draw a rectangle and fill it color.
​
code link
nc_Week8: 內嵌
nc_Week8: 內嵌
Areas for improvement:
1. It is difficult to determine the number and area of ​​randomly generated squares each time
2. The system is easy to crash for a period of time.
nc_Week8: 內嵌
bottom of page
