xxxxxxxxxx
117
var phrases = [
{
username: "@EezyOlah",
date: "10:50AM - 19 Mar 13",
originalText: "B1tch dont k1ll my vibe remix!!! Kendrick verse go harder than jay z tho",
color: '#00ff00'
},
{
username: "@fancynancyxxo",
date: "11:54AM - 14 May 13",
originalText: "Have a safe trip Lulu. I love you baby girl! See you in 3 weeks! Kiss the Palestine ground for me and k1ll some jews <3",
color: '#ff0000'
}
];
var num = 23;
var currentPhraseIndex = 0;
var loadingProgress = 0;
var revealButton;
function setup() {
createCanvas(500, 300);
// Create "reveal content" button
revealButton = createButton('Reveal');
revealButton.position(80, 220);
revealButton.mousePressed(revealContent);
}
function draw() {
background(255);
let similarity = calculateJaccardSimilarity(phrases[currentPhraseIndex].originalText, "k1ll");
let result = similarity < 0.5; // Adjust the threshold based on your preference
strokeWeight(3);
stroke(0);
fill(255);
rect(10, 10, 480, 180, 10);
noStroke();
fill(phrases[currentPhraseIndex].color);
ellipse(40, 120, num * loadingProgress, num * loadingProgress);
fill(0);
textSize(16);
// Display either the original text or hashtags based on the reveal button state and the color of the phrase
let displayText;
if (phrases[currentPhraseIndex].color === '#ff0000') {
displayText = revealButton.elt.innerHTML === 'Reveal' ? replaceWithHashtags(phrases[currentPhraseIndex].originalText) : phrases[currentPhraseIndex].originalText;
} else {
displayText = phrases[currentPhraseIndex].originalText;
}
text(phrases[currentPhraseIndex].username, 80, 30);
textSize(12);
text(phrases[currentPhraseIndex].date, 80, 50);
textSize(16);
text(displayText, 80, 80, 400, 120);
if (loadingProgress < 1) {
loadingProgress += 0.02;
}
}
function revealContent() {
// Toggle between 'Reveal' and 'Hide' only for the red dot phrase
if (phrases[currentPhraseIndex].color === '#ff0000') {
if (revealButton.elt.innerHTML === 'Reveal') {
revealButton.elt.innerHTML = 'Hide';
} else {
revealButton.elt.innerHTML = 'Reveal';
}
}
loadingProgress = 0;
}
function mousePressed() {
// Check if the mouse click is within the button area
if (
mouseX > revealButton.position().x &&
mouseX < revealButton.position().x + revealButton.width &&
mouseY > revealButton.position().y &&
mouseY < revealButton.position().y + revealButton.height
) {
// If yes, trigger the button's mousePressed function
revealButton.mousePressed();
} else {
// If no, change the phrase
currentPhraseIndex = (currentPhraseIndex + 1) % phrases.length;
loadingProgress = 0;
// Reset the button text to 'Reveal' when switching to a new phrase
revealButton.elt.innerHTML = 'Reveal';
}
}
// Function to replace words with hashtags
function replaceWithHashtags(text) {
let words = text.split(' ');
let replacedText = words.map(word => '#'.repeat(word.length)).join(' ');
return replacedText;
}
// Function to calculate Jaccard similarity coefficient
function calculateJaccardSimilarity(str1, str2) {
let set1 = new Set(str1.split(" "));
let set2 = new Set(str2.split(" "));
let intersection = new Set([set1].filter(x => set2.has(x)));
let union = new Set([set1, set2]);
return intersection.size / union.size;
}