diff --git a/main/main.pde b/main/main.pde index 37df552..cb9d88b 100644 --- a/main/main.pde +++ b/main/main.pde @@ -1,11 +1,13 @@ -public void settings() { - size(500, 500, P2D); // 2D env -} +boolean pointclickedbool = false; +Point pointclicked; +PointList list = new PointList(); +DrawHalfEdge drawgraph = new DrawHalfEdge(); + public void setup() { + size(800, 500); background(255); fill(0,0); translate(width/2, height/2); - PointList list = new PointList(); Point p1 = new Point(0, 0); list.addPoint(p1); Point p2 = new Point(100, 50); @@ -40,7 +42,6 @@ public void setup() { list.addPoint(p16); Point p17 = new Point (20, 100); list.addPoint(p17); - DrawHalfEdge draw = new DrawHalfEdge(); HalfEdge h1 = new HalfEdge(p1, p2); HalfEdge h2 = new HalfEdge(p1, p4); HalfEdge h3 = new HalfEdge(p3, p1); @@ -81,16 +82,53 @@ public void setup() { //h1.facePrint(); //HalfEdge h5 = new HalfEdge(v1,v2); //h1.facePrint(); - draw.drawGraph(list.getPoints()); + drawgraph.drawGraph(list.getPoints()); //(new Face(h4, list)).printFace(); - (new Face(h12, list)).printFace(); - + //(new Face(h12, list)).printFace(); + print("finsihed set up"); +} +void draw() { + ellipse(50,50,50,50); + if(mousePressed) { + float x = mouseX; + float y = mouseY; + Point p = new Point(x,y); + list.addPoint(p); + drawgraph.drawGraph(list.getPoints()); + System.out.println("entered mousePressed"); + } } /*public void draw() { - fill(0,0,255,40); - noStroke(); - pushMatrix(); // store the default translation matrix - translate(width/2, height/2); // alter the current translation - //ellipse(0,0,100,100); //place the sphere in center of current translation - popMatrix(); // return to default translation -}*/ \ No newline at end of file + if(mousePressed) { + float x = mouseX; + float y = mouseY; + if(pointclickedbool) { + pointclickedbool = false; + for(Point p: list.getPoints()) { + if(p.getX() < x-10 || p.getX() > x + 10) + { + if(p.getY() < y - 10 || p.getY() > y + 10) { + HalfEdge h = new HalfEdge(p, pointclicked); + } + } + } + } else { + for(Point p: list.getPoints()) { + if((p.getX() < x-10) && (p.getX() > x + 10)) + { + if((p.getY() < y - 10) && (p.getY() > y + 10)) { + pointclickedbool = true; + pointclicked = p; + } + } + } + } + Point p = new Point(x,y); + list.addPoint(p); + if(pointclickedbool) { + System.out.println("true"); + } + + } + draw.drawGraph(list.getPoints()); +}*/