Java 类com.badlogic.gdx.tools.hiero.unicodefont.effects.Effect 实例源码

项目:libgdxcn    文件:GlyphPage.java   
/** Loads a single glyph to the backing texture, if it fits. */
private void renderGlyph (Glyph glyph, int width, int height) {
    // Draw the glyph to the scratch image using Java2D.
    scratchGraphics.setComposite(AlphaComposite.Clear);
    scratchGraphics.fillRect(0, 0, MAX_GLYPH_SIZE, MAX_GLYPH_SIZE);
    scratchGraphics.setComposite(AlphaComposite.SrcOver);
    if (unicodeFont.getNativeRendering()) {
        for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();) {
            Effect effect = (Effect)iter.next();
            if (effect instanceof ColorEffect) scratchGraphics.setColor(((ColorEffect)effect).getColor());
        }
        scratchGraphics.setColor(java.awt.Color.white);
        scratchGraphics.setFont(unicodeFont.getFont());
        scratchGraphics.drawString("" + (char)glyph.getCodePoint(), 0, unicodeFont.getAscent());
    } else {
        scratchGraphics.setColor(java.awt.Color.white);
        for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();)
            ((Effect)iter.next()).draw(scratchImage, scratchGraphics, unicodeFont, glyph);
        glyph.setShape(null); // The shape will never be needed again.
    }

    width = Math.min(width, texture.getWidth());
    height = Math.min(height, texture.getHeight());

    WritableRaster raster = scratchImage.getRaster();
    int[] row = new int[width];
    for (int y = 0; y < height; y++) {
        raster.getDataElements(0, y, width, 1, row);
        scratchIntBuffer.put(row);
    }
    GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, pageX, pageY, width, height, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE,
        scratchByteBuffer);
    scratchIntBuffer.clear();

    float u = pageX / (float)texture.getWidth();
    float v = pageY / (float)texture.getHeight();
    float u2 = (pageX + width) / (float)texture.getWidth();
    float v2 = (pageY + height) / (float)texture.getHeight();
    glyph.setTexture(texture, u, v, u2, v2);
}
项目:GdxStudio    文件:GlyphPage.java   
/** Loads a single glyph to the backing texture, if it fits. */
private void renderGlyph (Glyph glyph, int width, int height) {
    // Draw the glyph to the scratch image using Java2D.
    scratchGraphics.setComposite(AlphaComposite.Clear);
    scratchGraphics.fillRect(0, 0, MAX_GLYPH_SIZE, MAX_GLYPH_SIZE);
    scratchGraphics.setComposite(AlphaComposite.SrcOver);
    if (unicodeFont.getNativeRendering()) {
        for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();) {
            Effect effect = (Effect)iter.next();
            if (effect instanceof ColorEffect) scratchGraphics.setColor(((ColorEffect)effect).getColor());
        }
        scratchGraphics.setColor(java.awt.Color.white);
        scratchGraphics.setFont(unicodeFont.getFont());
        scratchGraphics.drawString("" + (char)glyph.getCodePoint(), 0, unicodeFont.getAscent());
    } else {
        scratchGraphics.setColor(java.awt.Color.white);
        for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();)
            ((Effect)iter.next()).draw(scratchImage, scratchGraphics, unicodeFont, glyph);
        glyph.setShape(null); // The shape will never be needed again.
    }

    width = Math.min(width, texture.getWidth());
    height = Math.min(height, texture.getHeight());

    WritableRaster raster = scratchImage.getRaster();
    int[] row = new int[width];
    for (int y = 0; y < height; y++) {
        raster.getDataElements(0, y, width, 1, row);
        scratchIntBuffer.put(row);
    }
    GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, pageX, pageY, width, height, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE,
        scratchByteBuffer);
    scratchIntBuffer.clear();

    float u = pageX / (float)texture.getWidth();
    float v = pageY / (float)texture.getHeight();
    float u2 = (pageX + width) / (float)texture.getWidth();
    float v2 = (pageY + height) / (float)texture.getHeight();
    glyph.setTexture(texture, u, v, u2, v2);
}
项目:touhou-java    文件:GlyphPage.java   
/** Loads a single glyph to the backing texture, if it fits. */
private void renderGlyph (Glyph glyph, int width, int height) {
    // Draw the glyph to the scratch image using Java2D.
    scratchGraphics.setComposite(AlphaComposite.Clear);
    scratchGraphics.fillRect(0, 0, MAX_GLYPH_SIZE, MAX_GLYPH_SIZE);
    scratchGraphics.setComposite(AlphaComposite.SrcOver);
    if (unicodeFont.getNativeRendering()) {
        for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();) {
            Effect effect = (Effect)iter.next();
            if (effect instanceof ColorEffect) scratchGraphics.setColor(((ColorEffect)effect).getColor());
        }
        scratchGraphics.setColor(java.awt.Color.white);
        scratchGraphics.setFont(unicodeFont.getFont());
        scratchGraphics.drawString("" + (char)glyph.getCodePoint(), 0, unicodeFont.getAscent());
    } else {
        scratchGraphics.setColor(java.awt.Color.white);
        for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();)
            ((Effect)iter.next()).draw(scratchImage, scratchGraphics, unicodeFont, glyph);
        glyph.setShape(null); // The shape will never be needed again.
    }

    width = Math.min(width, texture.getWidth());
    height = Math.min(height, texture.getHeight());

    WritableRaster raster = scratchImage.getRaster();
    int[] row = new int[width];
    for (int y = 0; y < height; y++) {
        raster.getDataElements(0, y, width, 1, row);
        scratchIntBuffer.put(row);
    }
    GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, pageX, pageY, width, height, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE,
        scratchByteBuffer);
    scratchIntBuffer.clear();

    float u = pageX / (float)texture.getWidth();
    float v = pageY / (float)texture.getHeight();
    float u2 = (pageX + width) / (float)texture.getWidth();
    float v2 = (pageY + height) / (float)texture.getHeight();
    glyph.setTexture(texture, u, v, u2, v2);
}
项目:gdx-skineditor    文件:GlyphPage.java   
/** Loads a single glyph to the backing texture, if it fits. */
private void renderGlyph (Glyph glyph, int width, int height) {

    // Draw the glyph to the scratch image using Java2D.
    scratchGraphics.setComposite(AlphaComposite.Clear);
    scratchGraphics.fillRect(0, 0, MAX_GLYPH_SIZE, MAX_GLYPH_SIZE);
    scratchGraphics.setComposite(AlphaComposite.SrcOver);
    if (unicodeFont.getNativeRendering()) {
        for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();) {
            Effect effect = (Effect)iter.next();
            if (effect instanceof ColorEffect) scratchGraphics.setColor(((ColorEffect)effect).getColor());
        }
        scratchGraphics.setColor(java.awt.Color.white);
        scratchGraphics.setFont(unicodeFont.getFont());
        scratchGraphics.drawString("" + (char)glyph.getCodePoint(), 0, unicodeFont.getAscent());
    } else {
        scratchGraphics.setColor(java.awt.Color.white);
        for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();)
            ((Effect)iter.next()).draw(scratchImage, scratchGraphics, unicodeFont, glyph);
        glyph.setShape(null); // The shape will never be needed again.
    }

    width = Math.min(width, texture.getWidth());
    height = Math.min(height, texture.getHeight());

    WritableRaster raster = scratchImage.getRaster();
    int[] row = new int[width];
    for (int y = 0; y < height; y++) {
        raster.getDataElements(0, y, width, 1, row);
        scratchIntBuffer.put(row);
    }
    GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, pageX, pageY, width, height, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE,
        scratchByteBuffer);
    scratchIntBuffer.clear();

    float u = pageX / (float)texture.getWidth();
    float v = pageY / (float)texture.getHeight();
    float u2 = (pageX + width) / (float)texture.getWidth();
    float v2 = (pageY + height) / (float)texture.getHeight();
    glyph.setTexture(texture, u, v, u2, v2);
}