Concept
This work acts an oracle by generating wise sayings. Predefined times, elements, actions and destinations are stored in the program and they are randomly paired up to create the oracle. This work employs the concept of lists to store the times, elements, actions and destinations. Text in p5js concept was explored in this work by employing textAlign, textSize and textFont to create the desired output for the work.
A background animation was created for the program by creating translucent circle that randomly move around on the screening. This was done using class and arrays. To keep the design visually appealing, when a ball goes off the screen, it appears on the opposite side of the screen and and continues moving the same trajectory.
An oracles fades and a new one appears and this is done by changing the transparency of the text each frame. When the text becomes fully transparent, it is deleted and a new one is formed and displayed. When you click on the screen, the program can also change between light and dark mode using the callback function mouseClicked and an if statement
Code I’m proud of
for (let i=0; i<currentLines.length; i++) {
text(currentLines[i], width/2, startY + (i*spacing));
}
// Fading
textAlpha += fadeSpeed;
if (textAlpha < 0) {
currentLines.length = 0;
generateNewPoem();
fadeSpeed = 2;
}
if (textAlpha > 400) {
fadeSpeed = -2;
}
This is the code that generates the oracle and causes the fading effect. A for loop is used to print out randomly generated text in a vertical format and the if statements gradually increase the opaqueness of the the text and then makes it transparent eventually disappear.
Embedded Sketch
How it was made
The texts in the various arrays that are randomly selected where generated with Chat GPT with the goal of creating a more natural and consistent text
Reflection
This was a good exercise to make use of my knowledge in text manipulation, arrays, classes and other concepts learnt in other lectures. This work can be improved by building on the background animations and changing the colors the text are printed in to create a more visually pleasing effect.