Hi, I want to make my code when mouse is clicked it can open 2nd sketch.
right now it only appears when I click and released my mouse. ( i know it is because it is in void draw)
I want it to be hold the 2nd sketch and have interaction there too.
is there a possible way?
1 Like
boolean pos = false;
boolean pos2 = false;
void setup() {
size(550, 800, P3D);
}
void draw() {
background(255);
PFont f = createFont ("Garamond", 20);
fill(0);
textFont(f);
textSize(20);
String q = "real";
String q2 = "dream";
if (mouseY > 0 && mouseY < height/2
&& mouseX > 0 && mouseX < width)
{
fill(0);
} else {
noStroke();
fill(255);
}
rect(0, 0, width, height/2);
if (mouseY > 400 && mouseY < height
&& mouseX > 0 && mouseX < width)
{
fill(0);
} else {
noStroke();
fill(255);
}
rect(0, 400, width, height/2);
if (mouseY > 0 && mouseY < height/2
&& mouseX > 0 && mouseX < width)
{
fill(255);
} else {
fill(0);
}
textSize(18);
text(q, width/2, height/4);
if (mouseY > 400 && mouseY < height
&& mouseX > 0 && mouseX < width)
{
fill(255);
} else {
fill(0);
}
textSize(18);
text(q2, width/2-10, 600);
//void mouseClicked() {
// if (mouseY > 350 && mouseY < 350+35
// && mouseX > 228 && mouseX < 228+90)
// {
// pos = true;
// drawDream();
// } else {
// pos = false;
// }
//}
String t = "inceptioninceptioninception";
float radius = 120;
float angle = radians(360) / t.length() ;
float x, y, z;
PFont f;
int numRings = 6;
void drawDream() {
f = createFont ("Serif", 20);
textFont(f);
textAlign(CENTER);
textMode(SHAPE);
textSize(20);
smooth(8);
fill(255);
numRings = 8;
background(0);
lights();
translate(mouseX, mouseY);
rotateX(PI/2.5);
rotateY(0);
rotate(frameCount * .04);
for (int i = 0; i < numRings; i++) {
translate(0, 0, i+30);
wordRing(radius, angle);
}
}
void wordRing (float thisRadius, float thisAngle) {
for (int i=0; i< t.length(); i++) {
x = cos(thisAngle * i) * thisRadius;
y = sin(thisAngle * i) * thisRadius;
pushMatrix();
translate(x, y);
rotateX(-HALF_PI);
rotateY(-thisAngle*i + HALF_PI);
text(t.charAt((t.length()-1) - i), 0, 0);
popMatrix();
}
}
sorry, it is quite messy…
1 Like