Eclipse and Processing with Colours
in
Integration and Hardware
•
8 months ago
Hi guys,
I am working on a project on eclipse that requires separating out two colours Red and Green from a connect4 board. I was hoping to use those colours to determine what move has been made. I layed a grid over the board to isolate where the tiles will be , and used colorMode()s get() to return the colours found at those locations. However the PrintStatment is telling me that the numbers at those spots are 1) in the minus and 2) it sometimes returns the same value for red and green i.e -16777216. Below is the java code I am currently working on , ... if anyone has any ideas or impute, I would appreciate it
import processing.core.*;
public class ColourTrackingExample extends PApplet
{
//load an instance of image
PImage img = loadImage("BoardPieces.jpg");
//open an instance of setup
public void setup()
{
//set window size to be that of the pic
size(320, 240)
;
//draw a grid around it so we know the location of desired pixels
image(img,0,0);
//horizontal lines
line(290, 15, 25, 15);
line(290, 55, 25, 55);
line(290, 95, 25, 95);
line(290, 135, 25, 135);
line(290, 175, 25, 175);
line(290, 215, 25, 215);
//vertical lines
line(290, 15, 290, 215);
line(240, 15, 240, 215);
line(200, 15, 200, 215);
line(160, 15, 160, 215);
line(115, 15, 115, 215);
line(70, 15, 70, 215);
line(25, 15, 25, 215);
//get the colour o coordinates (290, 15)
int p = get(290, 15);
int p1 = get(290, 55);
int p2 = get(290, 95);
int p3 = get(290, 135);
int p4 = get(290, 175);
int p5 = get(290, 215);
System.out.println("(290, 15)g = " + p);
System.out.println("(290, 55)r = " + p1);
System.out.println("(290, 95)g = " + p2);
System.out.println("(290, 135)r = " + p3);
System.out.println("(290, 175)r = " + p4);
System.out.println("(290, 215)g = " + p5);
System.out.println("------------------");
int p6 = get(240, 15);
int p7 = get(200, 15);
System.out.println("(240, 15)r = " + p6);
System.out.println("(200, 15)g = " + p7);
}
}
(--------------------------------------------------- AND OUT PUT -------------------------------)
(290, 15)g = -16711424
(290, 55)r = -16777216
(290, 95)g = -16777216
(290, 135)r = -16777216
(290, 175)r = -16777216
(290, 215)g = -16711424
------------------
(240, 15)r = -16777216
(200, 15)g = -16777216
1