xxxxxxxxxx
154
let modelURL = "https://teachablemachine.withgoogle.com/models/3v18EGH_g/";
let classifier;
let video;
let label = "";
let button;
let resultMessage = "";
let animationCounter = 0; // Counter for animation
let sinta;
let queercestors;
function preload() {
classifier = ml5.imageClassifier(modelURL + "model.json");
sinta = loadImage('sinta.PNG');
queercestors = loadImage('queercestors.png');
}
function setup() {
createCanvas(windowWidth, windowHeight);
// Create video capture
video = createCapture(VIDEO);
video.hide();
// Start classifying the webcam feed
classifyVideo();
// Initial state is the intro screen
state = "intro";
}
function draw() {
background(30);
if (state === "intro") {
showIntroScreen();
} else if (state === "detect") {
showDetectionScreen();
} else if (state === "result") {
showResultScreen();
}
}
// Show intro screen
function showIntroScreen() {
textAlign(CENTER, CENTER);
fill(255);
textSize(40);
text("magpakatotoo ka", width / 2, height / 2 - 50);
textSize(16);
textStyle(ITALIC);
text("show your real self", width / 2, height / 2 - 10);
if (!button) {
button = createButton("totoo ako");
button.position(width / 2 - 50, height / 2 + 50);
button.size(120, 40);
button.style("font-size", "14px");
button.mousePressed(() => {
state = "detect";
button.hide();
});
}
}
// Show detection screen
function showDetectionScreen() {
image(video, 0, 0, width, height);
textSize(20);
fill(255);
text("activating anting anting...", width / 2, height - 50);
// If a label is detected, move to the result screen
if (label === "Queercestors") {
state = "result";
resultMessage = "You've activated quantum protection from your queercestors.";
} else if (label === "Sinta") {
state = "result";
resultMessage = "You've invoked divine love \n for you and your team.";
}
}
// Show result screen
function showResultScreen() {
background(10, 10, 30);
textAlign(CENTER, CENTER);
if (label === "Queercestors") {
drawRainbowText("You've activated quantum protection from your queercestors.", width / 3, height / 2);
image(queercestors, 0, 0, 600,600);
} else if (label === "Sinta") {
drawGlowingPinkText("You've invoked divine love \n for you and your team.", width / 2, height / 2);
image(sinta, 500, 0, 600, 600);
}
// Create a restart button
if (!button) {
button = createButton("Restart");
button.position(width / 2 - 50, height - 100);
button.size(100, 40);
button.style("font-size", "20px");
button.mousePressed(() => {
state = "intro";
button.hide();
label = ""; // Reset label
button = null; // Reset button
});
}
}
// Rainbow glowing text animation
function drawRainbowText(message, x, y) {
animationCounter += 0.1; // Adjust speed of animation
textSize(40);
for (let i = 0; i < message.length; i++) {
let hue = (animationCounter + i * 0.1) % 1; // Gradual rainbow effect
fill(color(`hsba(${hue * 360}, 100%, 70%, 1)`));
text(message.charAt(i), x - message.length * 10 / 2 + i * 20, y);
}
}
// Glowing pastel pink text animation
function drawGlowingPinkText(message, x, y) {
animationCounter += 0.02; // Adjust speed of glow effect
let glowSize = 20 + sin(animationCounter) * 10; // Pulsating glow
textSize(40);
for (let i = 0; i < 5; i++) {
fill(255, 182, 193, 50 - i * 10); // Glowing layers (lighter at edges)
text(message, x, y);
}
fill(255, 182, 193); // Solid pastel pink
text(message, x, y);
}
// Classify the current video frame
function classifyVideo() {
classifier.classify(video, gotResults);
}
// Handle classification results
function gotResults(error, results) {
if (error) {
console.error(error);
return;
}
label = results[0].label; // Store the label of the highest confidence prediction
classifyVideo(); // Classify again
}