Package geomerative

Examples of geomerative.RShape


    }   
  }

  private void drawShape(RShape shape) {
    for (int i = 0; i < shape.countChildren(); i++) {
      RShape s = shape.children[i];
      drawShape(s);
    }
    for (int i = 0; i < shape.countPaths(); i++) {
      RPath p = shape.paths[i];
      RPoint[] points = p.getPoints();
View Full Code Here


  }
 
  private RShape computeIntersections(RShape shape) {
    float x = 0;
    float y = 0;
    RShape allLines = new RShape();
    while (x < MAX_X*2 && y < MAX_X*2) {     
      RShape s = new RShape();
      s.addMoveTo(new RPoint(0, y));
      s.addLineTo(new RPoint(x, 0));
      RPoint[] points = shape.getIntersections(s);
      if (points != null) {
        List<MyPoint> pointsList = new ArrayList<MyPoint>();     
        for (RPoint p : points) {
          pointsList.add(new MyPoint(p));
        }
        Collections.sort(pointsList);
        if (pointsList.size() % 2 == 0) {
          int i = 0;
          while (i <  pointsList.size()) {
            RPoint p1 = pointsList.get(i++);
            RPoint p2 = pointsList.get(i++);
            RShape l = new RShape();
            l.addMoveTo(p1);
            l.addLineTo(p2);
            allLines.addChild(l);
          }
        }
        else if (points != null) {
          System.out.println("points: " + pointsList.size());
View Full Code Here

      for (int i = 0; i < listing.length; i++) {
        System.out.println("file: " + listing[i]);
      }
      currentFileName = listing[0];
      System.out.println("loading " + currentFileName);
      RShape shape = RG.loadShape(BUFFER_NEW_PATH + currentFileName);
      //shape.scale(10.0F);
      print(shape, "loaded: ");
      return shape;
    }
    return null;
View Full Code Here

   *            Shape to draw
   */
  public void drawShape(PGraphics g, RShape shape) {
    // Recurse through any children of this shape
    for (int i = 0; i < shape.countChildren(); i++) {
      RShape s = shape.children[i];
      drawShape(g, s);
    }

    // Iterate through each path of the shape, drawing them to the screen
    for (int i = 0; i < shape.countPaths(); i++) {
View Full Code Here

   *            RShape to proces
   */
  public void convertToInstructions(List<Instruction> instructions, RShape shape) {
    // Recurse through any children of current shape
    for (int i = 0; i < shape.countChildren(); i++) {
      RShape s = shape.children[i];
      convertToInstructions(instructions, s);
    }

    // Generate Instruction objects for every path of shape
    for (int i = 0; i < shape.countPaths(); i++) {
View Full Code Here

    return resultPath;
  }
 
  public void getAllPaths(List<RPath> paths, RShape shape) {
    for (int i = 0; i < shape.countChildren(); i++) {
      RShape s = shape.children[i];
      getAllPaths(paths, s);
    }
    for (int i = 0; i < shape.countPaths(); i++) {
      paths.add(shape.paths[i]);
    }
View Full Code Here

   *
   * @return RShape The SVG file contents, if it exists. Otherwise null.
   */
  private RShape loadNewShape(String filename) {
    System.out.println("loading " + filename);
    RShape shape = RG.loadShape(BUFFER_ACC_PATH + filename);
    shape.scale(svgScale, shape.getCenter());
    print(shape, "loaded: ");
    return shape;
  }
View Full Code Here

    }
  }

  private void drawShape() {
    int i = 0;
    shape = new RShape();
    for (int y = 0; y < img.height; y++) {
      RShape s = new RShape();
      s.addMoveTo(new RPoint(0*TILE_SIZE, y*TILE_SIZE));
      for (int x = 0; x < img.width; x++) {
        pushMatrix();
        int c = img.pixels[i++];
        int r = (c >> 16) & 0xff;
        int g = (c >> 8) & 0xff;
        int b = c & 0xff
        // 76.5 + 150.45 + 28.05 = 255;
        //float bright = (float)(0.3F * r + 0.59F * g + 0.11F * b);
        float bright = (r + g + b) / 768F;
        bright = 1 - (bright);
        bright *= brightScale;
        // bright = circleSize - bright;
        // println(bright);
        translate(x*TILE_SIZE, y*TILE_SIZE);
        if (bright < 0.2) {
          s.addMoveTo(new RPoint((x+1)*TILE_SIZE, y*TILE_SIZE+4));
        }
        else if (bright < 0.4) {
          line(0, 3, TILE_SIZE, 3);
          s.addLineTo(new RPoint((x+1)*TILE_SIZE, y*TILE_SIZE+4));
        }
        else if (bright < 0.6) {
          line(0, 4, 2, 1);
          line(2, 1, 4, 5);
          line(4, 5, 8, 4);
          s.addLineTo(new RPoint(x*TILE_SIZE+2, y*TILE_SIZE+1));
          s.addLineTo(new RPoint(x*TILE_SIZE+4, y*TILE_SIZE+5));
          s.addLineTo(new RPoint(x*TILE_SIZE+8, y*TILE_SIZE+4));
        }
        else if (bright < 0.8) {
          line(0, 4, 2, 1);
          line(2, 1, 4, 8);
          line(4, 8, 8, 4);
          s.addLineTo(new RPoint(x*TILE_SIZE+2, y*TILE_SIZE+1));
          s.addLineTo(new RPoint(x*TILE_SIZE+4, y*TILE_SIZE+8));
          s.addLineTo(new RPoint(x*TILE_SIZE+8, y*TILE_SIZE+4));
        }
        else {
          line(0, 4, 2, 0);
          line(2, 0, 3, 7);
          line(3, 7, 4, 1);
          line(4, 1, 6, 7);
          line(6, 7, 8, 4);
          s.addLineTo(new RPoint(x*TILE_SIZE+2, y*TILE_SIZE+0));
          s.addLineTo(new RPoint(x*TILE_SIZE+3, y*TILE_SIZE+7));
          s.addLineTo(new RPoint(x*TILE_SIZE+4, y*TILE_SIZE+1));
          s.addLineTo(new RPoint(x*TILE_SIZE+6, y*TILE_SIZE+7));
          s.addLineTo(new RPoint(x*TILE_SIZE+8, y*TILE_SIZE+4));
        }
        popMatrix();      
      }
      shape.addChild(s);
    }   
View Full Code Here

TOP

Related Classes of geomerative.RShape

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.