Package com.badlogic.gdx.tools.imagepacker.TexturePacker2

Examples of com.badlogic.gdx.tools.imagepacker.TexturePacker2.Page


    if (settings.alias) {
      String crc = hash(rect.getImage(this));
      Rect existing = crcs.get(crc);
      if (existing != null) {
        System.out.println(rect.name + " (alias of " + existing.name + ")");
        existing.aliases.add(new Alias(rect));
        return null;
      }
      crcs.put(crc, rect);
    }
View Full Code Here


        placeRect(bestNode);
        rects.removeIndex(bestRectIndex);
      }

      Page result = getResult();
      result.remainingRects = rects;
      return result;
    }
View Full Code Here

      for (int i = 0; i < usedRectangles.size; i++) {
        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

      }
    }

    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

    // Find the minimal page size that fits all rects.
    BinarySearch widthSearch = new BinarySearch(minWidth, settings.maxWidth, settings.fast ? 25 : 15, settings.pot);
    BinarySearch heightSearch = new BinarySearch(minHeight, settings.maxHeight, settings.fast ? 25 : 15, settings.pot);
    int width = widthSearch.reset(), height = heightSearch.reset(), i = 0;
    Page bestResult = null;
    while (true) {
      Page bestWidthResult = null;
      while (width != -1) {
        Page result = packAtSize(true, width - edgePaddingX, height - edgePaddingY, inputRects);
        if (++i % 70 == 0) System.out.println();
        System.out.print(".");
        bestWidthResult = getBest(bestWidthResult, result);
        width = widthSearch.next(result == null);
      }
View Full Code Here

  }

  /** @param fully If true, the only results that pack all rects will be considered. If false, all results are considered, not all
   *           rects may be packed. */
  private Page packAtSize (boolean fully, int width, int height, Array<Rect> inputRects) {
    Page bestResult = null;
    for (int i = 0, n = methods.length; i < n; i++) {
      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++) {
View Full Code Here

      binWidth = width;
      binHeight = height;

      usedRectangles.clear();
      freeRectangles.clear();
      Rect n = new Rect();
      n.x = 0;
      n.y = 0;
      n.width = width;
      n.height = height;
      freeRectangles.add(n);
View Full Code Here

      freeRectangles.add(n);
    }

    /** Packs a single image. Order is defined externally. */
    public Rect insert (Rect rect, FreeRectChoiceHeuristic method) {
      Rect newNode = scoreRect(rect, method);
      if (newNode.height == 0) return null;

      int numRectanglesToProcess = freeRectangles.size;
      for (int i = 0; i < numRectanglesToProcess; ++i) {
        if (splitFreeNode(freeRectangles.get(i), newNode)) {
          freeRectangles.removeIndex(i);
          --i;
          --numRectanglesToProcess;
        }
      }

      pruneFreeList();

      Rect bestNode = new Rect();
      bestNode.set(rect);
      bestNode.score1 = newNode.score1;
      bestNode.score2 = newNode.score2;
      bestNode.x = newNode.x;
      bestNode.y = newNode.y;
      bestNode.width = newNode.width;
View Full Code Here

    /** 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;

        // Find the next rectangle that packs best.
        for (int i = 0; i < rects.size; i++) {
          Rect newNode = scoreRect(rects.get(i), method);
          if (newNode.score1 < bestNode.score1 || (newNode.score1 == bestNode.score1 && newNode.score2 < bestNode.score2)) {
            bestNode.set(rects.get(i));
            bestNode.score1 = newNode.score1;
            bestNode.score2 = newNode.score2;
            bestNode.x = newNode.x;
View Full Code Here

    }

    public Page getResult () {
      int w = 0, h = 0;
      for (int i = 0; i < usedRectangles.size; i++) {
        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);
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.tools.imagepacker.TexturePacker2.Page

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.