CMSC 160 -- Lab 10

Lab 10

Getting Started

  1. Log into the computer science server and create a new directory named public_html.
    mkdir public_html.
  2. You will need to change the permissions of the public_html directory.
    chmod 755 public_html
  3. Now you will need to change the permissions on your account.
    cd ..
    chmod a+x your_account_name
  4. Now change back to your home directory.
    cd

Download your lab file

  1. Use wget to download the file at http://cs.longwood.edu/courses/cmsc160/f17/files/lab10.tgz
  2. Uncompress the lab10.tgz file by using tar -xvzf lab10.tgz
  3. Use ls to see that there is a new directory called lab10
  4. Use cd lab10 to change directory to the lab10 directory

The Problem

We will be using scalable vector graphics (SVG) files in this lab. SVG files are text files which can be displayed as graphics when viewed in a web browser.

You will need the following structures:
  • Point
    an integer x and an integer y
  • Color
    an integer red, an integer green, and an integer blue
You will need to write the following functions:
  1. svgHeader
    input: a Point containing the width in the x field and height in the y field
    output: a string containing the code for svg header
  2. svgSquare
    input: a Point location, an integer size, and a Color color
    output: a string containing the code for svg text
  3. svgCircle
    input: a Point location, an integer radius, and a Color color
    output: a string containing the svg circle
  4. svgText
    input: a Point location, and a string text
    output: a string containing the code for svg text
  5. randomPoint
    input: a Point containing the minimum possible random value and a Point containing the maximum possible random value
    output: a random Point between the minimum and maximum values
An example SVG file is provided here.

You will output an svg file named demo.svg which will contain 50 randomly placed circles and 50 randomly placed rectangles. Each circle and rectangle should have text indicating the number.

Each time you run your program you will want to copy your demo.svg to your public_html directory. You can do this with the following command:
cp demo.svg ../public_html/

Your output should look something like this.

Handin

Your completed lab is due on Nov. 7th at 11:59pm. It should be handed in by using the make handin command.