Package com.badlogic.gdx.tools.texturepacker.TexturePacker

Examples of com.badlogic.gdx.tools.texturepacker.TexturePacker.Page


    inputRects.reverse();

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


    }
    return pages;
  }

  private Page packPage (Array<Rect> inputRects, int cellWidth, int cellHeight) {
    Page page = new Page();
    page.outputRects = new Array();

    int maxWidth = settings.maxWidth, maxHeight = settings.maxHeight;
    if (settings.edgePadding) {
      maxWidth -= settings.paddingX;
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

    minHeight = Math.max(minHeight, settings.minHeight);

    System.out.print("Packing");

    // Find the minimal page size that fits all rects.
    Page bestResult = null;
    if (settings.square) {
      int minSize = Math.max(minWidth, minHeight);
      int maxSize = Math.min(settings.maxWidth, settings.maxHeight);
      BinarySearch sizeSearch = new BinarySearch(minSize, maxSize, settings.fast ? 25 : 15, settings.pot);
      int size = sizeSearch.reset(), i = 0;
      while (size != -1) {
        Page result = packAtSize(true, size - edgePaddingX, size - edgePaddingY, inputRects);
        if (++i % 70 == 0) System.out.println();
        System.out.print(".");
        bestResult = getBest(bestResult, result);
        size = sizeSearch.next(result == null);
      }
      System.out.println();
      // Rects don't fit on one page. Fill a whole page and return.
      if (bestResult == null) bestResult = packAtSize(false, maxSize - edgePaddingX, maxSize - edgePaddingY, inputRects);
      sort.sort(bestResult.outputRects, rectComparator);
      bestResult.width = Math.max(bestResult.width, bestResult.height);
      bestResult.height = Math.max(bestResult.width, bestResult.height);
      return bestResult;
    } else {
      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(), i = 0;
      int height = settings.square ? width : heightSearch.reset();
      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);
          if (settings.square) height = width;
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

        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

TOP

Related Classes of com.badlogic.gdx.tools.texturepacker.TexturePacker.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.