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

SCM Repository

[diderot] View of /tests/glk-tests/back/mandel.diderot
ViewVC logotype

View of /tests/glk-tests/back/mandel.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4640 - (download) (annotate)
Tue Sep 27 20:54:47 2016 UTC (2 years, 11 months ago) by glk
File size: 1334 byte(s)
initial result of svn export --username anonsvn --password=anonsvn https://svn.smlnj-gforge.cs.uchicago.edu/svn/diderot/branches/vis15/src/tests/
/*! \file mandel.diderot
 *
 * \author Gordon Kindlmann
 */

/*
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 */

// ../bin/diderotc --exec mandel.diderot && ./mandel && unu quantize -b 8 -i rgb.nrrd -o mandel.png 

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

function real coord (real x, int idx) = lerp(x - fov, x + fov, 1, idx, reso);

// Strand definition
strand mandel (vec2 c) {
   vec2 z = [0, 0];
   int iter = 0;
   output vec3 rgb = [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| > escape) {
         // point has escaped; set continuous color from iter and radius
         real t = 4*log(iter - log2(log(|z|)/log(escape)));
         rgb = [sin(-t), cos(t), sin(t)];
         rgb = ([1.8, 1.8, 1.8] + rgb)/2.8;
         stabilize;
      }
      if (iter > maxiter) {
         rgb = [0, 0, 0];
         stabilize;
      }
   }
}

// Strand initialization
initially [ mandel([coord(center[0], crIdx), coord(center[1], ciIdx)])
            | ciIdx in 1..reso, crIdx in 1..reso ];

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