Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added drag functionality to edges
  • Loading branch information
cor11004 committed Dec 15, 2015
1 parent 65e21f2 commit a2aba27
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
5 changes: 2 additions & 3 deletions main/Face.pde
Expand Up @@ -18,7 +18,6 @@ public class Face {
float minY = 0;
float maxY = y;
if (outerComponent != null) {
Point p;
minX = outerComponent.getOrigin().getX();
maxX = outerComponent.getOrigin().getX();
minY = outerComponent.getOrigin().getY();
Expand All @@ -33,8 +32,8 @@ public class Face {
temp = temp.getnext();
}
}
for (int i = minX; i < (int)maxX; i++) {
for (int j = minY; j < (int)maxY; j++) {
for (int i = (int) minX; i < (int)maxX; i++) {
for (int j = (int) minY; j < (int)maxY; j++) {
p = new Point(i, j);
if (inSpecificFace(p, pl)) {
point(i,j);
Expand Down
30 changes: 25 additions & 5 deletions main/main.pde
Expand Up @@ -93,8 +93,13 @@ public void setup() {
//(new Face(h12, list)).printFace();
}
void draw() {
//background(255);
if(mode != 4) {
background(255);
}
drawgraph.drawGraph(list.getPoints());
if(pointclickedbool) {
line(pointclicked.getX(), pointclicked.getY(), mouseX,mouseY);
}
}
void keyPressed() {
switch (key) {
Expand Down Expand Up @@ -148,6 +153,20 @@ void keyPressed() {
}

}
public void mousePressed() {
if(mode == 0) {
float x = mouseX;
float y = mouseY;
for(Point p: list.getPoints()) {
if((p.getX() - 10 < x) && (p.getX() + 10 > x)) {
if((p.getY() - 10 < y) && (p.getY() + 10 > y)) {
pointclicked = p;
pointclickedbool = true;
}
}
}
}
}
void mouseReleased() {
float x = mouseX;
float y = mouseY;
Expand Down Expand Up @@ -225,6 +244,7 @@ public void colorFace(float x, float y) {
}
noFill();
}

public void insertMode(float x, float y) {
if(pointclickedbool) {
pointclickedbool = false;
Expand All @@ -242,7 +262,7 @@ public void insertMode(float x, float y) {
}
}
}
} else {
} /*else {
for(Point p: list.getPoints()) {
if((p.getX() - 10 < x) && (p.getX() + 10 > x)) {
if((p.getY() - 10 < y) && (p.getY() + 10 > y)) {
Expand All @@ -251,7 +271,7 @@ public void insertMode(float x, float y) {
}
}
}
}
}*/
if(!pointclickedbool && !linedrawn) {
Point p = new Point(x,y);
list.addPoint(p);
Expand All @@ -272,7 +292,7 @@ public void removePointMode(float x, float y) {
}
if(removePoint) {
list.removePoint(removeThis);
background(255);
//background(255);
}
}

Expand All @@ -284,7 +304,7 @@ public void removeEdgeMode(float x, float y) {
HalfEdge h = list.getHalfEdge(removeEdgePoint, p);
if(h != null) {
h.Remove();
background(255);
//background(255);
}
removeEdge = false;
}
Expand Down

0 comments on commit a2aba27

Please sign in to comment.