Workbook 2: Graphics APIs and Drawing Basics
CS559 Spring 2023 Sample Solution
This is a sample solution for the Workbook. You are welcome to refer to it to learn one way to do the assignment but only after you have turned in your own assignment
Remember to look at these web pages using a local web server! For more information on using a local server, see the Tools for 559 page.
You may have noticed from this week’s assignment that we will be doing non-trivial JavaScript programming. If you feel like you need to accelerate your learning, see the Javascript in CS559, specifically the “Advice on Learning JavaScript” section.
Learning Goals
- To introduce the idea of object-based graphics as opposed to image-based graphics
- To show the two different types of graphics APIs, immediate mode and retained mode
- To give you experience programming with the Canvas API that web browsers provide
- To give you exposure to SVGs, which we will look at more in the future
- To see how the event and animation loop models introduced in the previous workbook are used in graphics
- To introduce the concept of display lists
- To practice with reading and writing JavaScript programs with actual graphics programs
What you should do with this Workbook
This workbook assumes you’ve already done the previous week’s workbook, and are familiar with the mechanics of doing assignments and turning them in using GitHub, as well as looking at web pages with JavaScript programs. Remember to look at the workbook with a local web server.
You are welcome to look at any of the files in the workbook. However, you can read the text of the pages in the web browser.
The files for you to read the source code are stored in the for_students/
folder. For this workbook, you probably just need to look at the JavaScript .js
files.
This includes files that need to be modified for the exercises, but also source files that you should read and understand to learn about web programming.
We will ask you to make changes to some of the programs, and also write some of your own.
For this workbook, you should not need to add any files to the workbook.
This workbook also has links to required readings. Make sure you read them. Even if you don’t need it to complete the workbook assignment, you will need the information for other parts of class (for example, you may see questions on the surveys or exams). Sometimes the readings are information you will need for future weeks.
This workbook has 9 pages total. There are exercises for you to do scattered about.
Don’t forget to commit and push your work as you go - this way you’ll have a backup in case something goes wrong. Also, don’t forget to do the Canvas Assignments WB2 and WB2G when you are done to tell us that you’ve completed the workbook and that we can grade it.
Readings
In addition to the pages and code of the workbook, there are a number of things you will be asked to read. It may work best to read the workbook, and go to the external readings when they come up.