3. Program a Shape

Playback Speed:
Language:
Transcript

In the previous video, you stored each slide of your presentation in a variable of your function.

In this video, you will program code to add shapes to your presentation using this variable.

To start, press enter to go to the next line in your script editor.

The code you program in this video should still be within the curly braces that hold your function...

below the line that declares the slides variable.

Type “slides,” “open bracket,” “zero,”...

Slides zero indicates that you are working with the first slide in the presentation.

Computer code often starts counting at zero, rather than one.

Next, type a period to open the autocomplete menu.

Select insert shape.

Insert shape tells the computer application the type, position, and size of the shape.

To select a shape, add an open parenthesis and Slides app.

Remember to match the code you see on screen exactly.

Then, type a period, and select shape type from the menu.

Type another period to see a list of shape options to choose from.

Choose the shape you would like to use for your progress bar.

To set the position of the shape.

Type a comma after the shape.

And the numbers zero and “three-hundred-ninety-five.”.

This will place the shape in the bottom left of the slide.

Then, the number 10 typed twice, to set the size of the shape.

Save and run your program.

Now, look at the first slide in your presentation.

Nice job -- your shape is at the bottom of the first slide!

If you don’t see your shape or you get an error message, that’s okay.

Troubleshoot the solution by looking at the error message and ensuring that your code matches what you see on screen exactly.

Currently, your program places one shape on the first slide.

But, a progress bar requires a shape representing every slide in the presentation and one shape to be colored in with each slide.

You could program a line of code for every shape.

But if you had a long presentation, that would take a lot of code.

For example, if your presentation had 10 slides, you would have to program 10 lines of code for each slide.

That would be one hundred lines of code!

So, in the next video, you will program a loop to repeat the code for you.

This will save you lots of time and effort.

Instructions

  1. Add a shape to the first slide of the presentation.
  2. Set the position of the shape.
  3. Save and run your program.
  4. Troubleshoot any errors.