Package ch.blackspirit.graphics.shape

Examples of ch.blackspirit.graphics.shape.Line


    context.draw();
  }

  @Test
  public void drawLineWithColor() {
    final Line lines = getLine(false);
    context.setGraphicsListener(new GraphicsListener() {
      public void draw(View view, Graphics graphics) {
        graphics.clear();
        graphics.drawLine(lines, true);
      }
View Full Code Here


    });
    context.draw();
  }
  @Test
  public void drawLine() {
    final Line lines = getLine(false);
    context.setGraphicsListener(new GraphicsListener() {
      public void draw(View view, Graphics graphics) {
        graphics.clear();
        graphics.drawLine(lines, false);
      }
View Full Code Here

    });
    context.draw();
  }
  @Test
  public void drawLineWithColorNull() {
    final Line lines = getLine(true);
    context.setGraphicsListener(new GraphicsListener() {
      public void draw(View view, Graphics graphics) {
        graphics.clear();
        graphics.drawLine(lines, true);
      }
View Full Code Here

    });
    context.draw();
  }

  private Line getLine(boolean includeColorNull) {
    Line t = new Line();
    t.getPoint(0).set(0,0);
    t.getPoint(1).set(50,50);
    if(!includeColorNull) {
      setColor(t, new Color4f(0, 0, 1, 1));
    }
    return t;
  }
View Full Code Here

    return t;
  }

  private Line[] getLines(boolean includeNull, boolean includeColorNull) {
    Line[] lines = new Line[3];
    Line t1 = new Line();
    t1.getPoint(0).set(0,0);
    t1.getPoint(1).set(50,50);
    setColor(t1, new Color4f(1, 0, 0, 1));
    lines[0] = t1;
   
    if(!includeNull) {
      Line t2 = new Line();
      t2.getPoint(0).set(100,100);
      t2.getPoint(1).set(150,150);
      setColor(t2, new Color4f(0, 1, 0, 1));
      lines[1] = t2;
    }

    Line t3 = new Line();
    t3.getPoint(0).set(200,200);
    t3.getPoint(1).set(250,250);
    if(!includeColorNull) {
      setColor(t3, new Color4f(0, 0, 1, 1));
    }
    lines[2] = t3;
    return lines;
View Full Code Here

      // Create segments from the cut-outs convex points.
      // A segment is only valid if its ray doesn't intersect with segment
      // from the point before to the point after. (it's not pointing outside!)
      populateNonConvexPoints(cutOut, false);
      for(Vector2f point: nonConvexPoints) {
        Line outside = nonConvexPointOutsideSegment.get(point);
        for(Vector2f point2: cutOut) {
          ifpoint2 != point &&
            point2 != outside.getPoint(0) &&
            point2 != outside.getPoint(1)) {
            if(Geometry.raySegmentIntersect(point, point2, outside.getPoint(0), outside.getPoint(1)) == Intersection.FALSE) {
              addSegment(point, point2);
            }
          }
        }
      }

      // testing: draw concave and parallel cut-out points
//      for(Vector2f point: nonConvexPoints) {
//        renderer.drawPoint(point.x, point.y, 6f, new Color4f(1,0,0,1));
//      }
//      for(Vector2f point: nonConvexPointsParallel) {
//        renderer.drawPoint(point.x, point.y, 6f, new Color4f(0,1,0,1));
//      }
    }
   
    // Create segments from outline points making the TShape non-convex.
    // A segment is only valid if its ray doesn't intersect with segment
    // from the point before to the point after. (it's not pointing outside!)
    populateNonConvexPoints(shape.getOutline(), true);
    for(Vector2f point: nonConvexPoints) {
      Line outside = nonConvexPointOutsideSegment.get(point);
      for(Vector2f point2: shape.getOutline()) {
        ifpoint2 != point &&
          point2 != outside.getPoint(0) &&
          point2 != outside.getPoint(1)) {
          if(Geometry.raySegmentIntersect(point, point2, outside.getPoint(0), outside.getPoint(1)) == Intersection.FALSE) {
            addSegment(point, point2);
          }
        }
      }
    }

    // Handle redundant points
    if(!removeRedundantPoints) {
      // parallel points have not necessary been connected yet
      // connect them to all common connected points of their pre- and successor
      // if the connection does not already exist!
      for(Vector2f vec: nonConvexPointsParallel) {
        Line prepost = nonConvexPointOutsideSegment.get(vec);
        List<Line> lines1 = segmentMap.get(prepost.getPoint(0));
        List<Line> lines2 = segmentMap.get(prepost.getPoint(1));
        for(Line line1: lines1) {
          Vector2f point1 = line1.getPoint(0);
          if(point1 == prepost.getPoint(0)) point1 = line1.getPoint(1);
         
          for(Line line2: lines2) {
            Vector2f point2 = line2.getPoint(0);
            if(point2 == prepost.getPoint(1)) point2 = line2.getPoint(1);
           
            if(point2 == point1) {
              if(getLine(vec, point1) == null) {
                addSegment(vec, point1);
              }
View Full Code Here

        Vector2f pre = nonConvexPointsParallelPredecessor.get(vec);
        int preindex = rolloverRange(points.indexOf(pre), points.size() -1);
        int postindex = rolloverRange(preindex + 1, points.size() -1);
       
        Vector2f post = points.get(postindex);
        nonConvexPointOutsideSegment.put(vec, new Line(pre, post));
      }
    }
   
    int max = points.size() - 1;
    List<Vector2f> aSide = new ArrayList<Vector2f>();
    List<Vector2f> bSide = new ArrayList<Vector2f>();
    float aSideAngle = 0f;
    float bSideAngle = 0f;
    boolean useASide = true;
    Vector2f angleVec1 = new Vector2f();
    Vector2f angleVec2 = new Vector2f();
    for(int i = 0; i < points.size(); i++) {
      int before = rolloverRange(i-1,max);
      int after = rolloverRange(i+1,max);
      int after2 = rolloverRange(i+2,max);

      Vector2f currentVec = points.get(i);
      angleVec1.set(points.get(before));
      angleVec2.set(points.get(after));
      angleVec1.sub(currentVec);
      angleVec2.sub(currentVec);
      float angle = angleVec2.angle(angleVec1);
       
      nonConvexPointOutsideSegment.put(currentVec, new Line(points.get(before), points.get(after)));
     
      if(useASide) {
        aSide.add(currentVec);
        aSideAngle += angle;
        bSideAngle += TWO_PI - angle;
View Full Code Here

    }
    if(segmentIntersection(point1, point2)) {
      return;
    }
   
    Line line = new Line(point1, point2);
    segments.add(line);
   
    // Maintain line lists for points
    List<Line> lineList1 = segmentMap.get(point1);
    if(lineList1 == null) {
View Full Code Here

        renderer.setColor(white);
        renderer.drawText("" + lineCount + " Random Lines");
        renderer.clearTransform();
        float randomLinesWidth = randomLinesX2 - randomLinesX1;
        float randomLinesHeight = randomLinesY2 - randomLinesY1;
        Line line;
        Color4f lineColor = null;
        if(lines.size() == lineCount) {
          line = lines.remove(0);
          lineColor = line.getColor(0);
        } else {
          line = new Line();
          lineColor = new Color4f();
          line.setColor(0, lineColor);
          line.setColor(1, lineColor);
        }
        lines.add(line);
        for(int i = 0; i < 2; i++) {
          line.getPoint(i).x = random.nextFloat() * randomLinesWidth + randomLinesX1;
          line.getPoint(i).y = random.nextFloat() * randomLinesHeight + randomLinesY1;
        }
        float linealpha = 1;
        if(alphaC == 5) linealpha = random.nextFloat();
        lineColor.set(random.nextFloat(), random.nextFloat(), random.nextFloat(), linealpha);

View Full Code Here

TOP

Related Classes of ch.blackspirit.graphics.shape.Line

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.