congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
NinePatch.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.badlogic.gdx.graphics.g2d.NinePatch
constructor

Best Java code snippets using com.badlogic.gdx.graphics.g2d.NinePatch.<init> (Showing top 20 results out of 315)

origin: libgdx/libgdx

static NinePatch newDegenerateNinePatch () {
  final int patchSize = 8;
  final int pixmapSize = patchSize * 3;
  TextureRegion tr = newPatchPix(patchSize, pixmapSize);
  return new NinePatch(tr);
}
origin: libgdx/libgdx

static NinePatch newULQuadPatch () {
  final int patchSize = 8;
  final int pixmapSize = patchSize * 2;
  TextureRegion tr = newPatchPix(patchSize, pixmapSize);
  return new NinePatch(tr, patchSize, 0, patchSize, 0);
}
origin: libgdx/libgdx

static NinePatch newNinePatch () {
  final int patchSize = 8;
  final int pixmapSize = patchSize * 3;
  TextureRegion tr = newPatchPix(patchSize, pixmapSize);
  return new NinePatch(tr, patchSize, patchSize, patchSize, patchSize);
}
origin: libgdx/libgdx

/** Returns the first region found with the specified name as a {@link NinePatch}. The region must have been packed with
 * ninepatch splits. This method uses string comparison to find the region and constructs a new ninepatch, so the result should
 * be cached rather than calling this method multiple times.
 * @return The ninepatch, or null. */
public NinePatch createPatch (String name) {
  for (int i = 0, n = regions.size; i < n; i++) {
    AtlasRegion region = regions.get(i);
    if (region.name.equals(name)) {
      int[] splits = region.splits;
      if (splits == null) throw new IllegalArgumentException("Region does not have ninepatch splits: " + name);
      NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
      if (region.pads != null) patch.setPadding(region.pads[0], region.pads[1], region.pads[2], region.pads[3]);
      return patch;
    }
  }
  return null;
}
origin: libgdx/libgdx

  /** Creates a new drawable that renders the same as this drawable tinted the specified color. */
  public NinePatchDrawable tint (Color tint) {
    NinePatchDrawable drawable = new NinePatchDrawable(this);
    drawable.patch = new NinePatch(drawable.getPatch(), tint);
    return drawable;
  }
}
origin: libgdx/libgdx

/** Returns the first region found with the specified name as a {@link NinePatch}. The region must have been packed with
 * ninepatch splits. This method uses string comparison to find the region and constructs a new ninepatch, so the result should
 * be cached rather than calling this method multiple times.
 * @return The ninepatch, or null. */
public NinePatch createPatch (String name) {
  for (int i = 0, n = regions.size; i < n; i++) {
    AtlasRegion region = regions.get(i);
    if (region.name.equals(name)) {
      int[] splits = region.splits;
      if (splits == null) throw new IllegalArgumentException("Region does not have ninepatch splits: " + name);
      NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
      if (region.pads != null) patch.setPadding(region.pads[0], region.pads[1], region.pads[2], region.pads[3]);
      return patch;
    }
  }
  return null;
}
origin: libgdx/libgdx

  /** Creates a new drawable that renders the same as this drawable tinted the specified color. */
  public NinePatchDrawable tint (Color tint) {
    NinePatchDrawable drawable = new NinePatchDrawable(this);
    drawable.patch = new NinePatch(drawable.getPatch(), tint);
    return drawable;
  }
}
origin: libgdx/libgdx

/** Returns a registered ninepatch. If no ninepatch is found but a region exists with the name, a ninepatch is created from the
 * region and stored in the skin. If the region is an {@link AtlasRegion} then the {@link AtlasRegion#splits} are used,
 * otherwise the ninepatch will have the region as the center patch. */
public NinePatch getPatch (String name) {
  NinePatch patch = optional(name, NinePatch.class);
  if (patch != null) return patch;
  try {
    TextureRegion region = getRegion(name);
    if (region instanceof AtlasRegion) {
      int[] splits = ((AtlasRegion)region).splits;
      if (splits != null) {
        patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
        int[] pads = ((AtlasRegion)region).pads;
        if (pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
      }
    }
    if (patch == null) patch = new NinePatch(region);
    add(name, patch, NinePatch.class);
    return patch;
  } catch (GdxRuntimeException ex) {
    throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name);
  }
}
origin: libgdx/libgdx

/** Returns a registered ninepatch. If no ninepatch is found but a region exists with the name, a ninepatch is created from the
 * region and stored in the skin. If the region is an {@link AtlasRegion} then the {@link AtlasRegion#splits} are used,
 * otherwise the ninepatch will have the region as the center patch. */
public NinePatch getPatch (String name) {
  NinePatch patch = optional(name, NinePatch.class);
  if (patch != null) return patch;
  try {
    TextureRegion region = getRegion(name);
    if (region instanceof AtlasRegion) {
      int[] splits = ((AtlasRegion)region).splits;
      if (splits != null) {
        patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
        int[] pads = ((AtlasRegion)region).pads;
        if (pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
      }
    }
    if (patch == null) patch = new NinePatch(region);
    add(name, patch, NinePatch.class);
    return patch;
  } catch (GdxRuntimeException ex) {
    throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name);
  }
}
origin: libgdx/libgdx

static NinePatch newMidlessPatch () {
  final int patchSize = 8;
  final int fullPatchHeight = patchSize * 2;
  final int fullPatchWidth = patchSize * 3;
  final int pixmapDim = MathUtils.nextPowerOfTwo(Math.max(fullPatchWidth, fullPatchHeight));
  Pixmap testPatch = new Pixmap(pixmapDim, pixmapDim, Pixmap.Format.RGBA8888);
  testPatch.setColor(1, 1, 1, 0);
  testPatch.fill();
  for (int x = 0; x < fullPatchWidth; x += patchSize) {
    for (int y = 0; y < fullPatchHeight; y += patchSize) {
      testPatch.setColor(x / (float)fullPatchWidth, y / (float)fullPatchHeight, 1.0f, 1.0f);
      testPatch.fillRectangle(x, y, patchSize, patchSize);
    }
  }
  return new NinePatch(new TextureRegion(new Texture(testPatch), fullPatchWidth, fullPatchHeight), patchSize, patchSize,
    patchSize, patchSize);
}
origin: Var3D/var3dframe

/**
 * 获取九宫图
 */
public NinePatch getNinePatch(String name, int left, int right, int top,
               int bottom) {
  return new NinePatch(getTextureRegion(name), left, right, top, bottom);
}
origin: udacity/ud406

  public PlatformAssets(TextureAtlas atlas) {
    AtlasRegion region = atlas.findRegion(Constants.PLATFORM_SPRITE);
    int edge = Constants.PLATFORM_EDGE;
    platformNinePatch = new NinePatch(region, edge, edge, edge, edge);
  }
}
origin: com.badlogicgames.gdx/gdx

/** Returns the first region found with the specified name as a {@link NinePatch}. The region must have been packed with
 * ninepatch splits. This method uses string comparison to find the region and constructs a new ninepatch, so the result should
 * be cached rather than calling this method multiple times.
 * @return The ninepatch, or null. */
public NinePatch createPatch (String name) {
  for (int i = 0, n = regions.size; i < n; i++) {
    AtlasRegion region = regions.get(i);
    if (region.name.equals(name)) {
      int[] splits = region.splits;
      if (splits == null) throw new IllegalArgumentException("Region does not have ninepatch splits: " + name);
      NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
      if (region.pads != null) patch.setPadding(region.pads[0], region.pads[1], region.pads[2], region.pads[3]);
      return patch;
    }
  }
  return null;
}
origin: com.badlogicgames.gdx/gdx

  /** Creates a new drawable that renders the same as this drawable tinted the specified color. */
  public NinePatchDrawable tint (Color tint) {
    NinePatchDrawable drawable = new NinePatchDrawable(this);
    drawable.patch = new NinePatch(drawable.getPatch(), tint);
    return drawable;
  }
}
origin: crashinvaders/gdx-texture-packer-gui

private void updatePreviewNinePatch() {
  int[] patches = model.readPatchValues();
  NinePatch ninePatch = new NinePatch(model.texture, patches[0], patches[1], patches[2], patches[3]);
  previewImage.setDrawable(new NinePatchDrawable(ninePatch));
}
origin: udacity/ud406

@Override
public void create() {
  batch = new SpriteBatch();
  viewport = new FitViewport(WORLD_SIZE, WORLD_SIZE);
  // TODO: Load the platform texture (Look for the file in android/assets)
  platformTexture = new Texture("platform.png");
  // TODO: Initialize the NinePatch using the texture and the EDGE constant
  platformNinePatch = new NinePatch(platformTexture, EDGE, EDGE, EDGE, EDGE);
}
origin: Var3D/var3dframe

public Drawable getRectLineDrawable(Color color, Color out, int w, int h) {
  Pixmap pixmap = new Pixmap(w, h, Format.RGBA8888);
  pixmap.setColor(color);
  pixmap.fill();
  pixmap.setColor(out);
  pixmap.drawRectangle(0, 0, w, h);
  Texture colorPoint = new Texture(pixmap);
  colorPoint.setFilter(filter, filter);
  pixmap.dispose();
  NinePatchDrawable nine = new NinePatchDrawable(new NinePatch(colorPoint, 2, 2, 2, 2));
  return nine;
}
origin: peakgames/libgdx-stagebuilder

  public static NinePatchDrawable createNinePatchDrawableFromAtlas(ResolutionHelper resolutionHelper, 
                                   String imageName, TextureAtlas textureAtlas,
                                   int patchOffsetLeft, int patchOffsetRight,
                                   int patchOffsetTop, int patchOffsetBottom) {
    NinePatchDrawable ninePatchDrawable = new NinePatchDrawable();
    TextureRegion region = textureAtlas.findRegion(imageName);
    NinePatch patch = new NinePatch(region, patchOffsetLeft, patchOffsetRight, patchOffsetTop, patchOffsetBottom);
    patch.scale(resolutionHelper.getSizeMultiplier(), resolutionHelper.getSizeMultiplier());
    ninePatchDrawable.setPatch(patch);
    return ninePatchDrawable;
  }
}
origin: dingjibang/GDX-RPG

private static NinePatch get9(String fname, int wpad, int hpad, int woff, int hoff, int left, int right, int top, int bottom) {
  final Texture t = new Texture(Gdx.files.internal(fname));
  t.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
  final int width = t.getWidth() - wpad;
  final int height = t.getHeight() - hpad;
  return new NinePatch(new TextureRegion(t, woff, hoff, width, height), left, right, top, bottom);
}
origin: peakgames/libgdx-stagebuilder

private void prepareNinepatch(AssetsInterface assets, float sizeMult) {
  TextureAtlas atlas = assets.getTextureAtlas(this.atlasName);
  TextureAtlas.AtlasRegion ninePatchTexture = atlas.findRegion(progressImageFrame);
  NinePatch patch = new NinePatch(ninePatchTexture, this.ninePatchLeft, this.ninePatchRight, 0, 0);
  NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(patch);
  ninePatchDrawable.setMinWidth(ninePatchDrawable.getMinWidth() * sizeMult);
  ninePatchDrawable.setMinHeight(ninePatchDrawable.getMinHeight() * sizeMult);
  TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle(ninePatchDrawable, ninePatchDrawable, ninePatchDrawable, assets.getFont(this.fontName));
  this.progressBarNinePatch = new TextButton("", textButtonStyle);
  this.progressBarNinePatch.setWidth(ninePatchTexture.originalWidth);
  this.progressBarOriginalWidth = ninePatchTexture.originalWidth;
  this.progressBarNinePatch.setX(this.progressImagePaddingLeft);
}
com.badlogic.gdx.graphics.g2dNinePatch<init>

Javadoc

Construct a degenerate "nine" patch with only a center component.

Popular methods of NinePatch

  • draw
  • setColor
    Copy given color. The color will be blended with the batch color, then combined with the texture col
  • getBottomHeight
  • getRightWidth
  • getTotalHeight
  • getTotalWidth
  • add
  • getLeftWidth
  • getPadBottom
    Returns the bottom padding if set, else returns #getBottomHeight().
  • getPadLeft
    Returns the left padding if set, else returns #getLeftWidth().
  • getPadRight
    Returns the right padding if set, else returns #getRightWidth().
  • getPadTop
    Returns the top padding if set, else returns #getTopHeight().
  • getPadRight,
  • getPadTop,
  • getTexture,
  • getTopHeight,
  • load,
  • prepareVertices,
  • set,
  • setPadding,
  • getColor

Popular in Java

  • Parsing JSON documents to java classes using gson
  • onCreateOptionsMenu (Activity)
  • getApplicationContext (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Table (org.hibernate.mapping)
    A relational table
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now