Today, it’s the day of Holi, the festival of colors in India.
Yesterday, it was the end of our midterm exams.
Such Time. Much Rhyme.
During the last minutes, I decided to stop writing after matching an answer with the person sitting next to me. I was all set to run outside the hall and smell the woot! no more exams left scent in the air.
I have one strange habit of drawing random things in my notebook, ranging from literally anything to K-nearest girls. All the drawings are terrible though.
So I started utilizing rest of the time by drawing in the backside of exam paper. After a little journey to some wonderland, I had this weird sounding thought in my mind, to write something that simulates a painted wall.
Then the exam ended, we left the hall, enjoyed the Holi all day with batchmates.
That weird thought was still there in my mind, deep somewhere. I decided to give it a shout next morning. And you never need a halcion after ~40 hours of not sleeping and doing not so successful attempt of cram.
Today, I started justifying that thought, picked up golang for it and created a directory, ~/go/src/github/pravj/wall
Wait! let’s talk over. Have you ever painted a wall before?
Well! I have. If not, you must have seen people doing it. What happens when you start with the brush? Something like this picture.
Here in the picture, the part painted by each color doesn’t have a specific shape.
So, in my attempt, I assumed that there exists a central rectangular shape in color block generated by each brush swipe. And the final block also contains some noise around that rectangle, resulting in the final irregular shape.
I started with those rectangles, equally spaced with each other. The space was for the noise interference I was planning. Result was this, fix colored image.
Then I added the noise on each rectangle. For this, instead of fix sized rectangle. I added some random lengthy stripes around the block, colored same as the block. The result was this image, fixed color again.
After applying random colors to each block, it generates image similar to the one given below. The ideal thing to do would be, coloring each block in a way that it’s different from its surrounding block color. Something like the classical Four Color Theorem, variant of the Constraint satisfaction problem.
But in this case, the probability of the ideal case violation is lilliputian.
Precisely, for a slanted saltire(cross) shape divided in five squares, the probability of central square having same color as any surrounding square will be around 2 in 10 million.
So let’s ignore it like a pigeon closing its eyes in front of a venerer cat.
Now I was concerned about the equally spaced color blocks. Things were still not in the way I wanted them to be. It looked like there is a pattern inside. As systems having more entropy are more stable and beautiful. I decided to put color blocks at random places in the image, result was this.
After this all, the central rectangle that I have assumed for the structure, was clearly visible in the block. To conceal that, I formatted the block such that the noise along the block-width depends on the index of the row in block matrix. Now, it was better than the last one.
This is what I have thought about. A wall painted by some children in their tiffin time.
This may sound like a dumb thing to work on, it’s actually. It’s just a combination of some for and if-else loops.
But this is more than just dumb, now I feel relieved as I made it real what I have thought about, something like Aaron has said.
Source Code : virtual-wall