/** * Esfera. * David Pena. * * Distribucion aleatoria uniforme sobre la superficie de una esfera. * * Modifications by subpixel: * removal of unused global arrays; * calculate end point of a hair as the hairlength distance from the hair base, not as a point at a fixed distance from the centre of the sphere (which causes hairs to stretch); * reverse Ymouse reactivity so ball spins in the direction of mouse movement instead of against it; * added start/pause functionality on mouse click event */ import processing.opengl.*; // ------------------------------------------------------------ // Global variables // ------------------------------------------------------------ boolean looping = false; // Opening state of the sketch. Set true to open un-paused. int cuantos = 1200; // Number of hairs pelo[] lista ; // Array/list of hairs float radio; // Radius of the sphere float hairmin; // Minimum hair length float hairmax; // Maximum hair length float rx = 0; float ry = 0; // ------------------------------------------------------------ // Main setup method. // ------------------------------------------------------------ void setup() { size(640, 480, OPENGL); // Set the canvas size, and use OpenGL rendering if (!looping) noLoop(); // Opportunity to open the sketch in a paused state radio = height/4; // The central sphere is half the window height (radius therefore 1/4 window height) hairmin = radio * 0.1; // Minimum hair length set proportionally to the sphere radius hairmax = radio * 0.4; // Maximum hair length ser proportionally to the sphere radius lista = new pelo[cuantos]; // Initialise the array for the number of hairs for (int i=0; i