xxxxxxxxxx
486
let smegma = false;
let phase = 0;
let img;
let imgg;
let imgnum = 0;
let previmg = 0;
let b642;
let b642string;
let b64img;
let desc;
let i;
let z2 = [];
let god1 = "Uanna";
let god2 = "Guanyin";
let god3 = "Chaos";
let god4 = "Kali";
let god5 = "Mami Wata";
let v1,v2,v3,v4,v5;
const t1a = "[worship " + god1 + "] ",t1b = "[insult " + god1 + "]",t2a = "[worship " + god2 + "] ",t2b = "[insult " + god2 + "]",t3a = "[worship " + god3 + "] ",t3b = "[insult " + god3 + "]",t4a = "[worship " + god4 + "] ",t4b = "[insult " + god4 + "]",t5a = "[worship " + god5 + "] ",t5b = "[insult " + god5 + "]";
let t1aw, t1bw, t2aw, t2bw, t3aw, t3bw, t4aw, t4bw, t5aw, t5bw;
let buttons = false;
let coolfont;
let hmarg = 40;
let hmarg2 = hmarg + 200;
let vmargint = 56;
let vmarg;
let fontsize = 16;
const text1 = "The year is ";
const text2a = "The land has ", text2b = " in the ", text2c = " of ";
const text3 = "Tell us, o Elder, to whom shall we direct our prayers?"
let curyear;
let counting = false;
let chosengod = god3;
let chosendir = "regressed";
let chosenpres = "abscence";
const introtext1 = "Dear village Elder, these lands are in great peril,";
const introtext2 = "We are in need of your guidance.";
const outrotext1 = "The lands have prospered due to your judgement";
const outrotext2 = "Thank you for your guidance, Elder.";
let hideoverlay;
let noOverlay = false;
const model1 = new rw.HostedModel({
url: "https://landscapes-3f1fa68b.hosted-models.runwayml.cloud/v1/",
token: "UPh5+9spZ+7vbKyhgIv1zA==",
});
const model2 = new rw.HostedModel({
url: "https://densecap-52fb3f11.hosted-models.runwayml.cloud/v1/",
token: "sOq+3RYz9fdAO1JP2/uz4g==",
});
function setup() {
//img3 = loadImage("download.png");
//img4 = loadImage("img4.jpeg");
coolfont = loadFont("Inconsolata.ttf");
canvas = createCanvas(512, 512);
//createButton('generate descriptions').mousePressed(generateDescriptions);
hideoverlay = createButton('hide overlay');
hideoverlay.mousePressed(function() {overlayToggle(true);});
hideoverlay.mouseReleased(function() {overlayToggle(false);});
t1aw = textWidth(t1a) + 24; t1bw = textWidth(t1b) + 24; t2aw = textWidth(t2a) + 30; t2bw = textWidth(t2b) + 30; t3aw = textWidth(t3a) + 24; t3bw = textWidth(t3b) + 24; t4aw = textWidth(t4a) + 16; t4bw = textWidth(t4b) + 16; t5aw = textWidth(t5a) + 34; t5bw = textWidth(t5b) + 34;
curyear = Math.round(random(0,10000));
for(i=0;i<512;i++){
z2.push(random(-0.3,0.3));
}
const inputs = { "z": z2, "truncation": 0.8
};
model1.query(inputs).then(outputs => {
//console.log(outputs);
img = outputs;
});
}
function draw() {
if(img){
imgg = createImg(img.image);
imgg.hide();
}
if(imgg){
image(imgg,0,0);
}
else{
textSize(32);
fill(255);
text("LOADING...",55,256);
}
if(imgg && previmg == imgnum){
imgnum++;
noOverlay = true;
setTimeout(function(){
saveCanvas("img" + imgnum, 'jpg');
noOverlay = false;}, 100)
}
if(imgg && phase == 0){
phase = 1;
smegma = true;
generateDescriptions();
setTimeout(function(){phase=2;}, 2000)
}
if(phase==2 && smegma){
vmarg = vmargint;
noStroke();
fill(0,0,0,150);
rect(hmarg-20,vmarg-36,canvas.width-40,400)
textSize(fontsize);
textFont(coolfont);
fill(255);
text(text1 + curyear, hmarg, vmarg);
vmarg = vmarg + fontsize*2;
text(introtext1, hmarg, vmarg);
vmarg = vmarg + fontsize;
text(introtext2, hmarg, vmarg);
vmarg = vmarg + fontsize*2;
text(text3, hmarg, vmarg);
vmarg = vmarg + fontsize*2;
buttons = true;
/*
v1 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==1 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t1a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==1 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t1b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v2 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==2 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t2a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==2 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t2b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v3 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==3 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t3a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==3 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t3b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v4 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==4 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t4a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==4 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t4b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v5 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==5 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t5a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==5 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t5b, hmarg2, vmarg);
*/
}
if(desc && phase > 2 && phase < 7){
vmarg = vmargint;
noStroke();
fill(0,0,0,150);
rect(hmarg-20,vmarg-36,canvas.width-40,400);
textSize(fontsize);
textFont(coolfont);
fill(255);
text(text1 + curyear, hmarg, vmarg);
vmarg = vmarg + fontsize*2;
text(text2a + chosendir + text2b + chosenpres + text2c + chosengod, hmarg, vmarg);
vmarg = vmarg + fontsize*2;
for(i=0;i<5;i++){
text(desc[i],hmarg,vmarg);
vmarg = vmarg + fontsize;
}
vmarg = vmarg + fontsize;
text(text3, hmarg, vmarg);
vmarg = vmarg + fontsize*2;
buttons = true;
/*
v1 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==1 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t1a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==1 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t1b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v2 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==2 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t2a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==2 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t2b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v3 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==3 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t3a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==3 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t3b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v4 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==4 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t4a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==4 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t4b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v5 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==5 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t5a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==5 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t5b, hmarg2, vmarg);
*/
}
if(buttons){
v1 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==1 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t1a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==1 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t1b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v2 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==2 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t2a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==2 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t2b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v3 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==3 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t3a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==3 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t3b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v4 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==4 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t4a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==4 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t4b, hmarg2, vmarg);
vmarg = vmarg + fontsize;
v5 = vmarg;
if(isMouseInsideText()){if(isMouseInsideText()[0]==5 && isMouseInsideText()[1]==1){fill(255);} else{fill(200);}}
text(t5a, hmarg, vmarg);
if(isMouseInsideText()){if(isMouseInsideText()[0]==5 && isMouseInsideText()[1]==2){fill(255);} else{fill(200);}}
text(t5b, hmarg2, vmarg);
}
if(desc && phase > 6){
vmarg = vmargint;
noStroke();
fill(0,0,0,150);
rect(hmarg-20,vmarg-36,canvas.width-40,400);
textSize(fontsize);
textFont(coolfont);
fill(255);
text(text1 + curyear, hmarg, vmarg);
vmarg = vmarg + fontsize*2;
text(text2a + chosendir + text2b + chosenpres + text2c + chosengod, hmarg, vmarg);
vmarg = vmarg + fontsize*2;
for(i=0;i<5;i++){
text(desc[i],hmarg,vmarg);
vmarg = vmarg + fontsize;
}
vmarg = vmarg + fontsize;
text(outrotext1, hmarg, vmarg);
vmarg = vmarg + fontsize;
text(outrotext2, hmarg, vmarg);
}
buttons = false;
if(imgg && noOverlay){
image(imgg,0,0)
}
if(counting){
curyear++;
}
}
function mouseClicked(){
if(isMouseInsideText() && counting == false){
let num1;
let num2;
if(isMouseInsideText()[1]==1){
chosendir = "developed";
chosenpres = "presence";
num2 = 0.1;
}
else if(isMouseInsideText()[1]==2){
chosendir = "regressed";
chosenpres = "abscence";
num2 = -0.1;
}
if(isMouseInsideText()[0]==1){
chosengod = god1;
num1 = 0;
}
else if(isMouseInsideText()[0]==2){
chosengod = god2;
num1 = 100;
}
else if(isMouseInsideText()[0]==3){
chosengod = god3;
num1 = 200;
}
else if(isMouseInsideText()[0]==4){
chosengod = god4;
num1 = 300;
}
else if(isMouseInsideText()[0]==5){
chosengod = god5;
num1 = 400;
}
desc = undefined;
smegma = false;
console.log(chosengod + " = " + chosenpres);
console.log("num1 = " + num1 + " num2 = " + num2);
generateLandscape(num1,num2,0)
}
}
function isMouseInsideText() {
if(mouseY > v1 - textAscent() && mouseY < v1 + textDescent()){
if(mouseX > hmarg && mouseX < hmarg + t1aw ){
return [1,1];
}
else if(mouseX > hmarg2 && mouseX < hmarg2 + t1bw){
return [1,2];
}
}
else if(mouseY > v2 - textAscent() && mouseY < v2 + textDescent()){
if(mouseX > hmarg && mouseX < hmarg + t2aw ){
return [2,1];
}
else if(mouseX > hmarg2 && mouseX < hmarg2 + t2bw){
return [2,2];
}
}
else if(mouseY > v3 - textAscent() && mouseY < v3 + textDescent()){
if(mouseX > hmarg && mouseX < hmarg + t3aw ){
return [3,1];
}
else if(mouseX > hmarg2 && mouseX < hmarg2 + t3bw){
return [3,2];
}
}
else if(mouseY > v4 - textAscent() && mouseY < v4 + textDescent()){
if(mouseX > hmarg && mouseX < hmarg + t1aw ){
return [4,1];
}
else if(mouseX > hmarg2 && mouseX < hmarg2 + t4bw){
return [4,2];
}
}
else if(mouseY > v5 - textAscent() && mouseY < v5 + textDescent()){
if(mouseX > hmarg && mouseX < hmarg + t5aw ){
return [5,1];
}
else if(mouseX > hmarg2 && mouseX < hmarg2 + t5bw){
return [5,2];
}
}
}
function generateLandscape(c,int,framecount){
if(framecount<18){
imgnum++
noOverlay = true;
setTimeout(function(){
saveCanvas("img" + imgnum, 'jpg');
noOverlay = false;}, 100);
counting = true;
const inputs = { "z": z2, "truncation": 0.8
};
//model1.info().then(info => console.log(info));
model1.query(inputs).then(outputs => {
//console.log(outputs);
img = outputs;
// use the outputs in your project
});
for(i=0;i<10;i++){
z2[c+i] = z2[c+i] + int;
}
console.log(z2[0]);
//console.log(outputs)
setTimeout(function() {generateLandscape(c,int,framecount+1)},1000);
}
else{
phase++;
counting = false;
generateDescriptions();
}
}
function generateDescriptions(){
//img4.loadPixels();
//b642 = img4.canvas.toDataURL();
//console.log(b642);
const inputs = {
"image": img.image,
"max_detections": 5,
};
//console.log(inputs);
//model2.info().then(info => console.log(info));
model2.query(inputs).then(outputs => {
desc = outputs.classes;
console.log(desc);
// use the outputs in your project
});
}
function overlayToggle(on){
if(on){
noOverlay = true;
}
else{
noOverlay = false;
}
}