0% found this document useful (0 votes)
11 views11 pages

Ton Connor 5 P 2 App

The document outlines an app designed for drawing various shapes on a canvas using specific procedures for each shape, including squares, triangles, pentagons, and circles. It details the coding logic behind each shape's creation, utilizing loops and parameters for flexibility. Additionally, it includes features for drawing flowers with customizable petal visibility and an extra credit procedure for creating dynamic shapes.

Uploaded by

connorton2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views11 pages

Ton Connor 5 P 2 App

The document outlines an app designed for drawing various shapes on a canvas using specific procedures for each shape, including squares, triangles, pentagons, and circles. It details the coding logic behind each shape's creation, utilizing loops and parameters for flexibility. Additionally, it includes features for drawing flowers with customizable petal visibility and an extra credit procedure for creating dynamic shapes.

Uploaded by

connorton2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

5p2 App Write Up [265] Period: Name:

Overview & Purpose ( [10] screen cap, [5] App Title, [10] Describe)

Logo 2

This app helps the user draw shapes on a canvas with a


predetermined draw button that draws different shapes.

Viewer [10] & Components [10]


Complete Code

[10 + 10] Variables

This global variable is used to determine if petals in a flower are going to be printed or not.

0. [15 + 10] square

This procedure uses a for each number loop to print out a square. The code is repeated 4 times by moving
forward 100 pixels and then turning 90 degrees to the right. This is done 4 times to create a square.
1. [15 + 10] squareSpecSide

This procedure uses a for each number loop, with the ending number being 4 to create a square. The
code calls forward to be moved however many pixels the coder puts in the parameter and then turns 90
degrees.

2. [15 + 10] triangleSpecSide


This procedure uses a for each number loop that runs 3 times. The loop calls the forward procedure and
moves the pen L amount of pixels and turns 120 degrees, creating a triangle.

3. [15 + 10] pentagonSpecSide

The drawPentagon procedure uses a for loop that runs 5 times, 1 time for each side in the pentagon. The
loop calls forward L amount of pixels and to turn 72 degrees, creating a pentagon.
4. [15 + 10] polygonSpecSide

The drawPolygon procedure uses a for loop to determine how many sides this polygon will have depending
on info put into the parameter. The loop calls the forward procedure to move L amount of pixels forward.
Then the turn procedure is called, how many degrees the pen should turn depends on how many sides the
user wants the polygon to have. Which is 360/N to figure out how much the pen should turn.

5. [15 + 10] circle

To create a circle, the drawPolygon procedure has to be used. The code calls the drawPolygon procedure
and setting the length of each line to 5 pixels and the number of sides to 100, the drawing resembles a
circle.

6. [15 + 20] flower

The drawFlower procedure uses a for loop that runs 24 times. The loop draws a square with side lengths of
100 and then to turn the pen by 15 degrees. Then the code sets the canvas’s paint color to a random color
that is generated that draws the squares.
7. [15 + 20] flower with 20% missing petals

The drawFlowerMissingPetals uses a for each number loop that starts at 1 and ends at 24, running 24
iterations. The loop sets the global variable missingPetals to a random integer from 0 to 100. Then an if
statement is used to check if the global missing petals is less than 80, if the number is less than 80 then a
square is drawn and the paint color is randomized. If the missingPetals number is above 80 then the code is
not ran and the turn procedure is called to turn 15 degrees.
8. [15+ 10] extra credit
This procedure uses a for loop for 1 to 75 so that the loops runs 75 times. The loop moves the pen
forwards L amount of pixels before turning the pen X amount of pixels. Then L is increased by 3 pixels and
X is increased by -0.01 pixels to create that rotating shape feeling.

You might also like