Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Basic setup

From: Interactive Data Visualization with Processing

Video: Basic setup

We're now at the point that we can start Sketching and Processing. Now normally when you learn a new programming language, you begin by writing some code and getting some text output, like "Hello, World!" Now something we are perfectly capable of doing in Processing like this, and once I have that I can press Run by clicking on this button or I can press Ctrl+R on the keyboard for a PC or Cmd+R on a Mac. And what I get is an empty display window, because I have no graphical commands.

Basic setup

We're now at the point that we can start Sketching and Processing. Now normally when you learn a new programming language, you begin by writing some code and getting some text output, like "Hello, World!" Now something we are perfectly capable of doing in Processing like this, and once I have that I can press Run by clicking on this button or I can press Ctrl+R on the keyboard for a PC or Cmd+R on a Mac. And what I get is an empty display window, because I have no graphical commands.

There you see right at the bottom in the message box, I have "Hello, World!" So I've successfully created my first Processing program. But the beauty of Processing is that it's able to do graphical output from the text. And so the simplest way to start in Processing is to draw some basic shapes, also known as primitive shapes or geometric primitives. Now not only is this a good place to start for learning Processing, it's also good Processing for data visualization, as the shapes form the basis of most visualizations. So I am going to comeback to my Sketch here and I'm going to set a Sketch Window size.

To do that I type size and then in parentheses () I put the number of pixels wide and the number of pixels tall, I will do 600 x 200 and then I put a semicolon (;) at the end to say I am finished with that particular comment. Now you see by the way that Processing is coloring the commands, print line and size are recognized known commands in Processing, so put some in orange color. And now if I click Run, you will see that I have a larger display window, it's still empty, because I am not putting anything in it, but it is 600 x 200 pixels, I'll close that now.

Now one important thing to understand if you're not familiar with programming is that like most other programs, the counting for pixels in a window starts at 0, 0 like the graphs you're used to, but they start at the top left and the x-coordinates increase as you go to the right, but the y coordinates increase as you go down. There are a lot of good reasons for this, but it can be a little disorienting if you're not accustomed to it. Now there are a couple things that I want to do here that I always do when I start a new window.

First I set the size of the window and then I turn on anti-aliasing, which makes things a little smoother. In fact, the command for that in Processing is smooth and then I have to put opening and closing parentheses () and a semicolon (;). Now the reason I have the parentheses () with nothing in them is because functions require arguments, smooth is a function and the empty parentheses () indicate that while it is a function there are no arguments or extra information needed for it to do it. However, it does have to have them, so I put smooth open and close parenthesis () then I finish with the semicolon (;).

Now if I want to draw a circle, I'm going to show you a lot more about this, but I can do it like this, in Processing there is not a built in circle command, but there is a ellipse command, and if you want to make a circle you just make them the same height width. So what I am going to do is I am going to type ellipse then in the parenthesis (). I have to first locate the ellipse, I'll put it right in the middle so that's 300 pixels over and 100 pixels down, then I pick the size of the ellipse, this is diameter by the way. So I am going to put it 100 wide and 100 tall, close the parenthesis, semicolon (;) and now if I press Ctrl+R on a PC or Cmd+R on a Mac to run the Sketch and I get my circle.

And in one sense this is the "Hello, World!" For Processing, because Processing is designed for graphical output and that's what I have here first. I am going to close this again, now one of the things I can alter in my sketch very easily is the background color. By default the sketch is gray. Let's take another quick look at it. I have a middling gray background and have a white circle with a black outline if I want to change the color of the background all I have to do is enter the function background all lowercase. Now please make sure if you enter that command, to enter it before you draw the circle or the background will cover up the ellipse. I've mentioned before that the order of operations matters in Processing.

So I am going to type in background and in the parenthesis () I get to put the code for the color I want. Now if I put a single number here, it's going to give a grayscale, it goes from 0 for Black up to white. Now it is not 100 at the top, it's 255, that's because it's an 8-bit Color Scheme. If you're not familiar with this, it can seem a little disoriented to go up to 255, but it has to do with binary numbers, and it's a very common approach with computer graphics. If I want it to be black, I just put in 0. I close the parenthesis, put a semicolon (;) and I can hit Run.

And now I have a black background for my white circle. On the other hand, if I want a white background, I can change the 0 to the maximum value of 255. Now have a white background with my white circle. Finally, if I want it to be a color background, I can use a three component coding system, it's the RGB, Red Green Blue, system that's common in Computer Graphics. In this particular case I'll just make it Red by putting the Red value at its maximum, and the Green and the Blue components at their minimum.

Please note, I have got the three numbers, they are separated with commas (,) and they're still in the parenthesis () and finish with the semicolon (;) now I hit Run and have a brilliant red background with my white circle. Now there's just one more thing I want to show you in this particular sketch and that's how to add comments to a sketch. I personally find it's very useful to comment to indicate what you're doing. Now, I generally comment more than other people, in my own work I attend to comment every single line, which is probably excessive, but makes it very easy to read the code.

I will not be commenting this much in this course, because I'll be describing in words to you, what each program is as I go through. However, I'm going to add a comment right here, by going to the top I'm going to click a print line and move that down a little bit. Now I am going to add a comment with the name of this file, I find that to be a helpful thing in general. Now because this is going to be a single line comment, what I do is I put two slashes //. These are the slashes that are down by the question mark (?). Then I put a space here and then I can put the name of this particular file.

And that helps me identify it in case I have got several files open. And you can see comments are by default colored gray in Processing, and if I want to add a comment somewhere else, I can put one for instance, after a line of code. Right here I can put a couple of spaces with two slashes and put Red background. And that's one way of keeping track of what I'm doing in this. Now if I'm going to have a comment that is more than one line long, for instance, I want to put an entire paragraph in, the way to do that is with a (/*).

So I'll come down to the bottom here, I put (/*), I can go to the next line if I want. This is a very long comment. Once I have the entire comment in, I can finish with an (*/) and now Processing knows that I'm done with the entire comment. Again, this can be very helpful, both if you intend on sharing your sketches with other people and for helping you reconstitute the sketch if you come back to it at a later time. Then as a final note, each sketch will be saved in the folder with the exact same name as the sketch.

So if you go and manually change the name of the folder, you need to make sure that the sketch has the exact same name, the only exception is that the sketch will have the .pde Extension on the file, and with that we're ready get drawing in Processing

Show transcript

This video is part of

Image for Interactive Data Visualization with Processing
Interactive Data Visualization with Processing

72 video lessons · 12214 viewers

Barton Poulson
Author

 
Expand all | Collapse all
  1. 3m 16s
    1. Welcome
      58s
    2. What you should know
      1m 22s
    3. Using the exercise files
      56s
  2. 11m 51s
    1. Overview of data visualization
      11m 51s
  3. 11m 53s
    1. Installing Processing
      3m 38s
    2. Overview of Processing
      4m 5s
    3. Exploring libraries
      4m 10s
  4. 1h 1m
    1. Basic setup
      7m 31s
    2. Drawing points
      4m 37s
    3. Drawing lines
      5m 6s
    4. Drawing ellipses and circles
      5m 24s
    5. Drawing arcs
      6m 54s
    6. Drawing rectangles and squares
      4m 58s
    7. Drawing quadrangles
      3m 25s
    8. Drawing triangles
      2m 55s
    9. Drawing polygons
      3m 37s
    10. Drawing simple curves
      4m 54s
    11. Drawing complex curves
      6m 46s
    12. Drawing Bézier curves
      5m 38s
  5. 54m 3s
    1. Introduction to variables
      10m 44s
    2. Understanding variable scope
      6m 53s
    3. Modifying variables
      9m 8s
    4. Creating arrays
      9m 53s
    5. Modifying arrays
      6m 37s
    6. Creating strings
      7m 3s
    7. Modifying strings
      3m 45s
  6. 1h 2m
    1. Incorporating randomness
      7m 59s
    2. Using Perlin noise
      4m 24s
    3. Shuffling with Java
      3m 30s
    4. Specifying line attributes
      8m 2s
    5. Changing placement modes
      5m 45s
    6. Understanding color attributes and functions
      4m 16s
    7. Exploring color spaces
      7m 44s
    8. Using color palettes
      7m 5s
    9. Transforming the grid
      8m 38s
    10. Exploring the attribute matrix
      5m 33s
  7. 52m 7s
    1. Building code blocks
      5m 57s
    2. Writing a while loop
      3m 52s
    3. Using for loops
      5m 35s
    4. Creating conditionals
      14m 50s
    5. Working with easing
      10m 51s
    6. Creating spirals
      11m 2s
  8. 18m 55s
    1. Mouse tracking
      3m 54s
    2. Hovering and clicking
      11m 16s
    3. Understanding keyboard interaction
      3m 45s
  9. 27m 32s
    1. Specifying fonts
      6m 43s
    2. Using images
      5m 51s
    3. Playing a video loop
      6m 20s
    4. Exporting video
      3m 47s
    5. Adding sound
      4m 51s
  10. 20m 49s
    1. Creating functions
      11m 48s
    2. Creating classes and objects
      9m 1s
  11. 31m 10s
    1. Using embedded data
      5m 26s
    2. Working with appended text data
      6m 4s
    3. Working with appended tabular data
      10m 26s
    4. Reading XML data
      9m 14s
  12. 48m 17s
    1. Generating dot plots
      11m 11s
    2. Building scatter plots
      10m 0s
    3. Making line plots
      9m 55s
    4. Creating bar charts
      9m 12s
    5. Checking out examples of maps, hierarchies, and networks
      7m 59s
  13. 20m 57s
    1. Introducing some principles of 2D design
      13m 44s
    2. Understanding color theory
      7m 13s
  14. 24m 46s
    1. Interacting with zooming, rotating, and sliding
      6m 26s
    2. Implementing slicing
      6m 47s
    3. Using rollovers
      5m 58s
    4. Introducing the GUI libraries
      5m 35s
  15. 10m 35s
    1. Sharing via OpenProcessing and other sites
      3m 19s
    2. Saving as a desktop application
      2m 42s
    3. Saving as JavaScript
      1m 47s
    4. Saving as an Android application
      2m 47s
  16. 2m 38s
    1. Where to go from here
      2m 38s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Interactive Data Visualization with Processing.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.