Package com.badlogic.gdx.math

Examples of com.badlogic.gdx.math.Rectangle


    maxy = maxy < vertices[Y2] ? vertices[Y2] : maxy;
    maxy = maxy < vertices[Y3] ? vertices[Y3] : maxy;
    maxy = maxy < vertices[Y4] ? vertices[Y4] : maxy;

    if (bounds == null) bounds = new Rectangle();
    bounds.x = minx;
    bounds.y = miny;
    bounds.width = maxx - minx;
    bounds.height = maxy - miny;
    return bounds;
View Full Code Here


    if (scissors.size == 0) {
      if (scissor.width < 1 || scissor.height < 1) return false;
      Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);
    } else {
      // merge scissors
      Rectangle parent = scissors.get(scissors.size - 1);
      float minX = Math.max(parent.x, scissor.x);
      float maxX = Math.min(parent.x + parent.width, scissor.x + scissor.width);
      if (maxX - minX < 1) return false;

      float minY = Math.max(parent.y, scissor.y);
View Full Code Here

  /** Pops the current scissor rectangle from the stack and sets the new scissor area to the new top of stack rectangle. In case
   * no more rectangles are on the stack, {@link GL20#GL_SCISSOR_TEST} is disabled.
   * <p>
   * Any drawing should be flushed before popping scissors. */
  public static Rectangle popScissors () {
    Rectangle old = scissors.pop();
    if (scissors.size == 0)
      Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
    else {
      Rectangle scissor = scissors.peek();
      Gdx.gl.glScissor((int)scissor.x, (int)scissor.y, (int)scissor.width, (int)scissor.height);
    }
    return old;
  }
View Full Code Here

  public static Rectangle getViewport () {
    if (scissors.size == 0) {
      viewport.set(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
      return viewport;
    } else {
      Rectangle scissor = scissors.peek();
      viewport.set(scissor);
      return viewport;
    }
  }
View Full Code Here

   * @param y
   */
  public Character(Texture texture, float x, float y) {
    currentFrame = new TextureRegion(texture);
    position = new Vector2(x, y);
    rect = new Rectangle(x, y, texture.getWidth(), texture.getHeight());
  }
View Full Code Here

   * {@link #clipEnd()} if true is returned.
   * @return false if the clipping area is zero and no drawing should occur.
   * @see ScissorStack */
  public boolean clipBegin (float x, float y, float width, float height) {
    if (width <= 0 || height <= 0) return false;
    Rectangle tableBounds = Rectangle.tmp;
    tableBounds.x = x;
    tableBounds.y = y;
    tableBounds.width = width;
    tableBounds.height = height;
    Stage stage = this.stage;
    Rectangle scissorBounds = Pools.obtain(Rectangle.class);
    stage.calculateScissors(tableBounds, scissorBounds);
    if (ScissorStack.pushScissors(scissorBounds)) return true;
    Pools.free(scissorBounds);
    return false;
  }
View Full Code Here

   * avoids drawing children completely outside the {@link #setCullingArea(Rectangle) culling area}, if set. */
  protected void drawChildren (Batch batch, float parentAlpha) {
    parentAlpha *= this.color.a;
    SnapshotArray<Actor> children = this.children;
    Actor[] actors = children.begin();
    Rectangle cullingArea = this.cullingArea;
    if (cullingArea != null) {
      // Draw children only if inside culling area.
      float cullLeft = cullingArea.x;
      float cullRight = cullLeft + cullingArea.width;
      float cullBottom = cullingArea.y;
View Full Code Here

    BoundingBox bounds = this.bounds;

    bounds.inf();
    for (int i = 0, n = active.length; i < n; i++)
      if (active[i]) {
        Rectangle r = particles[i].getBoundingRectangle();
        bounds.ext(r.x, r.y, 0);
        bounds.ext(r.x + r.width, r.y + r.height, 0);
      }

    return bounds;
View Full Code Here

    int borderPixels = padding + (duplicateBorder ? 1 : 0);
    borderPixels <<= 1;

    if(image.getWidth() >= pageWidth + borderPixels|| image.getHeight() >= pageHeight + borderPixels) throw new GdxRuntimeException("page size for '" + name + "' to small");

    Rectangle rect = new Rectangle(0, 0, image.getWidth() + borderPixels, image.getHeight() + borderPixels);
    Node node = insert(currPage.root, rect);

    if (node == null) {
      newPage();
      return pack(name, image);
    }

    node.leaveName = name;
    rect = new Rectangle(node.rect);
    rect.width -= borderPixels;
    rect.height -= borderPixels;
    borderPixels >>= 1;
    rect.x += borderPixels;
    rect.y += borderPixels;
View Full Code Here

   * @param name the name of the image
   * @return the rectangle for the image in the page it's stored in or null
   */
  public synchronized Rectangle getRect(String name) {
    for(Page page: pages) {
      Rectangle rect = page.rects.get(name);
      if(rect != null) return rect;
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.math.Rectangle

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.