Fill in fractal.cpp! Using the background documentation below, fill in fractal.c
ID: 3685036 • Letter: F
Question
Fill in fractal.cpp!
Using the background documentation below, fill in fractal.cpp so it creates fractal images!
This is an open-ended problem. You may create as many (or as few) functions as you wish to get the program written. I have added 3 functions, but you don’t have to. Break the problem down logically into manageable parts. My solution has 20 additional lines, so if you find yourself writing 50+ lines of code, rethink your approach. Use the complex class to its fullest advantage.
The background documentation above is for a newton fractal using z3-1. You may use any other formula to create a fractal, especially any of the others listed on the wikipedia page. I’ve had great success just changing constants and making up additional functions. You may implement ANY function you like, so far it is doing the newton’s iteration.
We will have a student gallery and voting on the best-looking fractal images! Usernames will not be associated with any image. 5 points extra credit on this assignment will go to the the top 10 voted-on images. Gallery details TBA. We will be running your fractal.cpp program with a custom filename and image size to generate the image for the gallery.
Verify everything is working by doing make followed by ./fractal a fractal.png file is created. If ./fractal bob.png 1280 1024 is run, a bob.png image file should be created with size 1280x1024.
// Convenience function to set the red, green, and blue channels
// at a given pixel location in the image.
void setRGB(int x, int y, unsigned char red, unsigned char green, unsigned char blue, cil::CImg<unsigned char>& image){
*(image.data(x,y,0,0)) = red;
*(image.data(x,y,0,1)) = green;
*(image.data(x,y,0,2)) = blue;
}
// Fill me in!
int main(int argc, char* argv[]){
// Fill me in!
return 0;
}
Explanation / Answer
#include<graphics.h>
#include<stdio.h>
int main(void) {
int gdriver = DETECT, gmode;
int source[10]={1,2,3,4,5,6,7,8,9,10};
int dest[10]={0,6,26,60,124,210,342,504,720,990};
int y1[10], y2[10];
initgraph(&gdriver, &gmode, "c:\tc\bgi");
for(int i=0;i<10;i++)
{
line(source[i], y1[i], dest[i], y2[i]);
}
setcolor(RED);
//choose points to fill color
closegraph();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.