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

Exploring color spaces

From: Interactive Data Visualization with Processing

Video: Exploring color spaces

Processing allows you to specify colors in several different systems or color spaces. Now the most common one is the RGB, Red, Green, Blue, or you can use either a three numbers on a 0 to 255 scale or you can use a single hex code. The other of choice is what's called an HSB system, which stands for Hue, Saturation and Brightness which is also common. Although it tends to use a different scale system where the Hue part is specified on the 360 degree circle and the Saturation and Brightness are specified on 100% scale.

Exploring color spaces

Processing allows you to specify colors in several different systems or color spaces. Now the most common one is the RGB, Red, Green, Blue, or you can use either a three numbers on a 0 to 255 scale or you can use a single hex code. The other of choice is what's called an HSB system, which stands for Hue, Saturation and Brightness which is also common. Although it tends to use a different scale system where the Hue part is specified on the 360 degree circle and the Saturation and Brightness are specified on 100% scale.

In this movie I want to show you how to use each of these different color spaces to get what you want in your drawings. I'm going to start by just putting a little comment with the name of this sketch. Like the last movie I'm going to start by specifying the size of the window, I'm also going to turn on anti-aliasing. I'm going to turn off the strokes on the shapes. I'm going to put in a background, let's say relatively dark gray and I'm going to position the rectangles by their centers.

Then I'm going to use two variables that help me position the rectangles. The first one is the number of rectangles that I want to draw. I want to use four in this case and then I'm going to use a float variable for X to help me get the positions for each one of this, and that'll be the width of the window divided by n+1, that'll give me the center points for each of the rectangles. Then what I do, because I put in the code for the rectangles, I'll do X times 1 and we'll put them the center halfway down and I'll make them 100 pixels wide and 100 pixels tall.

Now what I'm going to do though is I'm going to start specifying the colors. I'm going to use a green that I had from the previous movie and I'll specify this in the default RGB way that we normally like to use in Processing. So what I'm going to do is I can specify fill and I'm going to put in 116, 173, 146. And when I do that I get a green box here on my gray background. Now as you've seen a number of times, you can also use hex code to specify these. Now if it turns out that you have a color that you like and you know either the three RGB codes or you know the hex code, there is a way to get from one to another.

What you do is you come up to Tools and you come to Color Selector and what you can do here is you can enter the colors that you have, so right now my RGB is 116 and the G is 173 and the Blue component is 146 and then you see that that's the same one that I have up here on the top and right down here is the hex code that I need. It's 748092, so I'm just going to copy that, I'll put it down here for a second, because now I'm going to copy this, the rectangle information and I'm going to specify fill by putting in this hex code, I can delete this line, and I'll move this over to the next space.

So, what I have here is the same color specified two ways, this is the three number RGB code, and the next one is the unitary hex code, which actually is a version of the RGB code. And so when I press Run, I get to identical squares right next to each other. Now it turns out that there is an interesting alternative, you saw also that there was the HSB system, if I can go back to that window, that's where hue, saturation and brightness, and when I put that in here, what I have to do is I have to tell Processing that I'm using the HSB, Hue, Saturation, Brightness color mode, so I put in colorMode and I'll put in HSB.

Now, by default it's RGB, and if I wanted to, I can copy that and put it up here earlier, and put RGB, but that is the default, I don't need to do that. What I'm going to do down here is I'm going to put in HSB, but HSB uses a different set of dimensions. Now by default, Processing will try to use the 0 to 255 system, even though on the color selector it gave me the hue in terms of degrees around in a circle, and the saturation and brightness in terms of 0 to 100%, so you need to actually specify that and what you can do here is when you put the color mode, you put HSB, you can then put numbers to specify what is the maximum value for each of the components.

In this case, I say that the Hue, it has a maximum value of 360, Saturation and Brightness, each of them maximum 100. Then what I can do is I can come down and I can specify the fill using those numbers. If I go back to the Color Selector, I see they're 151, 32 and 67; 151, 32 and 67, and then I'm going to draw a rectangle again, and put that down right here and then I've a third rectangle with an identical shade of green.

Now I'm going to show you one other trick, there is a fourth way of working with colors that is similar to the color selector. If you go up to Tools in the menu and go to the bottom to Add Tool, one of the choice is, is what's called the Color Selector Plus, if you click on that and click Install, let me close that. Now we come back to Tools and the Color Selector Plus is an option near the bottom. This is a similar tool, but you see it's got a lot more choices and it let's you to do some other things that you couldn't do otherwise.

What I'm going to do here is I'm going to take the hex code that I have for the color and I'll just paste it in right there and it brings up the one. And now what you see here is we have the RGB codes, the 116, 173 and the 146, that's the same. And then we have Hue, Saturation and Value. Now what's interesting is this one is using a slightly different system here to do the things. This one is actually using a 0 to 255 scale for the Saturation and the Value, so what I'm going to do now, actually I'll just copy all of this.

It's still an HSV and HSB are the same thing or Value and Brightness, just two different terms for the same thing, so I can leave it as HSB, but I do need to specify that I'm on a 255 scale for this. It would be nice if that were indicated more clearly on this, but we have what we have. And so the Hue is still 151, but the Saturation goes from 32 to 84, because I'm on a different scale, and the brightness or Value goes from 67 to 173, and otherwise, I draw in my fourth rectangle, I can close this, it floats and stays on the top of everything.

I'm going to Save this and Run, and there you go. And I've noticed that some times you get very slight variations in color, because I assume things like rounding errors, but these are different ways of specifying the same colors, four different ways these three number RGB system, the hex code for the RGB. You can specify the Hue, Saturation, Brightness using Processing with 360, 100, 100 system or you can use the Color Selector Plus, which also uses the HSB or HSV with 360, 255, 255 system.

Anyhow, these are different ways of specifying colors, and depending on your purposes, each one of this can be very useful in producing your own images and visualizations.

Show transcript

This video is part of

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

72 video lessons · 12136 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.