Sketch runs, but no response in sketch window? Help
in
Programming Questions
•
2 years ago
Hi, new to the forum, but I've been messing around with processing for a quite while, but only really simple stuff.
So I can't quite get my head round this one, and I'm about ready to give up, any help would be greatly appreciated.
There's no error messages when the sketch is run, but also no response in the sketch window, ( points aren't drawn, or lines connecting them), so something must be wrong, I'm just not sure what.
The idea of the sketch is to be able to draw points anywhere in the window by clicking the mouse, then depending on a points distance from any other point, a line is drawn to connect them if they are close enough to each other. I also want to be able to increased or decreased the connection distance by the add and subtract keys on the keyboard.(I think the code I have for that bit is fine, its just the rest.)
So I can't quite get my head round this one, and I'm about ready to give up, any help would be greatly appreciated.
There's no error messages when the sketch is run, but also no response in the sketch window, ( points aren't drawn, or lines connecting them), so something must be wrong, I'm just not sure what.
The idea of the sketch is to be able to draw points anywhere in the window by clicking the mouse, then depending on a points distance from any other point, a line is drawn to connect them if they are close enough to each other. I also want to be able to increased or decreased the connection distance by the add and subtract keys on the keyboard.(I think the code I have for that bit is fine, its just the rest.)
//Sketch
int marker;
int r = 0; // color rgb: r-value
int g = 255; // color rgb: g-value
int b = 255; // color rgb: b-value
int[] PX = new int [marker];
int[] PY = new int [marker];
float Dist = 50;
int r = 0; // color rgb: r-value
int g = 255; // color rgb: g-value
int b = 255; // color rgb: b-value
int[] PX = new int [marker];
int[] PY = new int [marker];
float Dist = 50;
void setup(){
size(600, 400);
smooth();
for (int i = 0; i < marker; i++){
if (mousePressed == true) {
PX[i] = pmouseX;
PY[i] = pmouseY;
}
}
}
size(600, 400);
smooth();
for (int i = 0; i < marker; i++){
if (mousePressed == true) {
PX[i] = pmouseX;
PY[i] = pmouseY;
}
}
}
void draw(){
background(255);
stroke(r, g, b);
strokeWeight(1);
//Change Line colour
if ((keyPressed == true) && (key == 'c')){
r = int(random(0, 150));
g = int(random(0, 150));
b = int(random(0, 150));
//Change Connecting line length
if ((keyPressed == true) && (key == '=')){
Dist += 0.5;
} else if ((keyPressed == true) && (key =='-')) {
Dist = 0.5;
}
// Draw Connecting Lines
for (int i = 0; i < marker-1; i++) {
for (int j = i; j < marker; j++){
if(dist(PX[i], PY[i], PX[i], PY[i]) < Dist){
line(PX[i], PY[i], PX[i], PY[i]);
}
}
}
//Draw points (markers)
for (int i = 0; i < marker; i++){
point(PX[i], PY[i]);
}
}
}
background(255);
stroke(r, g, b);
strokeWeight(1);
//Change Line colour
if ((keyPressed == true) && (key == 'c')){
r = int(random(0, 150));
g = int(random(0, 150));
b = int(random(0, 150));
//Change Connecting line length
if ((keyPressed == true) && (key == '=')){
Dist += 0.5;
} else if ((keyPressed == true) && (key =='-')) {
Dist = 0.5;
}
// Draw Connecting Lines
for (int i = 0; i < marker-1; i++) {
for (int j = i; j < marker; j++){
if(dist(PX[i], PY[i], PX[i], PY[i]) < Dist){
line(PX[i], PY[i], PX[i], PY[i]);
}
}
}
//Draw points (markers)
for (int i = 0; i < marker; i++){
point(PX[i], PY[i]);
}
}
}
1