This repository has been archived by the owner on Aug 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
MandelMovie.c
90 lines (64 loc) · 3.04 KB
/
MandelMovie.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*********************
** Mandelbrot fractal movie generator
** clang -Xpreprocessor -fopenmp -lomp -o Mandelbrot Mandelbrot.c
** by Dan Garcia <ddgarcia@cs.berkeley.edu>
** Modified for this class by Justin Yokota and Chenyu Shi
**********************/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include "ComplexNumber.h"
#include "Mandelbrot.h"
#include "ColorMapInput.h"
#include <sys/types.h>
void printUsage(char* argv[])
{
printf("Usage: %s <threshold> <maxiterations> <center_real> <center_imaginary> <initialscale> <finalscale> <framecount> <resolution> <output_folder> <colorfile>\n", argv[0]);
printf(" This program simulates the Mandelbrot Fractal, and creates an iteration map of the given center, scale, and resolution, then saves it in output_file\n");
}
/*
This function calculates the threshold values of every spot on a sequence of frames. The center stays the same throughout the zoom. First frame is at initialscale, and last frame is at finalscale scale.
The remaining frames form a geometric sequence of scales, so
if initialscale=1024, finalscale=1, framecount=11, then your frames will have scales of 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1.
As another example, if initialscale=10, finalscale=0.01, framecount=5, then your frames will have scale 10, 10 * (0.01/10)^(1/4), 10 * (0.01/10)^(2/4), 10 * (0.01/10)^(3/4), 0.01 .
*/
void MandelMovie(double threshold, u_int64_t max_iterations, ComplexNumber* center, double initialscale, double finalscale, int framecount, u_int64_t resolution, u_int64_t ** output){
//YOUR CODE HERE
}
/**************
**This main function converts command line inputs into the format needed to run MandelMovie.
**It then uses the color array from FileToColorMap to create PPM images for each frame, and stores it in output_folder
***************/
int main(int argc, char* argv[])
{
//Tips on how to get started on main function:
//MandelFrame also follows a similar sequence of steps; it may be useful to reference that.
//Mayke you complete the steps below in order.
//STEP 1: Convert command line inputs to local variables, and ensure that inputs are valid.
/*
Check the spec for examples of invalid inputs.
Remember to use your solution to B.1.1 to process colorfile.
*/
//YOUR CODE HERE
//STEP 2: Run MandelMovie on the correct arguments.
/*
MandelMovie requires an output array, so make sure you allocate the proper amount of space.
If allocation fails, free all the space you have already allocated (including colormap), then return with exit code 1.
*/
//YOUR CODE HERE
//STEP 3: Output the results of MandelMovie to .ppm files.
/*
Convert from iteration count to colors, and output the results into output files.
Use what we showed you in Part B.1.2, create a seqeunce of ppm files in the output folder.
Feel free to create your own helper function to complete this step.
As a reminder, we are using P6 format, not P3.
*/
//YOUR CODE HERE
//STEP 4: Free all allocated memory
/*
Make sure there's no memory leak.
*/
//YOUR CODE HERE
return 0;
}