// http://lovehateubuntu.blogspot.com/2010/07/barnsley-fern.html // https://gist.github.com/robbrit/477834 // http://en.wikipedia.org/wiki/Barnsley_fern f1 = expr( dt:f[i]=1; xx=0.0; yy = 0.16 * yy; ); f2 = expr( dt:f[i]=2; xxx = 0.85 * xx + 0.04 * yy; yy = -0.04 * xx + 0.85 * yy + 1.6; xx = xxx; ); f3 = expr( dt:f[i]=3; xxx = 0.2 * xx - 0.26 * yy; yy = 0.23 * xx + 0.22 * yy + 1.6; xx = xxx; ); f4 = expr( dt:f[i]=4; xxx = -0.15 * xx + 0.28 * yy; yy = 0.26 * xx + 0.24 * yy + 0.44; xx = xxx; ); dt = New Table( "Fern", Add Rows( 1000000 ), New Column( "x" ), New Column( "y" ), new column("f"), New Column( "part", Formula( If( Row() == 1 | Lag( :f, 1 ) == 1, 0, Lag( :f, 1 ) == 3, -1, Lag( :f, 1 ) == 4, 1, Lag( :part, 1 ) ) ) ), New Column( "leaf", Formula( If( Row() == 1, 1, Lag( :f, 1 ) == 2, Lag( :leaf, 1 ) + 1, 1 ) ) ) ,private ); dt << beginDataUpdate; start = Tick Seconds(); xx = 0; yy = 0; N = N Rows( dt ); For( i = 1, i <= N, i++, dt:x[i] = xx; dt:y[i] = yy; Row State( /*dt,*/ i ) = Color State( {0.15, yy / 10, 0.25 * (3 + xx) / 6} ); which = Random Integer( 0, 99 ); If( which < 1, f1, which < 86, f2, which < 93, f3, f4 ); ); end = Tick Seconds(); dt << endDataUpdate; show(end-start); dt << newDataView; dt<