6. Program a Conditional Statement

Playback Speed:
Language:
Transcript

In the previous videos, you added shapes to each of your slides.

In this video, you will color in the shapes to indicate progress.

For example, when you are on the first slide, only the first shape will be colored in.

When you are on the third slide, the first 3 shapes will be colored in.

To create this process, you’ll use a conditional statement.

In this case, the color of the shape will change if "J" -- which keeps count of the shapes -- is less than or equal to "i", which keeps count of the slides.

To start, choose the color you want to use.

The color you select will have RGB values.

RGB stands for red, green, and blue, which can be combined to make any color in the spectrum.

To find the values of a color for your progress bar, do a web search.

Open another tab in your browser.

Then, go to google.com Search for "RGB values".

Select a website with an RGB color picker tool.

Click on different colors to see their RGB values.

Choose the color you want to use in your progress bar.

Write down the RGB values of your color or leave the color picker website open in another browser tab.

Then, return to the script editor.

Now, press enter after the code that adds the shape.

Type “if,” space, “open parenthesis” “J,” “is less than or equal to i”...

and an open curly brace.

Now, store the shapes on the slide within the conditional.

Press enter, and on the following line, type “v-a-r shapes,” equals slides...

“open bracket," "i"...

Then, type a period, and select get shapes from the menu.

Then, add an open parenthesis.

Add a semicolon.

Press enter.

On the next line, get the last shape drawn.

Type “v-a-r last shape,” space, equals, space, shapes, “open bracket," "shapes" .

Type a period, and choose length.

Then, type minus one, and a semicolon.

To fill your shape with the color you selected from the RGB color picker, go to the next line.

Type "last shape" then a period.

And select get fill.

Then, add an open parenthesis.

Type another period, and select set solid fill.

Then, add an open parenthesis.

Type the RGB values for the color you chose.

Make sure your code keeps the commas and spaces between each value.

Save and run your program.

Now, take a look at your presentation.

Click through all 5 slides to watch your shape become filled with color.

Great job!

You now have a progress bar that adds color to a shape with each slide you advance.

Don’t worry if you get an error message -- you just typed a lot of code!

Take a moment to read the error message, compare your code to what’s on screen, and troubleshoot the problem.

Instructions

  1. Search for RGB values, and use the color picker to choose a color.
  2. Program a conditional statement.
  3. Add your color’s RGB values.
  4. Save and run your program.
  5. Troubleshoot any errors.