Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] View of /tests/new-tests/mandelbrot.diderot
 [diderot] / tests / new-tests / mandelbrot.diderot

# View of /tests/new-tests/mandelbrot.diderot

Thu Jul 27 21:42:48 2017 UTC (2 years, 4 months ago) by jhr
File size: 1412 byte(s)
```  Add support for "--double" option in regression tests
```
```#version 1.0

// bmark-diderot.diderot
//
// COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
//
// compute Mandelbrot set image
//

// unu quantize -b 8 -i rgb.nrrd -o mandel.png

// Global definitions
input int reso = 2000;
input int maxiter = 2000;
vec2 center = [-1.2, -0.3]; // [0.0,0.0] for whole thing
real fov = 0.15; // 2.0 for whole thing

// Strand definition
strand mandel (vec2 c) {
vec2 z = [0.0, 0.0];
int iter = 0;
output vec3 rgb = [0.0, 0.0, 0.0];
update  {
z = [z[0]^2 - z[1]^2, 2.0*z[0]*z[1]] + c; // z = z^2 + c
iter += 1;
if (z•z > 4.0) {
// point has escaped; set color based on iteration
real t = 11.0*real(iter)^0.2;
rgb = [sin(t), sin(t + 2.0*π/3.0), sin(t - 2.0*π/3.0)];
rgb = ([1.7, 1.7, 1.7] + rgb)/2.7;
stabilize;
}
else if (iter > maxiter)
stabilize;
}
}

// Strand initialization
initially [ mandel([lerp(center[0]-fov, center[0]+fov, 1.0, real(crIdx), real(reso)),
lerp(center[1]-fov, center[1]+fov, 1.0, real(ciIdx), real(reso))])
| ciIdx in 1..reso, crIdx in 1..reso ];

//create_array { mandel([lerp(center[0]-fov, center[0]+fov, 1.0, real(crIdx), real(reso)),
//                    lerp(center[1]-fov, center[1]+fov, 1.0, real(ciIdx), real(reso))])
//	  | ciIdx in 1..reso, crIdx in 1..reso }
```