// Processing code by Etienne JACOB // motion blur template by beesandbombs, explanation/article: https://bleuje.com/tutorial6/ // See the license information at the end of this file. // View the rendered result at: https://bleuje.com/gifanimationsite/single/spiralssphere/ ////////////////////////////////////////////////////////////////////////////// // Start of template int[][] result; // pixel colors buffer for motion blur float t; // time global variable in [0,1[ float c; // other global variable for testing things, controlled by mouse //----------------------------------- // some generally useful functions... float c01(float x) { return constrain(x,0,1); } // ease in and out, [0,1] -> [0,1], with a parameter g: // https://patakk.tumblr.com/post/88602945835/heres-a-simple-function-you-can-use-for-easing float ease(float p, float g) { if (p < 0.5) return 0.5 * pow(2*p, g); else return 1 - 0.5 * pow(2*(1 - p), g); } // defines a map function variant to constrain or not in target interval (exists in openFrameworks) float map(float x, float a, float b, float c, float d, boolean constr) { return constr ? constrain(map(x,a,b,c,d),min(c,d),max(c,d)) : map(x,a,b,c,d); } // short one to map an x from [a,b] to [0,1] and constrain float mp01(float x, float a, float b) { return map(x,a,b,0,1,true); } // reversed pow that does some kind of ease out, [0,1] -> [0,1], with a parameter g float pow_(float p, float g) { return 1-pow(1-p,g); } // hyperbolic tangent, maps ]-infinity,+infinity[ to ]-1,1[ float tanh(float x) { return (float)Math.tanh(x); } //----------------------------------- void draw() { if (!recording) // test mode... { t = (mouseX*1.3/width)%1; c = mouseY*1.0/height; if (mousePressed) println(c); draw_(); } else // render mode... { for (int i=0; i