xxxxxxxxxx
160
let img = [
"fist.png",
"globe.png",
"globe2.png",
"m19.png",
"protest.png",
"rebellion.png",
"icon04.png",
"ak47.png",
"remington.png",
"LIBERTY.png",
"SNAKES.png",
"FEET2.png",
"hercules.png"
];
let speeds = [-0.5, -0.4, -0.3, -0.2, 0.2, 0.3, 0.4, 0.5];
function preload() {
for (let i = 0; i < img.length; i++) {
img[i] = loadImage(img[i]);
}
}
class Particle {
constructor() {
this.isCircle = true;
this.r = random(110, 130);
this.w = 200;
this.x = random(this.w, width - this.w);
this.y = random(this.w, height - this.w);
this.xSpeed = random(speeds);
this.ySpeed = random(speeds);
this.url = "";
}
createParticle(imgnum) {
noStroke();
fill("rgba(0,0,0,.5)");
//circle(this.x, this.y, this.r);
if (this.isCircle == true) {
image(
img[imgnum],
this.x - this.r / 2,
this.y - this.r / 2,
this.r,
this.r
);
} else {
let ar = img[imgnum].width / img[imgnum].height;
image(
img[imgnum],
this.x - (this.w * ar) / 2,
this.y - this.w / 2 /*img[imgnum].height*/,
this.w * ar,
this.w
);
}
}
moveParticle() {
if (this.isCircle) {
if (this.x < this.r || this.x > width - this.r / 2) this.xSpeed *= -1;
if (this.y < this.r || this.y > height - this.r / 2) this.ySpeed *= -1;
} else {
if (this.x < this.w || this.x > width - this.w / 2) this.xSpeed *= -1;
if (this.y < this.w || this.y > height - this.w / 2) this.ySpeed *= -1;
}
this.x += this.xSpeed;
this.y += this.ySpeed;
}
joinParticles(particles) {
particles.forEach((element) => {
let dis = dist(this.x, this.y, element.x, element.y);
if (dis < 400) {
stroke("rgba(255,255,255,0.5)");
strokeWeight(2);
line(this.x, this.y, element.x, element.y);
}
});
}
clicked() {
var d = dist(this.x, this.y, mouseX, mouseY);
if (this.isCircle) {
if (d <= this.r / 2) {
link(this.url, self);
}
} else {
if (d <= this.w / 2) {
link(this.url, self);
}
}
}
hover() {
var d = dist(this.x, this.y, mouseX, mouseY);
if (this.isCircle) {
if (d <= this.r / 2) {
cursor(HAND);
}
} else {
if (d <= this.w / 2) {
cursor(HAND);
}
}
}
}
let links = [
"https://artintimeslikethis.com/blackpantherscalifornia",
"http://onyedikachuke.com/about",
"http://onyedikachuke.com/about",
"https://artintimeslikethis.com/m19",
"https://www.myfloridahouse.gov/Sections/Documents/loaddoc.aspx?FileName=_h0001er.docx&DocumentType=Bill&BillNumber=0001&Session=2021",
"https://artintimeslikethis.com/wilmington",
"http://onyedikachuke.com/#/spring-break-art-show/",
"https://artintimeslikethis.com/capitol-riot",
"http://publicfiles.firearmspolicy.org/mulford-act/california-ab1591-1967-mulford-act-bill-file.pdf",
"http://onyedikachuke.com/#/thedrawingcenter/",
"http://onyedikachuke.com/#/bronx-museum/",
"http://onyedikachuke.com/#/cuchifritos-gallery-project-space-1/",
"https://lmcc.net/lmcc-arts-center-at-governors-island/onyedika-chuke/",
];
let particles = [];
function setup() {
createCanvas(windowWidth, windowHeight);
for (let i = 0; i < links.length; i++) {
particles.push(new Particle());
particles[i].url = links[i];
if (i > 6) {
particles[i].isCircle = false;
}
}
}
function draw() {
clear();
cursor(ARROW);
//tint(255, 180);
for (let i = 0; i < particles.length; i++) {
particles[i].createParticle(i);
particles[i].moveParticle(particles);
particles[i].joinParticles(particles.slice(i));
particles[i].hover();
}
}
function mousePressed() {
for (var i = 0; i < particles.length; i++) {
particles[i].clicked();
}
}
function link(href, target) {
window.parent.location.href = href;
//window.open(href, target);
}