xxxxxxxxxx
99
/*
final project pitch template
4.15.2024
*/
var currentSlide = 1;
var totalSlides = 4;
var nextSlideActive = false;
var prevSlideActive = false;
// slide 2
var description = "My final projet combines the generative pattern project and the sound sampler.";
// slide 3
var interaction = "The user can click on each part of the pattern to play a different sound. There will be a button to save an image of the canvas.";
var graphicsExample;
function preload() {
graphicsExample = loadImage('pattern.jpg');
}
function setup() {
createCanvas(400, 400);
textFont("Comic Sans MS");
}
function draw() {
background(220);
// first slide
if (currentSlide == 1) {
textAlign(CENTER, CENTER);
textSize(40);
fill("purple");
text('My Final Project', width / 2, height / 2);
text('by Owen', width / 2, height / 2 + 50);
}
if (currentSlide == 2) {
textSize(20);
textAlign(LEFT);
text(description, 50, 50, 300);
}
if (currentSlide == 3) {
textSize(20);
textAlign(LEFT);
text(interaction, 50, 50, 300);
}
// graphics example
if (currentSlide == 4) {
image(graphicsExample, 0, 0);
textAlign(CENTER);
textSize(40);
text("Graphics", width / 2, height / 2);
}
nextSlideActive = button(300, 350, 60, 20, "Next");
prevSlideActive = button(220, 350, 60, 20, "Prev");
}
function mousePressed() {
if (nextSlideActive && currentSlide < totalSlides) {
currentSlide += 1;
}
if (prevSlideActive && currentSlide > 1) {
currentSlide -= 1;
}
}
// draws a button, returns whether it is active
function button(x, y, w, h, txt) {
var isActive = false;
if (mouseX > x && mouseX < x + w &&
mouseY > y && mouseY < y + h) {
isActive = true;
fill('yellow');
} else {
fill("white");
}
rect(x, y, w, h);
textSize(h);
fill(0);
textAlign(LEFT, TOP);
text(txt, x + 2, y + 2);
// return button state to main program
return isActive;
}