We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I working on a project and want to create two objects which I can find the center of - and then using these co-ordinates, measure the distance and relative positions of the objects in relation to one another. This is also using the SMT library to create movable objects, so this information and co-ordinates will be changed by user interaction.
I feel like I am making progress with my code, but have confused myself a little bit and am having trouble creating a way to find these central co-ordinates of the two shapes.
Any and all help is much appreciated!
Thanks
import vialab.SMT.*;
PShape ellipse1, ellipse2;
float cX1, cY1;
int[] xpos = new int[10];
int[] ypos = new int[10];
void setup() {
size(displayWidth, displayHeight, SMT.RENDERER);
smooth();
for (int i = 0; i < xpos.length; i ++ ) {
xpos[i] = 0;
cX1 = i;
}
for (int j = 0; j < ypos.length; j ++ ) {
ypos[j] = 0;
cY1 = j;
}
SMT.init( this, TouchSource.AUTOMATIC);
Zone zone1 = new Zone( "GreenZone");
SMT.add( zone1);
Zone zone2 = new Zone( "RedZone");
SMT.add( zone2);
}
void draw() {
background(30);
shapeMode(CENTER);
noStroke();
fill(255, 0, 0);
ellipse1 = createShape(ELLIPSE, cX1, cY1, 500, 500);
fill(0, 0, 255);
ellipse2 = createShape(ELLIPSE, 0, 0, 500, 500);
text("X: "+cX1, 500, 60);
text("Y: "+cY1, 500, 80);
text("mouse: "+mouseX, 500, 100);
}
void drawGreenZone( Zone zone1) {
// fill(0, 255, 0);
shape(ellipse1, 0, 0, 500, 500);
}
void pickDrawGreenZone( Zone zone1) {
ellipse( 0, 0, 500, 500);
}
void touchGreenZone( Zone zone1) {
zone1.drag();
}
void drawRedZone( Zone zone2) {
// fill(255, 0, 50);
shape(ellipse2, 0, 0, 500, 500);
}
void pickDrawRedZone( Zone zone2) {
ellipse( 0, 0, 500, 500);
}
//Touch function for "MyZone"
void touchRedZone( Zone zone2) {
zone2.rst();
}