Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part III combines and integrates Parts I and II of Assignment 5 to generate random CSC 111 Circle Art as depicted in Figure 5 in

Part III combines and integrates Parts I and II of Assignment 5 to generate random CSC 111 Circle Art as depicted in Figure 5 in an HTML5/SVG file called A5P3.html. Integrating two separate programs into one is a common task in software development (e.g., combing two APIs) to provide the functionality of both APIs.

For iLeap you are to submit genRandomArtNumSet, genRandomArt and createFile. void genRandomArtNumSet(int *x, int *y, int *rad, int *r, int *g, int *b, float *op); void genRandomArt(FILE *ofp, char *id, int nShapes); FILE* createFile(char* fnam); The console output for Part III of Assignment 5 is the generated calls to the API function fillCircleSVG (i.e., 1000 lines of fillCircleSVG calls). fillCircleSVG(41, 170, 30, 236, 237, 69, 0.99) fillCircleSVG(522, 319, 38, 189, 165, 51, 0.77) fillCircleSVG(349, 170, 12, 186, 247, 83, 0.61) fillCircleSVG(186, 50, 40, 236, 158, 49, 0.80) fillCircleSVG(494, 314, 45, 142, 207, 24, 0.84) fillCircleSVG(688, 308, 28, 131, 166, 19, 0.91) fillCircleSVG(83, 159, 12, 240, 109, 35, 0.64)

CODE:

#include  #include  #include  // helper to convert a value into a string #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) #define ID0 ("") #define ID1 (" ") #define ID2 (" ") #define FILENAME ("A5P4.html") #define FOPENERR ("fopen error %s") #define TABTITLE ("My CSC 111 Art") #define WELCOME ("Welcome to my CSC 111 Webpage") #define RESUME ("SVG is a great skill for my co-op job resume") #define ANIMATIONTEXT ("My CSC 111 Art ...") #define WINWIDTH (800) #define WINHEIGHT (320) #define MAXNUMSHAPES 1000 #define STRSH (STR(MAXNUMSHAPES) " shapes generated") #define SHAPEMIN (0) #define SHAPEMAX (2) #define XMIN (0) #define XMAX (WINWIDTH) #define YMIN 0 #define YMAX (WINHEIGHT) #define RADMIN (10) #define RADMAX (50) #define FALLSHADE (1) #define REDSHADE (2) #define GREENSHADE (3) #define BLUESHADE (4) #define PURPLESHADE (5) #define FAVORITESHADE (6) #define SHADE (FALLSHADE) #if SHADE == FALLSHADE #define REDMIN (100) #define REDMAX (255) #define GREENMIN (100) #define GREENMAX (255) #define BLUEMIN (0) #define BLUEMAX (100) #elif SHADE == REDSHADE #define REDMIN (200) #define REDMAX (255) #define GREENMIN (50) #define GREENMAX (120) #define BLUEMIN (0) #define BLUEMAX (50) #elif SHADE == GREENSHADE #define REDMIN (0) #define REDMAX (50) #define GREENMIN (150) #define GREENMAX (255) #define BLUEMIN (50) #define BLUEMAX (150) #elif SHADE == BLUESHADE #define REDMIN (0) #define REDMAX (50) #define GREENMIN (50) #define GREENMAX (150) #define BLUEMIN (150) #define BLUEMAX (250) #elif SHADE == PURPLESHADE #define REDMIN (75) #define REDMAX (150) #define GREENMIN (50) #define GREENMAX (130) #define BLUEMIN (170) #define BLUEMAX (255) #elif SHADE == FAVORITESHADE #define REDMIN (163) #define REDMAX (255) #define GREENMIN (68) #define GREENMAX (178) #define BLUEMIN (4) #define BLUEMAX (42) #endif //SHADE #define OPMIN (0.6) #define OPMAX (1.0) #define PRECISION (100.0) //prototypes int main(void); int prng(int iLow, int iHigh); float prngFloat(float fLow, float fHigh, float precision); FILE* createFile(char* fnam); void prologue(FILE* ofp, char* winTabTitle, char* opening, char* col); void epilogue(FILE* ofp, char* closing, char* col); void drawHeader1HTML5(FILE* ofp, char* id, char* text, char* col); void drawParaHTML5(FILE* ofp, char* id, char* text, char* col); void openSVG(FILE* ofp, char* id, int w, int h); void closeSVG(FILE* ofp, char* id); void commentSVG(FILE* ofp, char* id, char* cmt); void fillRectSVG(FILE* ofp, char* id, int x, int y, int w, int h, int r, int g, int b, float op); void fillCircleSVG(FILE* ofp, char* id, int cx, int cy, int rad, int r, int g, int b, float op); void textSwipeAnimateSVG(FILE* ofp, char* id, char* txt, int fsz, int x, int y, int r, int g, int b, float op); void textSwipeAnimateSVG(FILE* ofp, char* id, char* txt, int fsz, int x, int y, int r, int g, int b, float op); void genRandomArtNumSet(int *x, int *y, int *rad, int *r, int *g, int *b, float *op); void genRandomArt(FILE *ofp, char *id, int nShapes); int main(void){ FILE *ofp = createFile(FILENAME); prologue(ofp, TABTITLE, WELCOME, "red"); genRandomArt(ofp, ID2, MAXNUMSHAPES); epilogue(ofp, RESUME, "blue"); return EXIT_SUCCESS; }//main int prngInt(int iLow, int iHigh) { //replace with the prngInt function you wrote for Part II return 0; }//prngInt float prngFloat(float fLow, float fHigh, float precision) { //replace with the prngFloat function you wrote for Part II return 0.0; }//prngFloat void genRandomArtNumSet(int *x, int *y, int *rad, int *r, int *g, int *b, float *op){ *x = *y = *rad = *r = *g = *b = 0; *op = 1.0; //replace with the genRandomArtNumSet function you wrote for Part II }//genRandomArtNumbers void genRandomArt(FILE *ofp, char *id, int nShapes){ int x, y, rad, rx, ry, w, h, r, g, b; float op; commentSVG(ofp, ID1, "Outline SVG viewbox"); openSVG(ofp, ID1, WINWIDTH, WINHEIGHT); commentSVG(ofp, ID2, "Define and paint SVG view box"); fillRectSVG(ofp, ID2, 0, 0, WINWIDTH, WINHEIGHT, 245, 245, 220, 1.0); commentSVG(ofp, ID2, "Draw SVG shapes"); for (int k=1; k<=nShapes; k++) { // Use the function genRandomArtNumSet to generate the random numbers // Use the function fillCircleSVG to create the SVG shapes // Replace with your code here }//for commentSVG(ofp, ID2, "SVG animation"); // Use the function textSwipeAnimateSVG to create the animated text // Replace with your code here closeSVG(ofp, ID1); }// genRandomArt FILE* createFile(char* fnam) { // Create a new file. // The name of the file is given in the parameter fnam // Replace with your code here return NULL; }//createFile void prologue(FILE* ofp, char* winTabTitle, char* opening, char* col) { fprintf(ofp, "%s%s ", ID0, ""); fprintf(ofp, "%s%s ", ID0, ""); fprintf(ofp, "%s%s ", ID0, ""); fprintf(ofp, "%s%s ", ID1, ""); fprintf(ofp, "%s%s ", ID2, winTabTitle); fprintf(ofp, "%s%s ", ID1, ""); fprintf(ofp, "%s%s ", ID0, ""); fprintf(ofp, "%s%s ", ID0, ""); drawHeader1HTML5(ofp, ID1, opening, col); }//prologue void epilogue(FILE* ofp, char* closing, char* col) { drawParaHTML5(ofp, ID1, STRSH, col); drawParaHTML5(ofp, ID1, closing, col); fprintf(ofp, "%s%s ", ID0, ""); fprintf(ofp, "%s%s ", ID0, ""); }//epilogue void openSVG(FILE* ofp, char* id, int w, int h) { fprintf(ofp, "%s ", id, w, h); }//openSVG void closeSVG(FILE* ofp, char* id) { fprintf(ofp, "%s ", id); }//closeSVG void fillRectSVG(FILE* ofp, char* id, int x, int y, int w, int h, int r, int g, int b, float op) { fprintf(ofp, "%s ", id, x, y, w, h,r, g, b, op); }//fillRectSVG void fillCircleSVG(FILE* ofp, char* id, int cx, int cy, int rad, int r, int g, int b, float op) { fprintf(ofp, "%s ", id, cx, cy, rad, r, g, b, op); }//fillCircleSVG void defAnimateSwipeSVG(FILE* ofp, char* id, char* link, int f, int t, int b, int d) { fprintf(ofp, "%s ", id); fprintf(ofp, "%s ", id, link, f, t, b, d); fprintf(ofp, "%s ", id); }//defAnimateSwipeSVG void textSwipeAnimateSVG(FILE* ofp, char* id, char* txt, int fsz, int x, int y, int r, int g, int b, float op){ defAnimateSwipeSVG(ofp, ID2, "defAnimateSwipeSVG", 500, 50, 0, 5); fprintf(ofp, "%s%s ", id, "defAnimateSwipeSVG", x, y, fsz, r, g, b, op, txt); }//textSwipeAnimateSVG void commentSVG(FILE* ofp, char* id, char* cmt) { fprintf(ofp, "%s ", id, cmt); }//commentSVG void drawHeader1HTML5(FILE* ofp, char* id, char* text, char* col) { fprintf(ofp, "%s

%s

", id, col, text); }//drawHeader1HTML5 void drawParaHTML5(FILE* ofp, char* id, char* text, char* col) { fprintf(ofp, "%s

%s

", id, col, text); }//drawParaHTML5

only compete genRandomArtNumSet, genRandomArt and createFile function

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

=+j What rules will apply to the process of negotiations?

Answered: 1 week ago