Workshop Task

In a recent workshop we were assigned the task of getting a single pixel colour value from an image. Below I will discuss how I achieved this.

Screen Shot 2015-01-26 at 04.21.56Screen Shot 2015-01-26 at 04.21.32

As you can see above my image of a fish has an orange square in the top left corner. I have done this by creating a pImage variable and assigning the name ‘img’. I have then loaded the image in the setup section by using the loadImage function. I have also created a color variable called ‘c’ and then assigned it to my PImage (img) and used the get function to grab a the pixel which is 200 pixels accross and 200 pixels down. I have then created a rect which has a fill of the color variable c, which is using get to find the pixel colour in the image, resulting in the square being the colour of that pixel.

Screen Shot 2015-01-26 at 04.25.15Screen Shot 2015-01-26 at 04.25.55

Here I have done the same thing but changed the get parameters (highlighted) to 27k,120, which is the fishes eye. As you can see above the rectangle has now changed colour to black.

What I didn’t do in the workshop was work out how to get the colour value of a pixel that is being captured by the camera, though I intend to work this when I next get time.

Workshop Challenge Outcome

In our previous workshop we were assigned the task of trying to figure out how to split an image into individual pixels and get those pixels to ‘fall’ to the bottom of the canvas. From our previous workshops where we learned how to replicate gravity and also how to affect single pixels. We were given some help in that we were told that the solutions lie in each of the workshops where we had followed along with Paul to learn some more challenging tasks. I didn’t quite manage to complete the task but I gave it my best shot and below I will show how far I got.

Above shows how I was attempting to split the pixels up and make them fall down, instead I found out how to split the pixels apart and make them grow apart from each other when the mouse is pressed.Below is my code with a few comments to explain what each section does.

Screen Shot 2015-01-26 at 05.44.11

The other thing I managed to to was get squares to “fall down” after a mouse click. There is a video and a screenshot below.

Screen Shot 2015-01-26 at 05.57.12

I think if I had more time I would have been able to work this problem out, but I’ll just have to say close but no cigar (I’ll probably kick myself when I look at the code from the workshops folder on mybu). However this process has helped me with becoming more familiar with more advanced concepts of programming.