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

SCM Repository

[diderot] View of /branches/vis12/test/mandl.diderot
ViewVC logotype

View of /branches/vis12/test/mandl.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1893 - (download) (annotate)
Mon May 28 05:36:29 2012 UTC (7 years, 4 months ago) by glk
File size: 977 byte(s)
for making a Mandlebrot set image
// ../bin/diderotc --exec mandl.diderot && ./mandl && unu quantize -b 8 -i rgb.nrrd -o mandl.png 

// Global definitions
input int reso = 800;
input int maxiter = 1000;

// Strand definition
strand mandl(int crIdx, int ciIdx) {
   vec2 c = [lerp(-2.0, 2.0, 1.0, real(crIdx), real(reso)),
             lerp(-2.0, 2.0, 1.0, real(ciIdx), real(reso))];
   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.2, 1.2, 1.2] + rgb)/2.0;
         stabilize;
      }
      if (iter > maxiter) {
         rgb = [0.0, 0.0, 0.0];
         stabilize;
      }
   }
}

// Strand initialization
initially [ mandl(crIdx, ciIdx) | ciIdx in 1..reso, crIdx in 1..reso ];

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