%The shape drawing program
 
%Daniel Simmonds and Martin Lindsy
 
%January 27 2005
 
setscreen ("graphics:max;max,nobuttonbar")  %makes screen larger and removes the button bar
 
var shape, nothing, box_col : string  %creates variable able to hold both numbers and letters
 
var box_base, box_height, box_col1, radius : int  %creates variables able to hold rounded numbers
 
var x, triangletype, y, x2, x3, y2 : int  %creates variables able to hold rounded number
 
var triangle_base, triangle_height, para_base, para_height, hex_base : real  %creates variables able to hold unrounded number
 
var font : int  %creates variables able to hold rounded number
 
font := Font.New ("Palatino:24:bold,italic")  %assigns the variable 'font' a font style to use
 
proc drawhexagon (base, hexagonarea : real)
 
    cls %clear screen
 
    x := round ((maxx div 2) - (base div 2) * 20) %places x coordinate at a point to center the hexagon when drawn
 
    x2 := round (x + base * 20) %when line is drawn the space between x and x2 is the base length
 
    y := round ((maxy div 2) - (base div 2) * 20) %y is set to a coordinate to center the hexagon
 
    drawline (x, y, x2, y, brightred) %draws the bottom line of the hexagon
 
    y2 := round (y + (base * 0.66666) * 20) %sets y2 2/3 times the base above the last y variable, for a 60 degree angle
 
    x3 := round (x - (base div 2) * 20) %x3 is half of the base to the left of the x coordinate
 
    drawline (x, y, x3, y2, brightred) %draws the bottom left line
 
    x := round (x2 + (base div 2) * 20) %sets x to half the base to the right of x2 to achieve a 60 degree angle
 
    drawline (x2, y, x, y2, brightred) %draws bottom right line
 
    y := round (y2 + (base * 0.66666) * 20) %sets the y coordinate 2/3 of the base over the last y corrdinate to achieve a 60 degree angle
 
    x2 := round (x3 + (base div 2) * 20) %x2 is now the same as the x corrdinate was first
 
    drawline (x3, y2, x2, y, brightred) %draws top left line
 
    x3 := round (x - (base div 2) * 20) %x3 i now the same as what x2 started as
 
    drawline (x3, y, x, y2, brightred) %draws top right line
 
    drawline (x2, y, x3, y, brightred) %draws top base line
 
    put "base=", base, "cm    area=", (round (hexagonarea * 100)) / 100, "cm" .. %outputs  base height and area
 
    put chr (170) %squared symbol
 
end drawhexagon
 
procedure draw_box (box_height, box_base, box_col1 : int)
 
    cls %clear screen
 
    drawfillbox (200, 200, box_base, box_height, box_col1) %draws box using user given variables variables
 
end draw_box
 
proc circle (radius : int)
 
    drawfilloval (400, 300, radius * 20, radius * 20, brightred) %draws circle using user given variables
 
end circle
 
proc drawparalellogram (para_base, para_height : real)
 
    cls %clears screen
 
    x := (maxx div 2) - ((para_base * 20) div 2) - 20 %x is put in a spot  so that when drawn, the parolellogram is centered
 
    x2 := round (x + para_base * 20) %x2 and x will be as far away from each other as the base
 
    y := (maxy div 2) - ((para_base * 20) div 2) %y will be in the a spot so that when drawn, the parolellogram will be centered
 
    drawline (x, y, x2, y, brightred) %draws the base line
 
    y2 := round (y + para_height * 20) %y2 will be the height higher than the y coordinate
 
    x3 := x + 40 %x3 will be 40 pixels to the right of x
 
    drawline (x, y, x3, y2, brightred) %draws the left line
 
    x := round (x3 + para_base * 20) %x is recycled to the base length to the right of x3
 
    drawline (x, y2, x2, y, brightred) %draws right line
 
    drawline (x, y2, x3, y2, brightred) %draws top line
 
    locate (30, 30)
 
    put "Base=", para_base, "    height=", para_height, "    area=", para_base * para_height .. %outputs the base height and area
 
    put chr (170) %squared symbol
 
end drawparalellogram
 
proc drawtriangle (triangle_base, triangle_height : real)
 
    cls %clear screen
 
    x := round ((maxx div 2) - ((triangle_base * 20) div 2)) %x is at a point so that when draw, the triangle will be centered
 
    x2 := round (x + triangle_base * 20) %x2 is the distance of the base away from the x
 
    y := round ((maxy div 2) - ((triangle_base * 20) div 2)) %y is at a point so that when drawn, the triangle will be centered
 
    drawline (x, y, x2, y, brightred) %draws bottome line
 
    locate (30, 30)
 
    put "base=", triangle_base, "cm   height=", triangle_height, "cm" %outputs base height and area
 
    y2 := round (y + triangle_height * 20) %y2 is the height away from the y coordinate
 
    if triangletype = 1 then %if isosceles
 
        x3 := maxx div 2 %x3 is centered
 
    elsif triangletype = 2 then %if right angle
 
        x3 := x2 %then x3 is x2
 
    else
 
        x3 := x + 15 %if scalene, then x3 is 15 right of x
 
    end if
 
    drawline (x, y, x3, y2, brightred) %draws left line
 
    drawline (x2, y, x3, y2, brightred) %draws right line
 
end drawtriangle
 
colourback (black) %screen's background will be black
 
cls %clears screen
 
Font.Draw ("Welcome to Daniel's and Martin's program!!", 85, 350, font, brightgreen)
 
Font.Draw ("5", 450, 200, font, brightgreen)
 
delay (1500)
 
cls
 
Font.Draw ("Welcome to Daniel's and Martin's program!!", 85, 350, font, brightgreen)
 
Font.Draw ("4", 450, 200, font, brightgreen)
 
delay (1500)
 
cls
 
Font.Draw ("Welcome to Daniel's and Martin's program!!", 85, 350, font, brightgreen)
 
Font.Draw ("3", 450, 200, font, brightgreen)
 
delay (1500)
 
cls
 
Font.Draw ("Welcome to Daniel's and Martin's program!!", 85, 350, font, brightgreen)
 
Font.Draw ("2", 450, 200, font, brightgreen)
 
delay (1500)
 
cls
 
Font.Draw ("Welcome to Daniel's and Martin's program!!", 85, 350, font, brightgreen)
 
Font.Draw ("1", 450, 200, font, brightgreen)
 
delay (1500)
 
cls
 
Text.Colour (white) %all writing will be white
 
%main program begins here.
 
loop
 
    cls %clears screen
 
    locate (1, 1)
 
    put "type 0 to exit."
 
    locate (5, 5)
 
    put "Please pick one of the following shapes that you would like to see drawn, and explained."
 
    locate (10, 15)
 
    put "1) Triangle"
 
    locate (11, 15)
 
    put "2) Rectangle"
 
    locate (12, 15)
 
    put "3) Circle"
 
    locate (13, 15)
 
    put "4) Paralellogram"
 
    locate (14, 15)
 
    put "5) Hexagon"
 
    locate (15, 15)
 
    put "Which shape would you like to see drawn?  " ..
 
    get shape %prompts user for input on their decision
 
    if shape = "triangle" or shape = "Triangle" then
 
        cls
 
        put "Enter the base for the triangle (1-20).. " ..
 
        get triangle_base %prompts user for base
 
        if triangle_base > 20 then %keeps size reasonable
 
            cls
 
            loop
 
                locate (15, 35)
 
                put triangle_base, " is not valid input."
 
                exit
 
            end loop
 
        end if
 
        put "Enter the height for the triangle (1-20).. " ..
 
        get triangle_height %user inputs height
 
        if triangle_height > 20 then %keeps height reasonable
 
            cls
 
            locate (15, 35)
 
            put triangle_height, " is not valid input."
 
        end if
 
        cls
 
        put "Enter the type of triangle you would like drawn.."
 
        put "(1) isoceles"
 
        put "(2) Right-Angle"
 
        put "(3) Scalene"
 
        put "Triangle type.. " ..
 
        get triangletype %asks user what triangle they want drawn
 
        drawtriangle (triangle_base, triangle_height) %calls triangle procedure
 
    elsif shape = "1" then
 
        cls
 
        loop
 
            locate (1, 1)
 
            put "Enter the base for the triangle (1-20).. " ..
 
            get triangle_base %user enters base
 
            if triangle_base > 20 then %keeps base reasonable
 
                cls
 
                locate (15, 35)
 
                put triangle_base, " is not valid input."
 
                exit
 
            end if
 
            put "Enter the height for the triangle (1-20).. " ..
 
            get triangle_height %user enters height
 
            if triangle_height > 20 then %keeps height reasonable
 
                cls
 
                locate (15, 35)
 
                put triangle_height, " is not valid input."
 
                exit
 
            end if
 
            put "Enter the type of triangle you would like drawn.."
 
            put "(1) isoceles"
 
            put "(2) Right-Angle"
 
            put "(3) Scalene"
 
            put "Triangle type.. " ..
 
            get triangletype %asks user what kind of triangle they want drawn
 
            drawtriangle (triangle_base, triangle_height) %calls triangle procedure
 
            exit
 
        end loop
 
    elsif shape = "2" then
 
        cls
 
        locate (12, 25)
 
        put "This is what a rectangle looks like..."
 
        drawfillbox (200, 200, 450, 300, brightred) %gives example of rectangle
 
        locate (25, 25)
 
        put "Are you ready to see more!!  " ..
 
        get nothing
 
        cls
 
        drawfillbox (200, 200, 450, 300, brightred) %redraws example box
 
        locate (2, 2)
 
        put "Would You like to try?  " ..
 
        locate (30, 25)
 
        put "Height of 5"
 
        locate (30, 40)
 
        put "Base of 8"
 
        locate (2, 25)
 
        get nothing
 
        put "OK, please give me the Base!! (1-30)  " ..
 
        get box_base %user enters base
 
        put "Ok, know give me the Height!! (1-20)  " ..
 
        get box_height %user enters height
 
        box_col := "red" %sets colour to red
 
        if box_col = "blue" then
 
            box_col1 := 1
 
        elsif box_col = "green" then
 
            box_col1 := 2
 
        elsif box_col = "red" then
 
            box_col1 := 4
 
        elsif box_col = "yellow" then
 
            box_col1 := 14
 
        elsif box_col = "white" then
 
            box_col1 := 31
 
        else
 
        end if
 
        put "invalid input"
 
        %this part multiplys all lengths by 20 for scale ratio
 
        box_height := box_height * 20
 
        box_base := box_base * 20
 
        box_base := box_base + 200
 
        box_height := box_height + 200
 
        draw_box (box_height, box_base, box_col1) %calls the draw box procedure
 
    elsif shape = "rectangle" or shape = "Rectangle" then
 
        cls        %clears screen
 
        locate (12, 25)
 
        put "This is what a rectangle looks like..."
 
        drawfillbox (200, 200, 450, 300, brightred) %draws example box
 
        locate (25, 25)
 
        put "Are you ready to see more!!  " ..
 
        get nothing
 
        cls %clears screeen
 
        drawfillbox (200, 200, 450, 300, brightred) %redraws example box
 
        locate (2, 2)
 
        put "Would You like to try?  " ..
 
        locate (30, 25)
 
        put "Height of 5"
 
        locate (30, 40)
 
        put "Base of 8"
 
        locate (2, 25)
 
        get nothing
 
        put "OK, please give me the Base!! (1-30)  " ..
 
        get box_base %user enters base
 
        put "Ok, know give me the Height!! (1-20)  " ..
 
        get box_height %user enters height
 
        box_col := "red" %sets colout to red
 
        if box_col = "blue" then
 
            box_col1 := 1
 
        elsif box_col = "green" then
 
            box_col1 := 2
 
        elsif box_col = "red" then
 
            box_col1 := 4
 
        elsif box_col = "yellow" then
 
            box_col1 := 14
 
        elsif box_col = "white" then
 
            box_col1 := 31
 
        else
 
        end if
 
        put "invalid input"
 
        %this code multiplys lengths by 20 to make a scale
 
        box_height := box_height * 20
 
        box_base := box_base * 20
 
        box_base := box_base + 200
 
        box_height := box_height + 200
 
        draw_box (box_height, box_base, box_col1) %calls box procedure
 
    elsif shape = "3" then
 
        cls
 
        put "This is what a circle looks like."
 
        drawfilloval (400, 300, 70, 70, brightred) %draw example circle
 
        locate (30, 2)
 
        put "Would you like to see more?  " ..
 
        get nothing
 
        cls %clears screen
 
        drawoval (400, 300, 70, 70, brightred) %redraws example circle
 
        drawline (400, 300, 470, 300, brightred)
 
        locate (17, 50)
 
        put "Radius of 4"
 
        locate (2, 2)
 
        put "Would you like to try?  " ..
 
        get nothing
 
        cls %clears screen
 
        locate (2, 2)
 
        put "Please give me the radius! (1-15) " ..
 
        get radius %user enters radius
 
        cls
 
        circle (radius) %calls circle procedure
 
        put "Area=", round ((3.14 * radius ** 2) * 100) / 100 %outputs area
 
    elsif shape = "circle" or shape = "Circle" then
 
        cls
 
        put "This is what a circle looks like."
 
        drawfilloval (400, 300, 70, 70, brightred) %draws example circle
 
        locate (30, 2)
 
        put "Would you like to see more?  " ..
 
        get nothing
 
        cls
 
        drawoval (400, 300, 70, 70, brightred) %redraws example circle
 
        drawline (400, 300, 470, 300, brightred)
 
        locate (17, 50)
 
        put "Radius of 4"
 
        locate (2, 2)
 
        put "Would you like to try?  " ..
 
        get nothing
 
        cls %clears screen
 
        locate (2, 2)
 
        put "Please give me the radius! (1-15)  " ..
 
        get radius %user enters radius
 
        cls %clears screen
 
        circle (radius) %calls circle procedure
 
    elsif shape = "paralellogram" or shape = "Paralellogram" or shape = "4" then
 
        cls %clears screen
 
        put "Enter the base of the shape (1-20).. " ..
 
        get para_base %user enters base
 
        put "Enter the height of the shape (1-20).. " ..
 
        get para_height %user enters height
 
        drawparalellogram (para_base, para_height) %calls procedure for paralellogram
 
    elsif shape = "Hexagon" or shape = "hexagon" or shape = "5" then
 
        cls %clears screen
 
        put "Enter the desired base (1-15).. " ..
 
        get hex_base %user enters base
 
        if hex_base > 15 or hex_base < 1 then %keeps the size reasonable
 
            hex_base := 15
 
        end if
 
        drawhexagon (hex_base, hex_base * (hex_base * 0.66) / 2 * 6) %calls haxagon procedure
 
    elsif shape = "0" then
 
        exit
 
    else %if choice is invalid
 
        cls
 
        locate (12, 20)
 
        put shape, " is an invalid input, please try again." %tells user its invalid
 
    end if
 
    delay (3000) %delays 3 seconds
 
end loop %goes back to the top of the menu part
 
cls
 
put "Thank you."
 
  |