Search in sources :

Example 6 with RectF

use of com.watabou.utils.RectF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class BitmapTextMultiline method getWordMetrics.

private void getWordMetrics(String word, PointF metrics) {
    float w = 0;
    float h = 0;
    int length = word.length();
    for (int i = 0; i < length; i++) {
        RectF rect = font.get(word.charAt(i));
        w += font.width(rect) + (w > 0 ? font.tracking : 0);
        h = Math.max(h, font.height(rect));
    }
    metrics.set(w, h);
}
Also used : RectF(com.watabou.utils.RectF)

Example 7 with RectF

use of com.watabou.utils.RectF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Image method texture.

public void texture(Object tx) {
    texture = tx instanceof SmartTexture ? (SmartTexture) tx : TextureCache.get(tx);
    frame(new RectF(0, 0, 1, 1));
}
Also used : RectF(com.watabou.utils.RectF) SmartTexture(com.watabou.gltextures.SmartTexture)

Example 8 with RectF

use of com.watabou.utils.RectF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class SkinnedBlock method frame.

@Override
public void frame(RectF frame) {
    scaleX = 1;
    scaleY = 1;
    offsetX = 0;
    offsetY = 0;
    super.frame(new RectF(0, 0, 1, 1));
}
Also used : RectF(com.watabou.utils.RectF)

Example 9 with RectF

use of com.watabou.utils.RectF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Tilemap method updateVertices.

protected void updateVertices() {
    moveToUpdating();
    float x1, y1, x2, y2;
    int pos;
    RectF uv;
    y1 = cellH * updating.top;
    y2 = y1 + cellH;
    for (int i = updating.top; i < updating.bottom; i++) {
        x1 = cellW * updating.left;
        x2 = x1 + cellW;
        pos = i * mapWidth + updating.left;
        for (int j = updating.left; j < updating.right; j++) {
            if (topLeftUpdating == -1)
                topLeftUpdating = pos;
            bottomRightUpdating = pos + 1;
            quads.position(pos * 16);
            uv = tileset.get(data[pos]);
            if (needsRender(pos) && uv != null) {
                vertices[0] = x1;
                vertices[1] = y1;
                vertices[2] = uv.left;
                vertices[3] = uv.top;
                vertices[4] = x2;
                vertices[5] = y1;
                vertices[6] = uv.right;
                vertices[7] = uv.top;
                vertices[8] = x2;
                vertices[9] = y2;
                vertices[10] = uv.right;
                vertices[11] = uv.bottom;
                vertices[12] = x1;
                vertices[13] = y2;
                vertices[14] = uv.left;
                vertices[15] = uv.bottom;
            } else {
                // If we don't need to draw this tile simply set the quad to size 0 at 0, 0.
                // This does result in the quad being drawn, but we are skipping all
                // pixel-filling. This is better than fully skipping rendering as we
                // don't need to manage a buffer of drawable tiles with insertions/deletions.
                Arrays.fill(vertices, 0);
            }
            quads.put(vertices);
            pos++;
            x1 = x2;
            x2 += cellW;
        }
        y1 = y2;
        y2 += cellH;
    }
}
Also used : RectF(com.watabou.utils.RectF)

Example 10 with RectF

use of com.watabou.utils.RectF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class HeroSprite method avatar.

public static Image avatar(HeroClass cl, int armorTier) {
    RectF patch = tiers().get(armorTier);
    Image avatar = new Image(cl.spritesheet());
    RectF frame = avatar.texture.uvRect(1, 0, FRAME_WIDTH, FRAME_HEIGHT);
    frame.shift(patch.left, patch.top);
    avatar.frame(frame);
    return avatar;
}
Also used : RectF(com.watabou.utils.RectF) Image(com.watabou.noosa.Image)

Aggregations

RectF (com.watabou.utils.RectF)12 Image (com.watabou.noosa.Image)3 SmartTexture (com.watabou.gltextures.SmartTexture)1 PointF (com.watabou.utils.PointF)1