the operator < is undefined for the argument type(s) boolean, int
in
Programming Questions
•
1 year ago
- Circle[] circles;
- int numCircles = 50; //number of circles
- int maxDistance; //max distance between circles when draw lines
- int minDistance;
- PImage bg;
- void setup() {
- size(800, 800); //size of window
- smooth(); //draw circles with anti-aliased edge
- bg = loadImage("bg_trans.png");
- // create an array and fill it with circles
- circles = new Circle[numCircles]; //create an array of circles
- for (int i=0; i< numCircles; i++) {
- //random position in the window, random size between 5-15
- circles[i] = new Circle(random(width), random(height), random(2, 10), random(150, 255));
- }
- }
- void draw() {
- // clear background
- background(0, 0, 25);
- tint(255, 50);
- image(bg, 0, 0);
- // update and display the circles
- for (int i=0; i< numCircles; i++) {
- circles[i].update();
- circles[i].display();
- }
- // define maximum distance
- maxDistance = 120;
- minDistance = 50;
- //maxDistance = mouseX; //manuplate lines by mouse cursor
- // look of the lines
- stroke(255, 130);
- strokeWeight(0.5);
- for (int i=0; i< numCircles; i++) {
- // compare circle to other circles
- for (int j=i+1; j< numCircles; j++) {
- // draw line if distance is below 'maxDistance'
- if (minDistance < dist(circles[i].x, circles[i].y, circles[j].x, circles[j].y) < maxDistance){
- line(circles[i].x, circles[i].y, circles[j].x, circles[j].y);
- }
- }
- }
- }
at line 50, error 'the operator < is undefined for the argument type(s) boolean, int' occurs.
When I wrote 'if(dist(circles[i].x, circles[i].y, circles[j].x, circles[j].y) < maxDistance){' at that line, the sketch worked.
In case of ' if((dist(circles[i].x, circles[i].y, circles[j].x, circles[j].y) > minDistance) & (dist(circles[i].x, circles[i].y, circles[j].x, circles[j].y) < maxDistance) < maxDistance){', it still does not work.
Is there anything I'm missing?
1