const char* CreateImageSource[] = {
"__kernel void CreateImage(__global float* image, __global float* fractalProperties, __global unsigned int* fpOperations)",
"{",
//"unsigned int n = get_global_id(0) * (*workSize) + get_local_id(0);",
"unsigned int n = get_global_id(0);",
"int iterations = 0;",
"float realC = fractalProperties[0] + (n % 800) * fractalProperties[4];", //2
"float imaginaryC = fractalProperties[2] + (int)(n / 800) * fractalProperties[5];", // 2
"float realA = 0;",
"float imaginaryA = 0;",
"float magnitude = sqrt(pow(realC, 2) + pow(imaginaryC, 2));", //5
"float hue = 0;",
"float value = .556789;",
"float saturation = 1;",
"float red = 0;",
"float green = 0;",
"float blue = 0;",
"int i = 0;",
"float f = 0;",
"float p = 0;",
"float q = 0;",
"float t = 0;",
"fpOperations[n] = 0;", // 9 up to this point
"while(magnitude > fractalProperties[7] && magnitude < fractalProperties[8] && iterations < fractalProperties[6])", // 3
"{",
"float tempRealA = (realA * realA) - (imaginaryA * imaginaryA);", // 3
"imaginaryA = (realA * imaginaryA) + (imaginaryA * realA);", // 3
"realA = tempRealA + realC;", // 1
"imaginaryA = imaginaryA + imaginaryC;", // 1
"magnitude = sqrt(pow(realA, 2) + pow(imaginaryA, 2));", // 3
"iterations += 1;",
"fpOperations[n] += 14;",
"}",
"if(iterations < 20 || (int)(iterations / fractalProperties[6]) == 1)",
"{",
"image[n*3] = 0.0;",
"image[n*3+1] = 0.0;",
"image[n*3+2] = 0.0;",
"}",
"else",
"{",
"hue = 360 * ((float)iterations / (float)fractalProperties[6]);", // 2
"hue /= (float)60;", // 1
"i = (int)floor(hue);", // 1
"f = hue - i;", // 1
"p = value * (1 - saturation);", // 2
"q = value * (1 - saturation * f);", // 3
"t = value * (1 - saturation * (1 - f));", //4
"switch(i)",
"{",
"case 0:",
"{",
"red = value;",
"green = t;",
"blue = p;",
"break;",
"}",
"case 1:",
"{",
"red = q;",
"green = value;",
"blue = p;",
"break;",
"}",
"case 2:",
"{",
"red = p;",
"green = value;",
"blue = t;",
"break;",
"}",
"case 3:",
"{",
"red = p;",
"green = q;",
"blue = value;",
"break;",
"}",
"case 4:",
"{",
"red = t;",
"green = p;",
"blue = value;",
"break;",
"}",
"default:",
"{",
"red = value;",
"green = p;",
"blue = q;",
"break;",
"}",
"}",
"image[n*3] = red;",
"image[n*3+1] = green;",
"image[n*3+2] = blue;",
"}",
"}"