Computational Media




Week 2 - Animation and Variables

EVERYTHING SOUNDS LOGICAL IN MY HEAD

This week was challenging. I guess I’m having a hard time figuring out how to write down what’s inside my head. Even though is feels/sounds logical in my head, the code won’t work as how I imagined it would be. During our 1:1 session with Sam, everything was alright. At least I got to understand the syntax for variables and their placement clearly. For the example on the right, we used background under the setup function to see the movement of our circle. Even a small change in the code can lead to something totally different.

      

Questions: 

1- For Worksheet Q4, I managed to the circles to the corners and to up-down-right-left.  But when I modifies the canvas size, it looked like an explosion. 

   


function setup() { 
createCanvas(400, 400);
  x = width / 2; 
  y = height / 2;

function draw() { 
background(220);
  x += w2h; 
  y += w2h;

//moving to  bottom right corner 
ellipse(x, y, 10);


I used the same logic with Q2-3, but for this challenge it didn’t work. 

2- I wanted to experiment with mouseX and mouseY. (https://editor.p5js.org/zelifergin/sketches/OzHihefhG)
When mouse was pressed, I wanted to see a red circle with blue stroke. But I also saw that red-blue circle when my mouse wasn’t pressed. How did this happen? I feel like this is mostly related to conditionals because my circle changes color when x>=200 even when the mouse it pressed.

let x;
function setup() { 
createCanvas(400, 400);   
x = width / 2}

function draw() { 
background (230) 

if (mouseIsPressed) {   
fill('red');   
stroke('blue');   
strokeWeight(mouseX / 50);   
ellipse(mouseX, mouseY, 20, 20);  }

else {   
fill(255);    stroke(0);  }   

if (mouseX < 200){   
ellipse(200, 200, mouseX, mouseY);      }  
if (mouseX >= 200){   
fill('green');   
strokeWeight( mouseX / 10);   
ellipse(200, 200, mouseX, mouseY);      }  }



   





---






         

















 
Lipsum™
Integer turpis massa, varius ultricies est sed, aliquet feugiat enim. Nulla facilisi. Ut in justo in ex faucibus ultricies. Proin id erat quis lorem vehicula commodo. Phasellus pharetra libero pretium ultricies aliquam. Vivamus eleifend, ligula ut venenatis aliquet, massa elit efficitur lorem, fermentum molestie elit ligula in ex. Duis mauris tellus, pharetra et orci a, aliquam imperdiet augue. Pellentesque elit neque, tincidunt sit amet imperdiet eget, porta ut metus. Nulla id leo tortor. Donec elementum ac sapien eget feugiat. Donec lorem dui, vestibulum quis nisl et, feugiat mattis massa.


Phasellus Rez

Praese
Suspendía

Lipsum Deus

  1. Praese Vita
  2. Nulla Vehicu AI
  3. Ukam Cors
  4. Dictum Magna
  5. Cursus Ex
  6. Suspendis Est
  7. Facili Sap
  8. Et Magni Disc
  9. Phasellus Deus
  10. Deus
  11. Rexus
  12. Maximus
  13. Lorem Ipsum
  14. Dolor 123




©MMXXI
Integer turpis massa varius