Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a function in mips draw _ spiral ( int x , int y , int size, int colour ) that draws a spiral starting

write a function in mips draw_spiral(int x, int y, int size, int colour) that draws a spiral starting at (x, y) where the first branch of the spiral has length size. Use functions draw_horizontal_line and draw_vertical_line to draw the spiral. Modify your main program to call draw_spiral.
Note: Feel free to come up with your own implementation of drawing a spiral. But here is a possible implementation for reference:
draw_spiral(int x, int y, int size, int color){
while(size>1){
draw_horizontal_line(x, y, size, color);
x = x + size -1;
size--;
draw_vertical_line(x, y, size, color);
y = y + size -1;
size--;
x = x - size +1;
draw_horizontal_line(x, y, size, color);
size--;
y = y - size +1;
draw_vertical_line(x, y, size, color);
size--;
}
}
Hint: Print different colours for vertical and horizontal lines while debugging.
Example: For the user input:
Please enter the x coordinate of the position:
1--- this is the input
Please enter the y coordinate of the position:
1--- this is the input
Please enter the size:
29--- this is the input
Please enter the colour (w-white, g-green, y-yellow and r-red):
w --- this is the input
The result of draw_spiral(1,1,29,w) should be:
Example of spiral
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions