// Name: cyclePallette // Description: Rotates an array of colors by one. Invoke every frame to cycle the pallette. You must declare an array of colors somewhere in your project. // Syntax: cyclePallete(palette) // Parameters: palette (color[]) - An array of colors used throughout your project. void cyclePalette(color[] palette){ color temp = palette[palette.length - 1]; // set aside last array element for (int i = palette.length - 1; i > 0 ; i-=1){ // rotate array elements palette[i] = palette[i-1]; } palette[0] = temp; // So the last will be first - Matthew 20:16 } // Name: textTrail // Description: Creates a trail of text in a chosen direction, which becomes larger as it grows longer. // Syntax: textTrail(message, xPos, yPos, angle, trailPalette, fontSize, trailLayers ) // Parameters: // message (str) - The text to be written // xPos (int) - X coordinate of text // yPos (int) - Y coordinate of text // angle (int) - Angle of text direction, in degrees // trailPalette (color[]) - An array of colors. Text colors are chosen from this array. // fontSize (int) - Size of text // trailLayers (int) - Number of times text should be overwritten. void textTrail (String message, int xPos, int yPos, int angle, color[] trailPalette, int fontSize, int trailLayers) { float theta = radians(angle); int currentColor = 0; int scaleFactor = fontSize / 2; int remainder = trailLayers % trailPalette.length; int layersPerColor; for (int i = 1 ; i < trailLayers+1; i++){ fill(trailPalette[currentColor]); textSize(fontSize + (fontSize / 5 * i)); textAlign(CENTER); text(message, xPos, yPos); yPos -=sin(theta)* scaleFactor; // Parametric Equation of a Circle xPos +=cos(theta)* scaleFactor; //When the palette doesn't divide evenly into the no. of layers, earlier colors are used an additional time until the remainder is met. int adjustment = 0; if (currentColor+1 <= remainder) {adjustment = 1;} layersPerColor = trailLayers / trailPalette.length + adjustment; if (i % layersPerColor == 0) {currentColor++;} } }