1 / 17

Intro to Java & Processing

Intro to Java & Processing. Review . CS is about problem-solving To write programs you must Be able to solve the problem yourself Be able to describe the solution to another Be able to describe the solution to the computer (programming). Programming.

Télécharger la présentation

Intro to Java & Processing

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. Intro to Java & Processing

  2. Review • CS is about problem-solving • To write programs you must • Be able to solve the problem yourself • Be able to describe the solution to another • Be able to describe the solution to the computer (programming)

  3. Programming • Programs: how to tell a computer what to do • Each line is a command to the computer • The computer is stupid, so you have to type everything in exactly • If you make a mistake, you get an error and have to fix it • In this class, we use a programming language called Java • Java is called an Object-Oriented language

  4. About Programming • Java is Case-SENsITivE! • Punctuation matters • Spelling matters • File names matter • Spaces don’t matter much • Be careful! • Follow the examples…

  5. The tool… • IDE: Integrated Development Environment • A Program that does it all together, and it’s PRETTY… • One IDE is Eclipse

  6. Fun with Graphics • We use a Java library called Processing that makes graphics easy. • Just open a new Processing project and check out the src folder. • Pixels! • Color (RGB, 0-255, Additive model, think LIGHT!) • x,y value

  7. Computer Graphics

  8. How it works • 2 sections: setup & draw • Setup: stuff that happens when the window opens (once) • Draw: stuff that happens many times a second

  9. Processing commands • background(255,0,0); • size(800,450);

  10. Shapes • triangle(Ax,Ay,Bx,By,Cx,Cy); • rect(ULx, ULy, w, h); • ellipse(Cx,Cy,w,h); • What’s the difference in putting these in setup() vs draw()? Try it. • What’s the difference between drawing a rectangle then a triangle or the triangle then a rectangle? Try it.

  11. Circles & Arcs • Angles done in radians & clockwise • You must put the smaller number before the larger number. AddTWO_PI if you need to to get a bigger number.

  12. Shape Attributes • fill(R,G,B); • stroke(R,G,B); • noFill(); • noStroke(); • strokeWeight(n);

  13. Comments • Don’t do too much without comments! • // - one line comment • /* • paragraph */

  14. ERROR!! • Sometimes it just doesn’t work… • Types of errors: • Compiler error • No semicolon • public Class Program{ • Logic error • answer = 2+3; • “The anser is “ • Fatal or Runtime error • answer = 2/0;

  15. And then what? • Fix the program, save it, recompile, re-execute until everything works • The error is often called a “bug” • Fixing it is called debugging

  16. There’s lots more… • You get a cheat sheet and the API!

  17. PW0 • Make a face • Turn it in

More Related