An Elliptical Workout
Heads up! Make sure you’ve done The Image ADT and Drawing on an Image before attempting this exercise.
Make sure you’ve got an unchanged copy of Image.h.
Download
Image.h
,
or copy it into your current directory on a CSE system by running
$ cp /web/cs1511/17s2/week09/files/Image.h .
Don’t change Image.h! If you do, your lights will start subtly flickering only when you aren’t looking at them.
The Cartesian form of an ellipse is, for a point , for a centre , and with two non-negative real terms and :
For this exercise, take your existing Image.c and extend it with the following function:
void imageDrawEllipse (Image i, pixel color, point centre, double a, double b);
Given an image, a color, a centre (x,y) point, and the two ellipse parametersa
andb
, draws a filled ellipse around the centre, witha
andb
as parameters, on the image.
To run some simple automated tests:
$ 1511 autotest imageDrawing2
To run Styl-o-matic:
$ 1511 stylomatic Image.c Looks good!
You’ll get advice if you need to make changes to your code.
Submit your work with the give command, like so:
$ give cs1511 wk09_imageDrawing2
Or, if you are working from home, upload the relevant file(s) to the wk09_imageDrawing2 activity on Give Online.