Package com.badlogic.gdx.utils

Examples of com.badlogic.gdx.utils.Array


        Rect rect = usedRectangles.get(i);
        w = Math.max(w, rect.x + rect.width);
        h = Math.max(h, rect.y + rect.height);
      }
      Page result = new Page();
      result.outputRects = new Array(usedRectangles);
      result.occupancy = getOccupancy();
      result.width = w;
      result.height = h;
      return result;
    }
View Full Code Here


    settings.rotation = false;
    settings.paddingX = 0;

    if (pages == null) {
      Random random = new Random(1243);
      Array<Rect> inputRects = new Array();
      for (int i = 0; i < 240; i++) {
        Rect rect = new Rect();
        rect.name = "rect" + i;
        rect.height = 16 + random.nextInt(120);
        rect.width = 16 + random.nextInt(240);
        inputRects.add(rect);
      }
      for (int i = 0; i < 10; i++) {
        Rect rect = new Rect();
        rect.name = "rect" + (40 + i);
        rect.height = 400 + random.nextInt(340);
        rect.width = 1 + random.nextInt(10);
        inputRects.add(rect);
      }

      long s = System.nanoTime();

      pages = new MaxRectsPacker(settings).pack(inputRects);
View Full Code Here

      return bestNode;
    }

    /** For each rectangle, packs each one then chooses the best and packs that. Slow! */
    public Page pack (Array<Rect> rects, FreeRectChoiceHeuristic method) {
      rects = new Array(rects);
      while (rects.size > 0) {
        int bestRectIndex = -1;
        Rect bestNode = new Rect();
        bestNode.score1 = Integer.MAX_VALUE;
        bestNode.score2 = Integer.MAX_VALUE;
View Full Code Here

        Rect rect = usedRectangles.get(i);
        w = Math.max(w, rect.x + rect.width);
        h = Math.max(h, rect.y + rect.height);
      }
      Page result = new Page();
      result.outputRects = new Array(usedRectangles);
      result.occupancy = getOccupancy();
      result.width = w;
      result.height = h;
      return result;
    }
View Full Code Here

    settings.rotation = false;
    settings.paddingX = 0;

    if (pages == null) {
      Random random = new Random(1243);
      Array<Rect> inputRects = new Array();
      for (int i = 0; i < 240; i++) {
        Rect rect = new Rect();
        rect.name = "rect" + i;
        rect.height = 16 + random.nextInt(120);
        rect.width = 16 + random.nextInt(240);
        inputRects.add(rect);
      }
      for (int i = 0; i < 10; i++) {
        Rect rect = new Rect();
        rect.name = "rect" + (40 + i);
        rect.height = 400 + random.nextInt(340);
        rect.width = 1 + random.nextInt(10);
        inputRects.add(rect);
      }

      long s = System.nanoTime();

      pages = new MaxRectsPacker(settings).pack(inputRects);
View Full Code Here

          }
        });
      }
    }

    Array<Page> pages = new Array();
    while (inputRects.size > 0) {
      Page result = packPage(inputRects);
      pages.add(result);
      inputRects = result.remainingRects;
    }
    return pages;
  }
View Full Code Here

      maxRects.init(width, height);
      Page result;
      if (!settings.fast) {
        result = maxRects.pack(inputRects, methods[i]);
      } else {
        Array<Rect> remaining = new Array();
        for (int ii = 0, nn = inputRects.size; ii < nn; ii++) {
          Rect rect = inputRects.get(ii);
          if (maxRects.insert(rect, methods[i]) == null) {
            while (ii < nn)
              remaining.add(inputRects.get(ii++));
          }
        }
        result = maxRects.getResult();
        result.remainingRects = remaining;
      }
View Full Code Here

  static public DisplayMode[] getDisplayModes () {
    GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    java.awt.DisplayMode desktopMode = device.getDisplayMode();
    java.awt.DisplayMode[] displayModes = device.getDisplayModes();
    Array<DisplayMode> modes = new Array();
    outer:
    for (java.awt.DisplayMode mode : displayModes) {
      for (DisplayMode other : modes)
        if (other.width == mode.getWidth() && other.height == mode.getHeight() && other.bitsPerPixel == mode.getBitDepth())
          continue outer; // Duplicate.
      if (mode.getBitDepth() != desktopMode.getBitDepth()) continue;
      modes.add(new JglfwDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()));
    }
    return modes.toArray(DisplayMode.class);
  }
View Full Code Here

    }
    return glfwGetPrimaryMonitor();
  }

  public DisplayMode[] getDisplayModes () {
    Array<DisplayMode> modes = new Array();
    for (GlfwVideoMode mode : glfwGetVideoModes(getWindowMonitor()))
      modes.add(new JglfwDisplayMode(mode.width, mode.height, 0, mode.redBits + mode.greenBits + mode.blueBits));
    return modes.toArray(DisplayMode.class);
  }
View Full Code Here

  }

  /** Returns all regions with the specified name, ordered by smallest to largest {@link AtlasRegion#index index}. This method
   * uses string comparison to find the regions, so the result should be cached rather than calling this method multiple times. */
  public Array<AtlasRegion> findRegions (String name) {
    Array<AtlasRegion> matched = new Array();
    for (int i = 0, n = regions.size; i < n; i++) {
      AtlasRegion region = regions.get(i);
      if (region.name.equals(name)) matched.add(new AtlasRegion(region));
    }
    return matched;
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.utils.Array

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.