1 / 19

Midterm Review

Midterm Review. Midterm Exam: March 12 Monday during class hours Open book Access to computers Grades will be out within the same week. Simple Shapes. Point: point(x , y); Line: line(x1 , y1, x2, y2 ); Rectangle: rectMode (CORNER); //default mode rect (x , y, width, height);

chace
Download Presentation

Midterm Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Midterm Review

  2. Midterm Exam: March 12 Monday during class hours Open book Access to computers Grades will be out within the same week.

  3. Simple Shapes Learning Processing: Slides by Don Smith

  4. Point: point(x, y); • Line: line(x1, y1, x2, y2); • Rectangle: • rectMode(CORNER); //default mode • rect(x, y, width, height); • rectMode(CENTER); • rect(x, y, width, height); • rectMode(CORNERS); • rect(x1, y1, x2, y2);

  5. Ellipse: • ellipseMode(CENTER); //default mode • ellipse(x, y, width, height); • ellipseMode(CORNER); • ellipse(x, y, width, height); • ellipseMode(CORNERS); • ellipse(x1, y1, x2, y2); • Circle is a special type of ellipse.

  6. Color: Grayscale • You can set the color of lines and background: • 0 is black (no ‘light’) • 255 is white (most ‘light’) • Some examples in processing: • background(255); // Sets background to white • stroke(0); // Sets outline to black • fill(150); // Sets interior of a shape to grey • noStroke(); • noFill(); Learning Processing: Slides by Don Smith

  7. RGB Color & Transparency • Each color has a value between 0 and 255 • colorMode(RGB,100); • colorMode(RGB,255,100,100) • Transparency • // 50% opacity • fill(255,0,0,127); • // 25% opacity • fill(255,0,0,63); • rect(0,150,200,40);

  8. Tracking the Mouse mouseX: The current X coordinate of the mouse mouseY: The current Y coordinate of the mouse pmouseX: The previous X coordinate of the mouse pmouseY: The previous Y coordinate of the mouse strokeWeight(width)

  9. Mouse clicks and Key presses mousePressed() //method keyPressed() //method mousePressed //system variable, boolean keyPressed//system variable, boolean

  10. Use of Variables Global and local variables

  11. frameRate() specifies the number of frames to be displayed every second. • The default rate is 60 frames per second. • random() returns a float. • Two arguments • random(1,100): a random float between [1,100) • One arguments • random(100): a random float between 0 (by default) and 100

  12. System Variables • width: Width (in pixels) of sketch window • height: Height (in pixels) of sketch window • frameCount: Number of frames processed • frameRate: Rate (per sec.) that frames are processed • screen.height, screen.width: Entire screen • key: Most recent key pressed on keyboard (ASC-II) • keyCode: Numeric code for which key pressed • mousePressed: True or false (pressed or not?) • mouseButton: Which button (left, right, center)

  13. if-else if (mouseX < width/3) { background(255); } else if (mouseX < 2*width/3) { background(127); } else { background(0); }

  14. constrain() • constrain() takes three parameters • the value we intend to constrain • minimum limit • maximum limt • constrain(r,0,255); • Returns the “constrained” value

  15. Logical Operator • And && • Or || • Not ! • Use a boolean variable as a button • Use a boolean variable as a switch

  16. Loops while loops for loops Remember that draw() itself is a loop!

  17. while loops • Plan the three parts: • What is the initial condition for the loop? • int y = 10; • When should the loop stop? • while (y < height){ • // loop • } • What is the loop operation? • rect(50,y,100,10); • y = y + 20;

  18. for loops Start at 0 and count up to 9 for (inti = 0; i < 10; i = i + 1) Start at 0 and count up to 100 by 10 for (inti = 0; i < 101; i = i + 1) Start at 100 and count down to 0 by 5 for (inti = 100; i >= 0; i = i – 5)

  19. Best way to study for the exam Go over the lecture slides Review the in-class exercises and homework I am here Monday through Thursday. Email me (ttian@kean.edu) if you have any question.

More Related