Computers and Technology
Computers and Technology, 04.02.2021 07:50, keem3247

Write a program that draws a stoplight. You should have a gray rectangle, and then three circles in the rectangle. The circles should be red, then yellow, then green. The rectangle should be centered on the screen. The yellow light should be centered on the screen, and the red and green light should be offset by BUFFER amount. BUFFER amount represents the distance from the center of one circle to the center of another circle.

Implement the function draw_circle that draws a single circle. Use it to draw the red, yellow, and green lights. Since all of the lights are the same size and aligned vertically, the function only needs to take the y position and color as arguments.

Note: Be sure to include comments for all functions that you use or create.

THIS IS WHAT I HAVE and I have error codes: any help??

# This program should draw a stop light

LIGHT_RADIUS = 25
STOPLIGHT_WIDTH = 100
STOPLIGHT_HEIGHT = 250
BUFFER = 75

# Implement a function that draws a single circle
# with radius LIGHT_RADIUS.
# The circle should be in the center of the screen horizontally.
# Use the parameters for the y position and color
def draw_circle(y_pos, color):
circ = Circle(LIGHT_RADIUS)
circ. set_postition(get_width()/2, y-pos)
circ. set_color(color)
add(circ)
draw_circle(get_height()/2 - BUFFER, Color. red)
draw_circle(get_height()/2, Color. yellow)
draw_circle(get_height()/2 + BUFFER, Color. green)

def draw_rectangle():
rect= Rectangle(STOPLIGHT_WIDTH, STOPLIGHT_HEIGHT)
rect. set_postion(get_width()/2 - STOPLIGHT_WIDTH/2, get_height()/2 - STOPLIGHT_HEIGHT/2)
rect. set_color(Color. grey)
add(rect)
draw_rectangle()

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 13:30, powellmj9216
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
image
Computers and Technology, 23.06.2019 14:30, HarryPotter10
Open this link after reading about ana's situation. complete each sentence using the drop-downs. ana would need a minimum of ato work as a translator. according to job outlook information, the number of jobs for translators willin the future.
Answers: 3
image
Computers and Technology, 23.06.2019 18:30, bsept1018
Report all segments of identity by descent longer than 20 polymorphisms between pairs of individuals in the following cohort of 15 individuals across 49 polymorphisms: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 numeric input 2 points possible (graded) you have 2 attempts to complete the assignment below. for example if the sequence is "bcd", which occurs in "abcdef" , the starting point would be 2 (b), and the finishing point would be 4(d). individuals 7,10 between positions
Answers: 1
image
Computers and Technology, 23.06.2019 19:00, brittneyrenae7338
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words. size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words. size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
Do you know the correct answer?
Write a program that draws a stoplight. You should have a gray rectangle, and then three circles in...

Questions in other subjects:

Konu
Mathematics, 21.10.2020 19:01