Immediate help required with a mouse clicking seven-segment counter setup
in
Programming Questions
•
7 months ago
Hello all,
I am trying to create code in processing that will do three things:
1) Respond to mouse clicks on many different arrows on my size layout.
2) When a click is detected, to increase a specific counter (one counter per pair of arrows) correlating to that pair of arrows.
3) Only let the arrows increase that specific counter when my mouse is inside them.
I am very new to this and the working code I have now is just a graphic, the code I've been working on to get this some what working I will post separately.
Please, any help is accepted and appreciated! Thank-you!
// *Code for "THE ROBOGNATHIC" Dental Articulator Windows-based touch screen platform.*
PFont f; // Declaring an object.
void setup(){
size (900,550); // Setting up tablet screen size.
background(150); // Setting the background to grey.
stroke(0); // Setting the outline to black.
f = createFont ("Arial",16,false); // Referencing the font name and function; Arial, 16 pt., anti-aliasing off.
}
void draw(){
// *Seperating Lines*
line(170,550,170,280); // Parallel Robot Y-Axis Line.
line(170,280,900,280); // Parallel Robot X-Axis Line.
line(450,550,450,280); // Forward/Reverse & Elevation Divider Line.
line(740,550,740,280); // Elevation Divider Line.
// *ROBOT HOME Button*
fill(0,0,255); // Sets the blue button color.
rectMode(CORNERS); // Initiates rectangle mode.
rect(40,450,120,530); // States corner locations of rectangle.
// *Linear X-Slide HOME Button*
fill(0,0,255); // Sets the blue button color.
rectMode(CORNERS); // Initiates rectangle mode.
rect(250,335,350,370); // States corner locations of rectangle.
// *Stepper Motor HOME Button*
fill(0,0,255); // Sets the blue button color.
rectMode(CORNERS); // Initiates rectangle mode.
rect(550,335,650,370); // States corner locations of rectangle.
// *PITCH plus/minus arrows*
fill(0,255,0); // Setting the interior of the arrow to green.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
line(40,220,130,220); // Arrow divider line.
fill(255,0,0); // Setting the interior of the arrow to red.
pushMatrix(); // Used for calling up translate and rotate.
translate(95,290); // Amount of space translatted up/down.
translate(75,150); // Centre of previous arrow.
rotate(PI); // Rotate arrow 180 degrees.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
popMatrix(); // Used for closing the translate/rotate command.
// *ELEVATION plus/minus arrows*
fill(255,0,0); // Setting the interior of the arrow to red.
pushMatrix(); // Used for calling up translate and rotate.
translate(760,590); // Amount of space translatted up/down.
rotate(PI); // Rotate arrow 180 degrees.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
popMatrix(); // Used for closing the translate/rotate command.
line(600,395,600,485); // Arrow divider line.
fill(0,255,0); // Setting the interior of the arrow to green.
pushMatrix(); // Used for calling up translate and rotate.
translate(440,290); // Amount of space translatted up/down.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
popMatrix(); // Used for closing the translate/rotate command.
// *YAW plus/minus arrows*
fill(255,0,0); // Setting the interior of the arrow to green.
pushMatrix(); // Used for calling up translate and rotate.
translate(110,245); // Amount of space translatted up/down.
rotate(3*PI/2); // Rotate 270 degrees.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
popMatrix();
line(330,120,330,210); // Arrow divider line.
fill(0,255,0); // Setting the interior of the arrow to red.
pushMatrix(); // Used for calling up translate and rotate.
translate(550,75); // Amount of space translatted up/down.
rotate(PI/2); // Rotate arrow 180 degrees.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
popMatrix(); // Used for closing the translate/rotate command.
// *FORWARD/REVERSE plus/minus arrows*
fill(255,0,0); // Setting the interior of the arrow to green.
pushMatrix(); // Used for calling up translate and rotate.
translate(80,520); // Amount of space translated up/down.
rotate(3*PI/2); // Rotate 270 degrees.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
popMatrix(); // Used for closing the translate/rotate command.
line(300,390,300,470); // Arrow divider line.
fill(0,255,0); // Setting the interior of the arrow to red.
pushMatrix(); // Used for calling up translate and rotate.
translate(520,350); // Amount of space translatted up/down.
rotate(PI/2); // Rotate arrow 180 degrees.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
popMatrix(); // Used for closing the translate/rotate command.
// *ROLL plus/minus arrows*
fill(0,255,0); // Setting the interior of the arrow to green.
pushMatrix(); // Used for calling up translate and rotate.
translate(500,15); // Amount of space translatted up/down.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
popMatrix(); // Used for closing the translate/rotate command.
line(650,120,650,210); // Arrow divider line.
fill(0,255,0); // Setting the interior of the arrow to green.
pushMatrix(); // Used for calling up translate and rotate.
translate(630,15); // Amount of space translatted up/down.
beginShape(); // Shape of arrow begin.
vertex(60,150); // Point #1
vertex(50,150); // Point #2
vertex(85,110); // Point #3
vertex(120,150); // Point #4
vertex(110,150); // Point #5
vertex(110,190); // Point #6
vertex(60,190); // Point #7
vertex(60,150); // Point #1
endShape(); // Shape of arrow end.
popMatrix(); // Used for closing the translate/rotate command.
// *Text Identifiers*
// *Title*
textAlign(CENTER); // Centres the text in the middle of the screen.
textFont(f,36); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("THE ROBOGNATHIC",width/2,50); // Displays text using 3 arguments; the text, x and y location.
// *Pitch*
textAlign(CENTER);
textFont(f,25); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("PITCH",85,80); // Displays text using 3 arguments; the text, x and y location.
// *Mini-Actuator HOME Position Title*
textAlign(CENTER); // Centres the text in the middle of the screen.
textFont(f,20); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("ROBOT HOME",85,425); // Displays text using 3 arguments; the text, x and y location.
// *Mini-Actuator HOME Button*
textAlign(CENTER); // Centres the text in the middle of the screen.
textFont(f,22); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("HOME",80,500); // Displays text using 3 arguments; the text, x and y location.
// *Yaw*
textAlign(CENTER); // Centres the text in the middle of the screen.
textFont(f,25); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("YAW",330,110); // Displays text using 3 arguments; the text, x and y location.
// *Roll*
textAlign(CENTER); // Centres the text in the middle of the screen.
textFont(f,25); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("ROLL",650,110); // Displays text using 3 arguments; the text, x and y location.
// *Linear X-Slide HOME Button*
textAlign(CENTER); // Centres the text in the middle of the screen.
textFont(f,22); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("HOME",300,360); // Displays text using 3 arguments; the text, x and y location.
// *Forward/Reverse*
textAlign(CENTER); // Centres the text in the middle of the screen.
textFont(f,25); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("FORWARD/REVERSE",310,310); // Displays text using 3 arguments; the text, x and y location.
// *Stepper Motor HOME Button*
textAlign(CENTER); // Centres the text in the middle of the screen.
textFont(f,22); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("HOME",600,360); // Displays text using 3 arguments; the text, x and y location.
// *Elevation*
textAlign(CENTER); // Centres the text in the middle of the screen.
textFont(f,25); // Uses text variable and size to specify font being used.
fill(255); // Specifies color of letters.
text("ELEVATION",600,310); // Displays text using 3 arguments; the text, x and y location.
}
1