Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

axzcxzcv

  1. PROCESSING LANGUAGE

      Question 1 Printing in a Circle

    Write an Active Processing program that prints a quotation in a circle; see the example on the right.

    Choose a very short quote — a long quote does not fit easily in a circle in a 600 × 600 canvas. Here are some examples — you can choose from them or find your own:

    • Hope is a waking dream. — Aristotle

    • I can, therefore I am. — Simone Weil

    • Everything you can imagine is real. — Pablo Pi- casso

    • Short cuts make long delays. — J.R.R. Tolkien

    • The art is long, life is short. — Hippocrates

    • Anger is a short madness. — Horace

    • Whatever you are, be a good one. — Abraham Lincoln

The quote is stored as a String. In each frame, the quote is printed in a circle around a center point. In each frame, the entire quote is printed one letter at a time at gradually increasing angles around a center point so that the quote is printed in a circle. The starting angle (of the first letter) and the center point of the circle are different for each frame, but each frame shows the entire quote.

Here is what should happen in each frame:

  1. Start with a fresh canvas.

  2. Choose a random radius for the circle. It can’t be too small or the letters will be packed too tightly together to read the quote. The radius also can’t be too big or the letters will not all fit on the screen.

  3. Choose a random center point for the circle, such that all the letters in the quote will be visible in the canvas using the radius you just generated in the previous step.

  4. Choose a random angle for the starting angle at which the first character of the quote will be printed.

  5. Then write a loop to print the characters of the quote one-by-one, at equally-spaced increasing angles around the center point, starting with the first character of the quote at the starting angle. Use a for-loop, and make it count through the positions of the characters in the quote. Inside the loop, after each character is printed, increase the angle so that the next character is printed a bit further around the circle. Use the charAt()function to pick out one character of the String to print.

Use a canvas size of 600 × 600. Use 30 pixels as the size of the letters. Make sure the background and letter colours contrast sufficiently that the quote is easy to read. Compute an angle speed so that the characters in the String are equally-spaced around the circle by dividing TWO PI by the length of the String. Slow the frame rate down to something like 0.5 — using command frameRate(0.5); so that the marker has time to read the quote during a frame before it is redrawn in the next frame.

Question 2: Printing in a Spiral

This question changes your program so that instead of printing a quote in a circle, it is printed in a spiral; see the example on the right.

Choose a longer quote than you used in Question 1 so that you get at least a couple of rotations to the spiral. The example uses the first line from “Pride and Preju- dice” by Jane Austen. You can use that quote or choose another of a similar length.

Notice that the first character of the quote is on the outside of the spiral and the last character of the quote is on the inside of the spiral.

The quote must be printed from the inside of the spiral to the outside. So the last character of the quote must be the first letter you print in a frame, and the first character of the quote must be the last letter printed in the frame. So the String is printed in backwards order, one character at a time.

Save a copy of your original Question 1 program. You must hand in the original circle version, as well as this modified spiral version. Rename this copy so that it ends with A3Q2.

Here is what should happen in each frame:

1. Start with a fresh canvas.

2. In this question, always use the center of the canvas as the center of the spiral (not a random center).

  1. Choose a random radius for the beginning of the spiral in the interior of the spiral. This starting radius can’t be too small or the letters will be packed too tightly together to read in the interior of the spiral. The radius also can’t be too big or the entire quote will not fit on the screen.

  2. Choose a random angle to be angle at which the interior of the spiral begins.

  3. Now you must write a for-loop that will print the entire quote in this frame:

    • Print the characters of the quote one-by-one in the loop — do this by making the for-loop count through the positions of the characters in the quote.

    • The loop must print the last character in the quote (the rightmost character) FIRST.

    • The loop must print the first character of the quote (the leftmost character) LAST.

    • That is, your loop must work backwards through the string (from right to left) — it is counting DOWN, not up.

    • The last character of the quote is printed at the starting point in the interior of the spiral.

    • Each subsequent character printed is printed at a slightly larger angle and a slightly larger radius than

      the previously-printed character.

    • In other words, inside the loop, after you print each character, you must increase the angle slightly and also increase the radius slightly.

      Choose the angle speed and the radius speed so that the characters in the quote are readable (not printed on top of each other).

      Remember that, in each frame, the entire quote is printed.Use a canvas size of 600 × 600. Use 30 pixels as the size of the letters. Make sure the background and letter

      colours contrast sufficiently that the quote is easy to read. Experiment with different radius and angle speeds until you find values so that make the characters in the String easily readable. Slow the frame rate down to something like 0.1 — using command frameRate(0.1); so that the marker has time to read this longer quote during a frame before it is redrawn in the next frame.

      What information needs to be remembered from frame to frame in this question — that is, what global / state variables do you need? Hint: few, if any!

      Question 3: Letters coming out a Spiral

      In this question, you will rewrite your program so that the long quote comes out in the spiral gradually, over many frames. For example, the pictures below show some snapshots of the execution of the sample solution; the left picture below shows the second frame drawn by the program, the middle picture shows the seventh frame, and the right picture shows the 13th frame.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question