Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /tests/new-tests/mandelbrot.diderot
ViewVC logotype

Annotation of /tests/new-tests/mandelbrot.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5223 - (view) (download)

1 : jhr 5223 #version 1.0
2 :    
3 : glk 4640 // bmark-diderot.diderot
4 :     //
5 :     // COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
6 :     // All rights reserved.
7 :     //
8 :     // compute Mandelbrot set image
9 :     //
10 :    
11 :     // unu quantize -b 8 -i rgb.nrrd -o mandel.png
12 :    
13 :     // Global definitions
14 :     input int reso = 2000;
15 :     input int maxiter = 2000;
16 :     vec2 center = [-1.2, -0.3]; // [0.0,0.0] for whole thing
17 :     real fov = 0.15; // 2.0 for whole thing
18 :    
19 :     // Strand definition
20 :     strand mandel (vec2 c) {
21 :     vec2 z = [0.0, 0.0];
22 :     int iter = 0;
23 :     output vec3 rgb = [0.0, 0.0, 0.0];
24 :     update {
25 :     z = [z[0]^2 - z[1]^2, 2.0*z[0]*z[1]] + c; // z = z^2 + c
26 :     iter += 1;
27 :     if (z•z > 4.0) {
28 :     // point has escaped; set color based on iteration
29 :     real t = 11.0*real(iter)^0.2;
30 :     rgb = [sin(t), sin(t + 2.0*π/3.0), sin(t - 2.0*π/3.0)];
31 :     rgb = ([1.7, 1.7, 1.7] + rgb)/2.7;
32 :     stabilize;
33 :     }
34 :     else if (iter > maxiter)
35 :     stabilize;
36 :     }
37 :     }
38 :    
39 :     // Strand initialization
40 :     initially [ mandel([lerp(center[0]-fov, center[0]+fov, 1.0, real(crIdx), real(reso)),
41 :     lerp(center[1]-fov, center[1]+fov, 1.0, real(ciIdx), real(reso))])
42 :     | ciIdx in 1..reso, crIdx in 1..reso ];
43 :    
44 :     //create_array { mandel([lerp(center[0]-fov, center[0]+fov, 1.0, real(crIdx), real(reso)),
45 :     // lerp(center[1]-fov, center[1]+fov, 1.0, real(ciIdx), real(reso))])
46 :     // | ciIdx in 1..reso, crIdx in 1..reso }

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0