Search in sources :

Example 1 with RectF

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

the class BitmapText method updateVertices.

protected synchronized void updateVertices() {
    width = 0;
    height = 0;
    if (text == null) {
        text = "";
    }
    quads = Quad.createSet(text.length());
    realLength = 0;
    int length = text.length();
    for (int i = 0; i < length; i++) {
        RectF rect = font.get(text.charAt(i));
        if (rect == null) {
            rect = null;
        }
        float w = font.width(rect);
        float h = font.height(rect);
        vertices[0] = width;
        vertices[1] = 0;
        vertices[2] = rect.left;
        vertices[3] = rect.top;
        vertices[4] = width + w;
        vertices[5] = 0;
        vertices[6] = rect.right;
        vertices[7] = rect.top;
        vertices[8] = width + w;
        vertices[9] = h;
        vertices[10] = rect.right;
        vertices[11] = rect.bottom;
        vertices[12] = width;
        vertices[13] = h;
        vertices[14] = rect.left;
        vertices[15] = rect.bottom;
        quads.put(vertices);
        realLength++;
        width += w + font.tracking;
        if (h > height) {
            height = h;
        }
    }
    if (length > 0) {
        width -= font.tracking;
    }
    dirty = false;
}
Also used : RectF(com.watabou.utils.RectF)

Example 2 with RectF

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

the class BitmapText method measure.

public synchronized void measure() {
    width = 0;
    height = 0;
    if (text == null) {
        text = "";
    }
    int length = text.length();
    for (int i = 0; i < length; i++) {
        RectF rect = font.get(text.charAt(i));
        float w = font.width(rect);
        float h = font.height(rect);
        width += w + font.tracking;
        if (h > height) {
            height = h;
        }
    }
    if (length > 0) {
        width -= font.tracking;
    }
}
Also used : RectF(com.watabou.utils.RectF)

Example 3 with RectF

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

the class BitmapTextMultiline method updateVertices.

@Override
protected void updateVertices() {
    if (text == null) {
        text = "";
    }
    quads = Quad.createSet(text.length());
    realLength = 0;
    // This object controls lines breaking
    SymbolWriter writer = new SymbolWriter();
    // Word size
    PointF metrics = new PointF();
    String[] paragraphs = PARAGRAPH.split(text);
    // Current character (used in masking)
    int pos = 0;
    for (int i = 0; i < paragraphs.length; i++) {
        String[] words = WORD.split(paragraphs[i]);
        for (int j = 0; j < words.length; j++) {
            String word = words[j];
            if (word.length() == 0) {
                // several spaces coming along
                continue;
            }
            getWordMetrics(word, metrics);
            writer.addSymbol(metrics.x, metrics.y);
            int length = word.length();
            // Position in pixels relative to the beginning of the word
            float shift = 0;
            for (int k = 0; k < length; k++) {
                RectF rect = font.get(word.charAt(k));
                float w = font.width(rect);
                float h = font.height(rect);
                if (mask == null || mask[pos]) {
                    vertices[0] = writer.x + shift;
                    vertices[1] = writer.y;
                    vertices[2] = rect.left;
                    vertices[3] = rect.top;
                    vertices[4] = writer.x + shift + w;
                    vertices[5] = writer.y;
                    vertices[6] = rect.right;
                    vertices[7] = rect.top;
                    vertices[8] = writer.x + shift + w;
                    vertices[9] = writer.y + h;
                    vertices[10] = rect.right;
                    vertices[11] = rect.bottom;
                    vertices[12] = writer.x + shift;
                    vertices[13] = writer.y + h;
                    vertices[14] = rect.left;
                    vertices[15] = rect.bottom;
                    quads.put(vertices);
                    realLength++;
                }
                shift += w + font.tracking;
                pos++;
            }
            writer.addSpace(spaceSize);
        }
        writer.newLine(0, font.lineHeight);
    }
    nLines = writer.nLines();
    dirty = false;
}
Also used : RectF(com.watabou.utils.RectF) PointF(com.watabou.utils.PointF)

Example 4 with RectF

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

the class BitmaskEmitter method emit.

@Override
protected void emit(int index) {
    RectF frame = ((Image) target).frame();
    float ofsX = frame.left * mapW;
    float ofsY = frame.top * mapH;
    float x, y;
    do {
        x = Random.Float(frame.width()) * mapW;
        y = Random.Float(frame.height()) * mapH;
    } while ((map.getPixel((int) (x + ofsX), (int) (y + ofsY)) & 0x000000FF) == 0);
    factory.emit(this, index, target.x + x * target.scale.x, target.y + y * target.scale.y);
}
Also used : RectF(com.watabou.utils.RectF) Image(com.watabou.noosa.Image)

Example 5 with RectF

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

the class Image method copy.

public void copy(Image other) {
    texture = other.texture;
    frame = new RectF(other.frame);
    width = other.width;
    height = other.height;
    updateFrame();
    updateVertices();
}
Also used : RectF(com.watabou.utils.RectF)

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