1st Assignment (Week 2)

Assignment (Week 3)

Class 3 - From Scratch 2 - Pixels

Covering - using color pixels - Introduction to the way pixels are stored and manipulated in computers and Processing.

cave painting hand spray

abstract expressionism:

Willem de Kooning paintings

Jackson Pollock paintings

Franz Kline paintings

color field painting:

Barnett Newman

Mark Rothko

abstract graffiti art

airbrush art on cars

  • Suggested exercise - Create a painting app, something that applies colors or paint or texture as the user moves the mouse or some other interaction.

Assignment (Week 4)

Class 4 - Image Processing 1 - Color Manipulation

Covering - Introduction to the discipline of image color correction and manipulation, change pixels colors to enhance brightness, saturation, contrast, and creating effects such as inverting and posterizing (also covering opening image files, movie files, and live camera)

  • Suggested exercise - Create interesting manipulations of images by changing their colors . Try to create static, dynamic and interactive pieces based on an image, video or live camera.

Week 8 (Mid-Term)

  • Thank you Jiayuan Ii for your beautiful description of me 🌈

Li,Nancy -> Yu,Junoh -> Zhou,Michael (-> Li,Nancy )

  • Due in March 25

    1. I will assign random pairs, each person must create a portrait or some sort of interactive project for/about their mate. It can be just influenced by them or it could be an actual portrait of them, it can be a homage to them or based on their likes and dislikes, it can be based on photos of them or of their family or of their stuff or pets. It can be based on things they like or dislike, it can be based on traits of their character or look. Try to make it as specific as you can to that person and as intimate as you can. Be generous.

    2. Today we will spend half an hour each interviewing our mates and gathering information that can be used for the project . Please bring with you anything that you think can assist such as photos /videos of family, you as a baby, pets, teddy bear you love, hobbies, and think of stories about yourself that can be helpful.

    3. Each student will prepare a presentation that will be shared in our class folder. Also the code will be placed in our class folder.

    4. Each student will have a google doc that will be used to receive feedback from all of us.

Progress (Learning Processing)

( 12 hours of learning the basis of the processing by Daniel Shiffman & Daniel Rozin)

  • The hardest part of this term was understanding all of the basic code. Because I wasn’t sure what the core meaning of all the names and commands were. But through watching all the tutorials with attempting examples, it became much more familiar with me. It took a while because I wanted to adapt those new languages to my brain. However, after making these progress, I feel a little bit confident in using java.

  • And I was really struggle with cameras and sounds. For some reasons, It doesn’t work with my mac. But after looking up lots of youtube video, I finally found the way to do it. But it wasn’t easy because I need to change the code through terminal. But finally it started to work in my mac, which is ‘Catalina in 16 inch new mac book pro.’

  • Whenever I use the camera, I need to change the old code to new code. (Need to remember)

    // old code

    video = new Capture(this, 640, 480);

    // new code

    String[] cameras = Capture.list();

    video = new Capture(this, 640, 480, cameras[0]);

Progress (Mid-term)

< Portrait of Zhou,Michael >

  • Thank you Zhou Michael for sharing your stories with me 🌈

  • First Question: “what do you want to do if you can do whatever you want?”

    • Answer: “I want to go to the moon and step on the Neil Armstrong’s first step.”

  • Second Question: “what is the your happiest moment in you whole, pick one!”

    • Answer: “Coachella, I was in this music festival and I actually came out yo my friend. And it was best moment in my life”

  • Third Question: “what do you want to be if you can be anything?”

    • Answer : “I want to be an octopus. Because they are actually smart. almost like as human. And they can go anywhere because they can change their body shape and color easily.”

Final Mid-term (Code/Java)

< Portrait of Zhou,Michael >

Feedback

  • I might have to change the way of interaction. It seems like everything happens at the same time. So it might be better if it happens in consecutive order. So it might give a surprise to the user and give them more curiosity.

Assignment (Week 9)

Class 9 - Video Tracking, Manipulation and Masking

Covering - Using dynamic visual data to extract information - getting pixel data from video, tracking brightness, color, change, motion.

  • Covering - Using techniques to manipulate live video, including masking, chroma keying, background removal, Face tracking.

  • PXP Code Examples week 9


This week we are looking at various methods and manipulations that are most useful with the video medium . This is for both video movies and live video. Some of the methods are also possible for static images but not as useful.

The medium of video is a unique one. It's uniqueness comes from the fact that it has an additional dimension. (It is a third dimension, but not in the sense that we usually think of XYZ, which we will discuss next week) The extra dimension is time, so its more like XYT. We started looking at that dimension last week when we looked at separate frames of video and tried to create composite images out of them.

Today we will look at two types of effects: Tracking and masking:

Tracking-

When you look at our "normal" input devices that we use in our computer based projects, we generally have the keyboard and mouse. Trying to calculate the data throughput of those yields:

Keyboard- 100 digital (1/0) buttons that can be pressed one at a time about 10 times per second, so that's about 10 bits per second

Mouse - 2 integers (X,Y) that refresh 120 times per second, so thats about 240 bytes per second

Compare this to the throughput of a video camera: We routinely open up our video source at 1280 x 720 and we have three integers for each pixel R,G,B , and the frame rate is typically 30 FPS so thats - 1280 * 720 * 3 * 30 = 82,944,000 bytes per second.

So the advantages of using video as input are obvious, in our search to get more richness and subtlety out of our interactions with users (people), this ocean of available data is an amazing resource.

Tracking techniques can be divided into three categories:

  • Color tracking techniques.

    1. Difference based tracking techniques.

    2. Feature tracking techniques.

Masking / Keying-

The same richness of data can be used to create masking effects. By masking we mean combining two or more sources of media according to some attribute of the video (Think green screen type of thing. Probably some of you are doing this right now by setting a custom background to your zoom ) . These tracking techniques are are also divided to three groups:

  • Color based masking techniques (chroma keying)

    1. Difference based masking techniques (background subtraction)

    2. Feature based masking techniques (usually employing ML like bodyPix)

I think for today's survey I will intertwine the tracking and masking techniques and go in the order of Color- Difference- Feature.

Color based tracking and masking:

When doing color based tracking and masking there is no difference if the source is a static image or a video, both have pixels and we can evaluate those pixels to try and derive information. For this tracking to work you need to control the environment and lighting. If you are tracking a bright light a mostly dim environment and a small spot of light (LED works well) , IR LEDs show up in most cameras but are invisible to humans so you can use those to be a bit more discrete. If you are tracking a color then a brightly lit environment will let the camera pick up the colors more easily.

Brightness tracking - source code

Here we are looking to find the brightest pixel in the video. This means to evaluate every pixel in terms of brightness (R+G+B) and compare it to all other pixels. This kind of "competition" is very commonly done, so its worthwhile spending a few minutes understanding the concept, here are the steps :

1. Visit all pixels of the image one by one and get their RGB values

2. Estimate the brightness of each color by adding up its R+G+B

3. Comparing this brightness to the brightest pixel we saw so far (record)

4. If the current pixel is brighter than the record, it becomes the record holder

for (int x = 0; x<width; x++) { for (int y = 0; y<height; y++) { PxPGetPixel(x, y, ourVideo.pixels, width); int thisBrightness=R+G+B; //adding up RGB is a good approximation of brightness if (thisBrightness >record) { // if our pixel is better than the record record= thisBrightness; //we remember the new record recordHolderX= x; // and the new record holder recordHolderY= y; } } }


Color Tracking - source code

Color tracking is useful if you do not have a dim environment and a bright spot. In that case you can dedicate a certain color to be tracked. It is very similar to the brightness tracking in code, only here we are not adding up RGB but rather comparing the RGBs of every pixel to the RGBs of the target color.


We define the target RGB as 3 global variables by clicking on a pixel :

void mousePressed(){ PxPGetPixel(mouseX, mouseY, ourVideo.pixels, width); // Get the RGB of pixel under the mouse targetR=R; // set the RGB under the mouse to the target targetG=G; targetB=B; }

And we calculate how similar a pixel is to the target RGB using the dist() function that works on RGB as well as it does on its intended XYZ :

float thisPixelSimilarity= dist(targetR, targetG,targetB,R,G,B);


Tracking multiple colors - source code

A variation of this is the tracking of multiple colors where a few target colors can be defined, this is useful for tracking a few things like multiple people or maybe multiple fingers of a glove, each with a colorful marker on it.

Masking using colors:

The same techniques that are useful for tracking also work for masking; in this case we look for a certain color (typically green) and replace all pixels with that color with pixels from a different source.

Chroma keying - source code

Here we will:

  • Draw the secondary image on the screen (Eiffel tower)

  • Go over the pixels of the video one by one and calculate how similar a pixel is to the target.

  • If a pixel is not close enough we draw its RGB on the screen (replacing the Eiffel)


for (int y = 0; y < video.height; y++) {for (int x = 0; x < video.width; x++) { PxPGetPixel(x, y, video.pixels, width); // get the RGB of the live videofloat distance = dist(R, G, B, keyR, keyG, keyB); // compare our pixel to the target,R,G,Bif (distance > threshold) { // If that distance is greater than the threshold then place PxPSetPixel(x, y, R, G, B, 255, pixels, width); // that pixel on the screen}}}

An interesting variant on the chroma key is "video behind" where we look for a certain color in the image (not the video) and replace that color with the live video. The result is that the video appears to be behind. (A similar effect can be achieved by placing a transparent PNG on top of the video, but doing it in code gives us flexibility to change the transparency in run time)

video behind - source code


difference-based tracking and masking:

Difference based effects only work on video media (live and movie) because the basis of this technique is comparing two frames of the video and looking for areas of great change. All difference based techniques, both tracking and masking compare the live frame to one of two:

  • Compare live frame to the most recent frame - This results in tracking for motion, as only areas of the frame that contain movement will be different.

  • Compare live frame to a selected reference frame - Here we choose a reference frame (typically the empty room) and compare the live frame to that. Areas of the frame that are different are probably a person or something that changed since the reference was made.

Show change pixels - source code

When trying this code try commenting out the line: in draw() :

frameToCompare.copy(video, 0, 0, width, height, 0, 0, width, height);

And pressing the mouse to create a reference frame and move the mouse left and right to change the threshold of what counts as change, notice how the yellow bar measures the amount of change, or motion depending on the reference frame.

Here the outline is :

  • create reference frame (by mouse click or repeatedly )

  • visit all pixels and:

    • Get RGB of live video pixel.

    • Get RGB of reference frame pixel.

    • compare the two sets of RGB with dist()

    • if the difference is big then copy RGB of live video to screen (replacing black)

Reference frame is created with copy() into a reference PImage - frameToCompare. This happens repeatedly or on mouse pressed :

frameToCompare.copy(video, 0, 0, width, height, 0, 0, width, height);

Then we compare all pixels:

for (int y = 0; y < video.height; y++) {for (int x = 0; x < video.width; x++) { PxPGetPixel(x, y, video.pixels, width); // get the RGB of the live videoint videoR=R;int videoG= G;int videoB= B;PxPGetPixel(x, y, frameToCompare.pixels, width); float distance = dist(R, G, B, videoR, videoG, videoB); if (distance > threshold) {PxPSetPixel(x, y, videoR, videoG, videoB, 255, pixels, width);countChangePixels++; }}}


Tracking Change - code example

So now that we understand the idea of finding change between frames let's see how we can use it for tracking , In the next example we will:

  • visit all pixels and:

    • Get RGB of live video pixel

    • Get RGB of reference frame pixel

    • compare the two sets of RGB with dist() and if its more than the threshold:

      • We remember the left, top, right, bottom most pixels.

  • When we are done with all the pixels we have defined the left, top, right, bottom of the area in which change had occurred.


for (int y = 0; y < video.height; y++) {for (int x = 0; x < video.width; x++) { PxPGetPixel(x, y, video.pixels, width); // get the RGB of the live videoint videoR=R;int videoG= G;int videoB= B;PxPGetPixel(x, y, frameToCompare.pixels, width); // get the RGB of the stored framefloat distance = dist(R, G, B, videoR, videoG, videoB); // compare our live pixel to the stored frame pixel's RGBif (distance > threshold) { // If that distance is smaller than the threshold, then checkif (x< leftMost)leftMost = x; // pixel is within the rectangle of the leftMost,topMost etc. if (x> rightMost)rightMost = x; // and if it isn't then increase the rectangle to containif (y< topMost)topMost = y;if (y> bottomMost)bottomMost = y;}}}


Masking/Remove Background - source code

Now That we know how to identify the pixels that have changed, we can also use that information to create a mask /key effect . This is sometimes referred to as frame subtraction because actually subtracting the RGB values of one frame from another will yield a similar effect. Here we'll try to create a green screen effect without a screen, our method will:

  • Copy the live video to the screen.

  • Visit all pixels and:

    • Get RGB of live video pixel

    • Get RGB of reference frame pixel

    • Compare the two sets of RGB with dist() and :

      • If the change is not great, copy a pixel from the image (Eiffel) to screen.


for (int y = 0; y < video.height; y++) {for (int x = 0; x < video.width; x++) { PxPGetPixel(x, y, video.pixels, width); // get the RGB of the live videoint videoR=R;int videoG= G;int videoB= B;PxPGetPixel(x, y, frameToCompare.pixels, width); // get the RGB of the stored framefloat distance = dist(R, G, B, videoR, videoG, videoB); // compare our live pixel to the stored frame pixel's RGBif (distance < threshold) { // If that distance is greater than the threshold then place PxPGetPixel(x, y, secondImage.pixels, width); PxPSetPixel(x, y, R, G, B, 255, pixels, width); // that pixel on the screen}}}

Feature based tracking and masking:

Many algorithms and libraries exist to do feature-based tracking. Typically these things are too complex to do from-scratch in your project but are very easy to use. The feature tat is most commonly tracked is the human body and human face, for those we have

Here are three examples for using the OpenCV face tracking. Make sure you add the library by going to sketch->import library->add library...

openCV paint with face - code example . Here we use the coordinates that are returned from openCV (it returns the rectangle of where it found a face) and just draw a circle, this yields a simple painting sketch.

openCV faces with camera fill screen - code example . Here we use the rect returned from openCV and use the copy() function to enlarge that region to fill the screen, the result is that the sketch "follows" you and grabs you face to fill the screen.

openCV faces with camera average - code example. Here we are expanding the "fill screen" example to average many faces as they are detected, the idea is that perhaps after a prolonged time it would create an average face... (Quite naive, but amusing, too bad we cant all try it together and see)


Artistic video effects

This belongs perhaps in the week 7 where we looked at compositing images. Some the effects for compositing images create very interesting results when applied to videos:

video random rects - code example. Here we play a video, note that the sound is played by default and our manipulations don't effect it or ruin it. Here we take random rectangles of the current frame of the video and use the copy() function to copy it with a random "shake" to the screen.

video glitch - code example. Here we are trying to create a glitch effect to video. We copy random rects from the current frame to the screen using blend() and changing the ink effect every second from 4 effects.

video datamosh - code example. Here are trying to simulate a datamosh effect. we compare the current frame pixels to the screen pixels and only copy pixels that are very different. The threshold is constantly changed to create a more dynamic effect that goes in and out from clarity.

video ghost frames - code example. Here we do the ghosting effect we did in week 6 between current frame and the screen using tint();

video ghost frames with floats - code example. Same effect but pixel by pixel with floating point precision eliminates posterization.

scratching video frames - code example. go to specific frames in the video. Note that this does influence the audio as well.

Assignment (Week 10)

Class 10 - Depth

Why depth in a pixels class?

Our class has focused on tools for creating, manipulating and perceiving images, predominantly employing pixels as the building blocks of visual information. Pixels are two dimensional, as are most images and certainly our displays are two dimensional, so what use do we have with the third dimension and the 3D tools of our programming language?

I can think of two reasons for using 3D in our class:

  • 3D blocks make for really great pixels, sometimes called voxels. Even though eventually we are viewing them on a 2D display our mind and eyes are very happy to see these objects as 3D. And there is a whole aesthetic that comes with the use of 3D pixels (voxels), think mindcraft.

    1. 3D worlds and objects use images as textures. The way most 3D objects get their intricate details is by having a geometric shape and stretching a texture on it. The textures are simple images, and images are what we do in this class, so all the stuff we learned can end up as a texture for a 3D object.

Let's Learn 3D (in processing)

We haven't noticed it yet, but all this time we were using a fully functioning 3D programming environment. In fact all the stuff we were doing was in a 3D space, we were simply looking at it straight-on so we couldn't appreciate it. The secret for unleashing the 3D power of Processing starts with the size() function. We have been using the default use of size(width, height); but we can optionally add a third parameter size(width, height, P3D); and now we have a few new capabilities (most 2D stuff also works in the P3D mode)

The coordinate system of Processing is expanded with the X and Y still the same, starting at the top/left corner and a third Z axis is added , starting from the same spot and going straight out perpendicular to the screen (minus goes in, plus goes out).

P3D mode makes extensive use of the three transforms:

Something to understand about the three transforms is that they are not applied to any particular object (you do not rotate an object) but rather they apply to all of processing's coordinate system (a less philosophical way of thinking of it is that it is applied to all objects that will be drawn after, a bit like CSS and HTML)

Let's give it a try:

void setup(){size (500,500,P3D);}void draw(){background(0);rotateY(mouseX/100.0);ellipse(0,0,100,100);}

This draws a rotating circle stuck in the top left corner, so we should add a translate() to move it to the center of the screen:

void draw(){background(0);translate(250,250);rotateY(mouseX/100.0);ellipse(0,0,100,100);}

Great. Now maybe we want another circle rotating in position 300,300. if we try to translate again it goes off screen because the transformations are relative, so we just added 300 to the 250 we had. Also if we do the second translate() after the rotateY() then it translates in an angle . This becomes pretty hard to predict very fast. For that we have the :

  • pushMatrix() - You should read the official explanation, I think of it as placing a marker so we can return to it.

  • popMatrix()- Again, read the explanation, I think of it as return to the state it was in the last pushMatrix()

So if we want two independent geometries we should:

  • pushMatrix

  • do the transformations for first geometry

  • draw first geometry

  • popMatrix

  • do the transformations for second geometry

  • draw the second geometry

void draw(){background(0);
pushMatrix();translate(250,250);rotateY(mouseX/100.0);ellipse(0,0,100,100);popMatrix();
translate(350,350);rotateY(mouseX/100.0);ellipse(0,0,100,100); }

Notice that we draw our geometry at position 0,0 but it lands in place because of the translation.

Notice that each circle rotates around it's center,( what would happen if we rotated first and then translated?)

So every 2D geometry, or image can be manipulated and viewed in 3D using the transforms, but there are a few objects that are really 3D:

So we can replace our geometry in the example above with sphere and box:

void draw(){ background(0); pushMatrix(); translate(250,250); rotateY(mouseX/100.0); sphere(50); popMatrix(); translate(350,350); rotateY(mouseX/100.0); box(100); }


The look of 3D geometry is determined with the fill(), stroke(), noFill, noStroke() commands. For realistic 3D usually a fill() and noStroke() are used. Here we can make the box wireframe and the sphere red:


void draw() { background(0);
pushMatrix(); translate(250, 250); rotateY(mouseX/100.0); fill(255, 0, 0); noStroke(); sphere(50); popMatrix();
translate(350, 350); rotateY(mouseX/100.0); noFill(); stroke(255); box(100);}

  • Notice that the sphere looks flat and monochromatic. This is because by default Processing does not turn on any lights, so our 3D geometry is not shaded. We can add some default lights by calling lights(). (must be called in draw() )

void draw() { background(0); lights();
pushMatrix(); translate(250, 250); rotateY(mouseX/100.0); fill(255, 0, 0); noStroke(); sphere(50); popMatrix();
translate(350, 350); rotateY(mouseX/100.0); noFill(); stroke(255); box(100);}

If you want to get fancy with the lights, there are many options-ambientLight(), directionalLight(), pointLight() etc.


Let's look at some samples that take advantage of these new tools:

PxP_3D_grid_of_boxes.pde - Here we create a grid of boxes by expanding our normal nested repeat loop of X and Y to include Z (nested in that order) then we pushMatrix, translate to the location and draw a box:

  • Repeat for X,Y,Z

    • pushMatrix

      • set a fill() color based on X,Y,Z

      • translate by X,Y,Z

      • draw a box

    • popMatrix

PxP_3D_video_block_pixels.pde - Here we create a pixelated image with boxes that are longer and shorter according to brightness of pixels (try uncommenting the variations on calculating z that add some motion):

  • Visit all X and Y pixels skipping every 20

    • get RGB of pixel

    • calculate brightness by (R+G+B)/3

    • set a fill() with RGB of that pixel

    • pushMatrix

      • translate by X, Y

      • draw box with size 20,20, and brightness for depth

    • popMatrix

PxP_3D_wooden_mirror - Here we create a pixelated image by tilting boxes according to the brightness of pixels (try dragging mouse to change size of boxes):

  • Setup a directional light from above

  • Visit all X and Y pixels skipping every 30

    • get the brightness of each visited pixel

    • pushMatrix

      • translate by X,Y

      • rotateX by the amount of brightness

      • draw box

    • popMatrix


beginShape/endShape:

Now let's look at the beginShape()/ endShape() commands. As easy as the box and sphere are, they are not really that useful, most complex 3D is made of faces , that is triangular flat surfaces, and the only way to get those is by using beginShape()/ endShape():


void draw() { background(0); lights();
translate(width/2, height/2); rotateY(mouseX/100.0); fill(255,0,0); beginShape(); // start the shape vertex(0,0,0); // first vertex vertex(200,0,0); // second vertex vertex(200,200,0); //third vertex endShape(); // close the shape}

Notice that the fill() call before the begineShape() controls the color of the whole face, but if we place the fill() calls inside the begingShape/endShape we can control the color of each vertex and get a smooth gradation between the corners:

void draw() { background(0); lights();
translate(width/2, height/2); rotateY(mouseX/100.0); beginShape(); fill(255,0,0); // fill color of first vertex vertex(0,0,0); fill(255,255,0); // fill color of second vertex vertex(200,0,0); fill(0,0,255); // fill color of third vertex vertex(200,200,0); endShape();}

PxP_3D_shape_with_color_gradation.pde - Sample that demos this.

PxP_3D_mesh_video.pde - Demos the use of beginShape/endShape to create a terrain based on brightness of pixels, Here is the process , it is slightly complicated by the fact that our pixel cells are square (10x10) but they are not necessarily flat so we need to divide every square to two triangles. In order to get a smooth image we are issuing a fill() cal for each vertex:

  • load video and blur it (optional)

  • visit all X,Y, pixels skipping 10

    • get RGB of every pixel and calculate brightness

    • divide each cell to 2 triangles and

    • beginShape , for top right triangle

      • issue fill commands with the RGB of the corner pixel

      • issue vertex commands to the topLeft triangle of each pixel cell

    • endShape

    • repeat same process for lower left corner triangle.


Using textures

So this gives us control of color per vertex , but what if we want to control the color per pixel ? for that we will use a texture(). In Processing a texture can be any image (PImage, video, movie).

So to use a texture we would:

  • Load an image or video

  • beginShape

    • call texture() to use the image as a texture

    • call vertex() to define each corner and each point on the texture that will be attached to that corner.

  • endShape

For this we need to understand the concept of the U/V mapping. What we are trying to do here is to marry a 2D point in the texture (a pixel ?) to a 3D point in the geometry. Once each point in the geometry will have an associated point on the texture it will stretch it like a rubber sheet. The U and V are just like the X, and Y: U is X, V is Y (but inverted ?).

PImage ourTexture;
void setup() { size (500, 500, P3D); ourTexture = loadImage("https://bestapples.com/wp-content/uploads/2015/10/gala.jpg"); ourTexture.resize(200, 200); }void draw() { background(0); lights();
translate(width/2, height/2); rotateY(mouseX/100.0); beginShape(); texture(ourTexture); // associating our image with the texture vertex(0,0,0 ,0,0); // each call to vertex has its XYZ and then its UV which are pixels of the image vertex(200,0,0, 200,0); vertex(200,200,0, 200,200); endShape();}

PxP_3D_shape_with_texture - Demos simple texture on a simple 3 vertex face

PxP_3D_shape_with_video_texture - Demos using live video as texture on a simple 3 vertex face


Lets look at a few examples that use the texture:

PxP_3D_paint_on_texture.pde - Here we paint on an mage and use it as texture, should be pretty simple but I am complicated it in order to allow transparency. So we create an empty PImage making sure it has alpha, so RGBA. then we load a file into that and we paint on that (try painting with a key pressed and see how it erases):

  • in setup():

    • create an empty image with RGBA pixels and load an image into it

  • in Draw():

    • draw the image on the right half of the screen

      1. beginShape

        • call texture() to associate our image

        • issue 3 vertex() to create triangle , and set U,V

      2. endShape

  • in mouseDragged():

  • visit a 20 pixels area around the mouse:

    • set the pixels opaque red (255,0,0,255)

    • if a key is pressed set the pixel transparent (0,0,0,0)


PxP_3D_draw_shapes_with_texture.pde - Here we are trying to "draw" shapes and then apply a texture to them, The idea of drawing a shape means that as you drag the mouse vertices are added in the mouse location, try drawing some small shapes. The implementation of this is a bit complex because I use objects to hold each "shard" and I hold all the shards in a growing array, here is a simplified explanation

  • in mousePressed():

    • add a new shard object to array of shards

  • in mouseDragged():

    • add the x and y of the mouse to the array inside the last shard

  • in draw():

    • visit all objects in the array of shards

    • for each shard:

      • beginShape

      • in every shard object , visit all x and y in the array and:

      • add vertex with the x and y and also same x and y as u and v

      • endShape

PxP_3D_texture_shards.pde - Very similar to he example above, here we do not draw thew shards, rather every time we click the mouse a random 4 point shard is created under the mouse. The steps in the code are quite similar too. One addition is that pressing a key makes the shards fall down and another key press makes them travel back up

Bonus topic - dealing with time:

Working with timers - working_with-timers.pde - this example shows how to create two timers with different intervals and without one waiting for the other.

Clock- clock.pde - This demonstrates working with real time clock, using the functions hour(), minute(), second() to get the time and using transforms and pushMatrix to create an analog clock.

Final Idea Proposal (Week 12)

< Processing with Video generated through Machine Learning >

< Hologram >

Final Presentation (Week 14)

  • Collaboration with Hyun

< Process (P5js) >

< Process (Colab / Machine Learning 4a) >

< Process (Processing with Kinect) >

< Final View >

Previous
Previous

Physical Computing

Next
Next

Programming from A to Z