31 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| unsigned int secant_fractal(double x, double y, unsigned int escape, unsigned int iterations) {
 | |
|   for(unsigned int iter = 0; iter < iterations; iter++) { 
 | |
|     double next_x;
 | |
|     next_x = x / cos(y);
 | |
|     y = y / cos(x);
 | |
|     x = next_x;
 | |
|     if((pow(x, 2) + pow(y, 2)) >= escape) return iter;
 | |
|   }
 | |
| }
 | |
| unsigned int cosecant_fractal(double x, double y, unsigned int escape, unsigned int iterations) {
 | |
|   for(unsigned int iter = 0; iter < iterations; iter++) { 
 | |
|     double next_x;
 | |
|     next_x = x / sin(y);
 | |
|     y = y / sin(x);
 | |
|     x = next_x;
 | |
|     if((pow(x, 2) + pow(y, 2)) >= escape) return iter;
 | |
|   }
 | |
| }
 | |
| 
 | |
| __kernel void render_frame(__global unsigned int *frame_output, //uint8_t *mask, //more bit depth is possible
 | |
|     double x_step, double y_step,
 | |
|     double x_start, double y_start,
 | |
|     unsigned int iterations, unsigned int escape, double ratio) {  
 | |
|   unsigned int result;
 | |
|   double on_x = (get_global_id(0) * x_step) + x_start;
 | |
|   double on_y = (get_global_id(1) * y_step) + y_start;
 | |
|   
 | |
|   frame_output[(get_global_id(1) * get_global_size(1)) + get_global_id(0)] =
 | |
|     secant_fractal(on_x, on_y, escape, iterations);
 | |
| }
 | 
