makefile # CS 202 # Make file for spirograph program CC= g++ -Wall -pedantic -Wextra -std=c++11 -g OBJS= spiro.o spiroType.o DEPS1= spiroType.h DEPS2= bitmapImage.h all: spiro spiro: $(OBJS) $(CC)...

As stated to support. This is a C++ assignment, STL library is not allowed, "Using namespace std;" instead of adding "std::" is required. Most of the files are given and its just implementation.


makefile # CS 202 # Make file for spirograph program CC= g++ -Wall -pedantic -Wextra -std=c++11 -g OBJS= spiro.o spiroType.o DEPS1= spiroType.h DEPS2= bitmapImage.h all: spiro spiro: $(OBJS) $(CC) -o spiro $(OBJS) bitmapImage.o spiro.o:spiro.cpp $(DEPS1) $(CC) -c spiro.cpp spiroType.o:spiroType.cpp $(DEPS1) $(DEPS2) $(CC) -c spiroType.cpp # ----- # clean by removing object files. clean: rm$(OBJS) spiro.cpp spiro.cpp // CS202 - Provided Main. //  This simple main creates some spiograph image files. //  Test various aspects of the sprioType class. #include  #include  #include  #include "spiroType.h" using namespace std; void displayImageData(spiroType); // ============================================================================= int main() {     cout <><>< endl;><><>< endl;  ----------------------------------------------=""   some initial error testing.=""><>< endl;     spirotype   image0(10,10,"none.bmp");       // bad constructor=""><>< endl;  ----------------------------------------------=""   create spirograph image #1.=""   get file name and image size information from user.=""     spirotype   image1;=""     image1.readfilename();=""     image1.readimagesize();=""     image1.readparameters();=""     image1.initimage(0);=""     image1.createspiroimage();=""     image1.createimagefile();=""  ----------------------------------------------=""   create spirograph image #2.=""     int img2width =" 1280;"     int img2height =" 800;"     spirotype   image2(img2width,img2height,"spiro2.bmp");=""     image2.initimage(0);=""     image2.setparameters(57, 108, 43, "red");=""     image2.createspiroimage();=""     image2.createimagefile();=""  ----------------------------------------------=""   create spirograph image #3.=""     spirotype   image3;=""     image3.setimagesize(640,480);=""     image3.setfilename("spiro3.bmp");=""     image3.setimagesize(img2width, img2height);=""     image3.setparameters(106, 8, 58, "green");=""     image3.initimage(0);=""     image3.createspiroimage();=""     image3.createimagefile();=""  ----------------------------------------------=""   create spirograph image #4 based on image #2.=""     spirotype image4(image2);=""     image4.setfilename("spiro4.bmp");=""     image4.createspiroimage();=""     image4.createimagefile();=""  ----------------------------------------------=""   create spirograph image #5 based on image #2.=""   image 5 should include image 2 (in red) and the=""   new image (in green).=""     spirotype image5(image2);=""     image5.setfilename("spiro5.bmp");=""     image5.setparameters(200, 8, 17, "green");=""     image5.createspiroimage();=""     image5.createimagefile();=""  ----------------------------------------------=""   create spirograph image #6 (small).=""     spirotype image6;=""     image6.setfilename("spiro6.bmp");=""     image6.setimagesize(200,200);=""     image6.setparameters(51, 13, 15, "blue");=""     image6.initimage(0);=""     image6.createspiroimage();=""     image6.createimagefile();=""  ----------------------------------------------=""   display summary for files created...=""><><><>< endl;><><>< endl;     displayimagedata(image1);=""     displayimagedata(image2);=""     displayimagedata(image3);=""     displayimagedata(image4);=""     displayimagedata(image5);=""     displayimagedata(image6);="">< endl;  ----------------------------------------------=""   all done, end program.=""     return 0;="" }=""  ="============================================================================"   simple support function=""   display the image information for reference.="" void displayimagedata(spirotype image)="" {=""     double  rf, rm, oa;=""     string  dc, fname;=""     fname =" image.getFileName();"     rf =" image.getRadiusFixed();"     rm =" image.getRadiusMoving();"     oa =" image.getOffsetAmount();"     dc =" image.getDrawColor();"><>< endl;><><>< endl;><><><><>< endl;><><><><>< endl; }=""  ="============================================================================" test/outmstr.txt="" cs="" 202="" -="" assignment="" #8.="" spirograph="" program.="" bad="" constructor="" (should="" be="" error)="" error,="" width="" must="" be="" between="" 100="" and="" 10000.="" error,="" height="" must="" be="" between="" 100="" and="" 10000.="" enter="" output="" file="" name:="" error,="" invalid="" file="" name.="" please="" re-enter.="" enter="" output="" file="" name:="" error,="" file="" name="" must="" be="" '.bmp'="" extension.="" please="" re-enter.="" enter="" output="" file="" name:="" enter="" image="" size="" (width,="" height):="" error,="" width="" must="" be="" between="" 100="" and="" 10000.="" please="" re-enter.="" error,="" invalid="" aspect="" ratio.="" must="" be="" between="" 1.0="" and="" 2.0.="" please="" re-enter.="" enter="" image="" size="" (width,="" height):="" error,="" height="" must="" be="" between="" 100="" and="" 10000.="" please="" re-enter.="" error,="" invalid="" aspect="" ratio.="" must="" be="" between="" 1.0="" and="" 2.0.="" please="" re-enter.="" enter="" image="" size="" (width,="" height):="" error,="" invalid="" aspect="" ratio.="" must="" be="" between="" 1.0="" and="" 2.0.="" please="" re-enter.="" enter="" image="" size="" (width,="" height):="" error,="" invalid="" aspect="" ratio.="" must="" be="" between="" 1.0="" and="" 2.0.="" please="" re-enter.="" enter="" image="" size="" (width,="" height):="" enter="" radius="" of="" fixed="" circle:="" invalid="" radius,="" please="" re-enter="" enter="" radius="" of="" fixed="" circle:="" invalid="" radius,="" please="" re-enter="" enter="" radius="" of="" fixed="" circle:="" enter="" radius="" of="" moving="" circle:="" invalid="" radius,="" please="" re-enter="" enter="" radius="" of="" moving="" circle:="" invalid="" radius,="" please="" re-enter="" enter="" radius="" of="" moving="" circle:="" enter="" offset="" amount:="" invalid="" offset="" amount,="" please="" re-enter="" enter="" offset="" amount:="" invalid="" offset="" amount,="" please="" re-enter="" enter="" offset="" amount:="" enter="" draw="" color="" (red,="" green,="" blue):="" invalid="" color,="" please="" re-enter="" enter="" draw="" color="" (red,="" green,="" blue):="" ************************************************="" image="" summary="" information:="" ---------------------------------------------------------------="" image:spiro1.bmp="" radius="" fixed="106" radius="" moving="8" offset="" amount="58" draw="" color="green" ---------------------------------------------------------------="" image:spiro2.bmp="" radius="" fixed="57" radius="" moving="108" offset="" amount="43" draw="" color="red" ---------------------------------------------------------------="" image:spiro3.bmp="" radius="" fixed="106" radius="" moving="8" offset="" amount="58" draw="" color="green" ---------------------------------------------------------------="" image:spiro4.bmp="" radius="" fixed="57" radius="" moving="108" offset="" amount="43" draw="" color="red" ---------------------------------------------------------------="" image:spiro5.bmp="" radius="" fixed="200" radius="" moving="8" offset="" amount="17" draw="" color="green" ---------------------------------------------------------------="" image:spiro6.bmp="" radius="" fixed="51" radius="" moving="13" offset="" amount="15" draw="" color="blue" test/spiro6mstr.bmp="" test/spiro4mstr.bmp="" test/spiro5mstr.bmp="" test/a5tst="" #!/bin/bash="" #="" cs="" 202,="" assignment="" #5="" test="" script.="" #="" ---------------------------------------------------------="" #="" initial="" checks.="" #="" ensure="" executable="" file="" exists.="" if="" [="" !="" -e="" "$1"="" ]="" ||="" [="" !="" -x="" "$1"="" ];="" then="" echo="" "error,="" unable="" to="" find="" bmain="" executable="" file."="" exit="" fi="" #="" -----="" #="" check="" for="" valgrind="" if="" hash="" valgrind="" 2="">/dev/null; then echo else echo echo "Error, Valgrind not installed." echo echo "To install, type:" echo " sudo apt update" echo " sudo apt upgrade" echo " sudo apt install valgrind" echo exit fi # --------------------------------------------------------- # Define script variables bolded=`tput bold` normal=`tput sgr0` red=`tput setaf 1` green=`tput setaf 2` white=`tput setaf 7` pause() { if [ "$1" = "skip" ]; then echo else echo echo -n "Press return to continue" read clear fi } # --------------------------------------------------------- # Test specified executable clear echo echo "CS 202 - Assignment #5 Test Script." echo echo echo echo echo echo "Should report:" echo " \"All heap blocks were freed -- no leaks are possible\" " echo "and" echo " \"ERROR SUMMARY: 0 errors from 0 contexts\" " echo echo echo pause # --------------------- # spiro class testing valgrind ./$1 > out.txt < eof="" no="" sp.txt="" spiro1.bmp="" 10="" 200="" 200="" 10="" 100="" 8000="" 8000="" 100="" 800="" 600="" 900="" -1="" 106="" -1="" 900="" 8="" 900="" -2="" 58="" magenta="" green="" eof="" echo="" echo="" if="" `diff="" -b="" out.txt="" outmstr.txt="">/dev/null` ; then echo "${bolded}Test #1 $1 Program Output ${green}Successful${normal}" else echo "${bolded}Test #1 $1 Program Output ${red}Fail${normal}" diff -b out.txt outMstr.txt fi echo i=1 for file in spiro*Mstr.bmp; do echo "-------------------------------" echo "${bolded}Test $file${normal}" if `diff -b spiro${i}.bmp $file >/dev/null`; then echo "${bolded}Test spiro${i} ${green}Successful${white} - (spiro${i}.bmp) ${normal}" else echo "${bolded}Test spiro${i} ${red}Fail${white} - (spiro${i}.bmp) ${normal}" diff -b spiro${i}.bmp $file fi i=$((i+1)) done echo test/spiro1Mstr.bmp test/spiro3Mstr.bmp test/spiro2Mstr.bmp bitmapImage.h #ifndef H_BITMAP_IMAGE_HEADER #define H_BITMAP_IMAGE_HEADER class bitmapImage; /* A class for working with the Windows Bitmap File Format. Supports bit depths of 16, 24, and 32 with uncompressed pixel data. This does not support compressed bitmaps or bit depths of 1,4, or 8. Compression is rarely used with this file format, though. Colors can be specified in RGB format (red, green, and blue intensity values) Red, Green, Blue colors range from 0-255 (0 -> off to 255 -> full intensity) For red, it would be (255, 0, 0) and in hex, (0xff0000). As a single value, 0xff0000 is 16,711,680 For green, it would be (0, 255, 0) and in hex, (0x00ff00). As a single value, 0x00ff00 is 65,280 */ class bitmapImage { private: intwidth, height; int**pixelData; voidfreePixelData(); public: // create empty bitmap object bitmapImage(); // create bitmap object from file 'filename'. bitmapImage(const char* filename); // create empty bitmap object of size width by height bitmapImage(int w, int h); // destructor virtual ~bitmapImage(); // set (for empty object) bitmap size void setSize(int width, int height); // loads uncompressed bitmaps with color depths of // 16,24, and 32 returns 0, if successfully loaded. int loadFromBitmapFile(const char*filename); // saves bitmaps using 24 bit color depth (typical default) void saveToBitmapFile(const char* filename) const; // saves using the specified depth of 16, 24, or 32 void saveToBitmapFile(const char* filename, int bitDepth) const; // get bitmap object height int getHeight() const; // get bitmap object width int getWidth() const; // get 'red' part of color value int getRed(int color) const; // get 'green' part of color value int getGreen(int color) const; // get 'blue' part of color value int getBlue(int color) const; // convert red, green, and blue values to single color value int getColorForRGB(int red, int green, int blue) const; // get contents of (x,y) in image map int getPixel(int x, int y) const; // set contents of (x,y) in image map with specified color void setPixel(int x, int y,int color); // set contents of entire image map with specified color void fillWith(int color); // set contents of rectangle within image map with specified color void fillRect(int left, int top, int width, int height, int color); // set contents of (x,y) in image map with specified color in RGB format void setPixelRGB(int x, int y, int red, int green, int blue); }; #endif bitmapImage.o CS 202 – Assignment #5 Purpose: Learn class inheritance, pointers, dynamic memory allocation, class implementation, virtual functions, and make utility. Points: 100 Assignment: Design and implement a C++ class to plot a spirograph1 drawing. Imagine the movement of a small circle that rolls on the outside of a rigid circle. Imagine that the small circle has an arm, rigidly attached, with a plotting pen fixed at some point. That is a epicycloid, commonly called spirographs. ● Spiro Class The spiro class will implement a spirograph class to provide basic Spirograph drawing functions. The spiroType class should inherit the bitmap image functions from the bitmapImage class (which includes creation of the formatted BMP image files). SpiroType : private bitmapImage -radiusFixed: double -radiusMoving: double -offsetAmount: double -drawColor: string -fileName: string +W_MIN, W_MAX, H_MIN, H_MAX: const int +spiroType() +spiroType(int, int, string) +spiroType(const spiroType&) +createSpiroImage(): void +readImageSize(): void +readFileName(): void +setFileName(string): void +setImageSize(int, int): void +initImage(int): void +createImageFile(): void +setParameters(double, double, double, string): void +readParameters(): void +getRadiusFixed() const: double +getRadiusMoving() const: double 1 For more information, refer to: http://en.wikipedia.org/wiki/Spirograph rF rM oA +getOffsetAmount() const: double +getDrawColor() const: string +getHeight() const: int +getWidth() const: int +getFileName() const: string +getPixel(int, int) const: int You may add additional private functions as needed. You are not allowed to add any additional class variables. Function Descriptions • The default constructor (no parameters) should call the base class and set the file name to a null string. The non-default constructor should accept the width, height, and file name string (in that order) and call the base class constructor. The copy constructor should create a new object from the passed object (i.e., deep copy). • The readFileName() function should read a file name from input, and ensure that it has a '.bmp' extension. Re-prompt if there is an error. The setFileName(string) function sets the file name class variable. • The readImageSize() function should read the width and height from input and ◦ ensure width is between W_MIN (100) and W_MAX (10000) ◦ ensure height is between H_MIN (100) and H_MAX (10000) ◦ ensure the aspect ratio (width/height) is between 1.0 and 2.0 and set the base class width and height variables accordingly. The setImageSize(int,int) function set the base class width and height variables (in that order) accordingly. The function should read both values and re-prompt as needed. • The initImage(int) function should fill the entire image with the provided color (by using the appropriate base class functions). • The setParameters(double,double,double,string) function sets the class variables for radiusFixed, radiusMoving, offsetAmount, and drawColor (in that order). • The readParameters() should read from the user, set the class variables for radiusFixed,
Mar 03, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here