本文整理汇总了Java中org.newdawn.slick.font.effects.Effect类的典型用法代码示例。如果您正苦于以下问题:Java Effect类的具体用法?Java Effect怎么用?Java Effect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Effect类属于org.newdawn.slick.font.effects包,在下文中一共展示了Effect类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderGlyph
import org.newdawn.slick.font.effects.Effect; //导入依赖的package包/类
/**
* Loads a single glyph to the backing texture, if it fits.
*
* @param glyph The glyph to be rendered
* @param width The expected width of the glyph
* @param height The expected height of the glyph
* @throws SlickException if the glyph could not be rendered.
*/
private void renderGlyph(Glyph glyph, int width, int height) throws SlickException {
// 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);
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.
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);
}
GL.glTexSubImage2D(SGL.GL_TEXTURE_2D, 0, pageX, pageY, width, height, SGL.GL_BGRA, SGL.GL_UNSIGNED_BYTE,
scratchByteBuffer);
scratchIntBuffer.clear();
glyph.setImage(pageImage.getSubImage(pageX, pageY, width, height));
}
示例2: addFont
import org.newdawn.slick.font.effects.Effect; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void addFont(String key, String file, int size, boolean bold, boolean italic, Effect [] effects) throws SlickException {
try {
AssetManager.ASSETS_TO_LOAD++;
UnicodeFont uni = new UnicodeFont(file, size, bold, italic);
uni.addAsciiGlyphs();
uni.addGlyphs(400, 600);
uni.getEffects().add(new ColorEffect(Color.WHITE));
uni.getEffects().addAll(Arrays.asList(effects));
uni.loadGlyphs();
if((fonts != null) && (uni != null)) {
fonts.put(key, uni);
AssetManager.ASSETS_LOADED++;
System.out.println(String.format("Font Loaded: %s", key));
}
} catch(Exception ex) {
ex.printStackTrace();
System.out.printf("ERROR: Font \"%s\" could not be loaded!\n", file);
}
}
示例3: renderGlyph
import org.newdawn.slick.font.effects.Effect; //导入依赖的package包/类
/**
* Loads a single glyph to the backing texture, if it fits.
*
* @param glyph The glyph to be rendered
* @param width The expected width of the glyph
* @param height The expected height of the glyph
* @throws SlickException if the glyph could not be rendered.
*/
private void renderGlyph(Glyph glyph, int width, int height) throws SlickException {
// 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);
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.
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();
glyph.setImage(pageImage.getSubImage(pageX, pageY, width, height));
}
示例4: renderGlyph
import org.newdawn.slick.font.effects.Effect; //导入依赖的package包/类
/**
* Loads a single glyph to the backing texture, if it fits.
*
* @param glyph The glyph to be rendered
* @param width The expected width of the glyph
* @param height The expected height of the glyph
* @throws SlickException if the glyph could not be rendered.
*/
private void renderGlyph(@Nonnull 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);
scratchGraphics.setColor(java.awt.Color.white);
for (Effect effect : unicodeFont.getEffects()) (effect).draw(scratchImage, scratchGraphics, unicodeFont, glyph);
glyph.setShape(null); // The shape will never be needed again.
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);
}
GL.glTexSubImage2D(SGL.GL_TEXTURE_2D, 0, pageX, pageY, width, height, SGL.GL_BGRA, SGL.GL_UNSIGNED_BYTE,
scratchByteBuffer);
scratchIntBuffer.clear();
glyph.setImage(pageImage.getSubImage(pageX, pageY, width, height));
}
示例5: loadFont
import org.newdawn.slick.font.effects.Effect; //导入依赖的package包/类
/**
* Loads a Unicode font and its ASCII glyphs.
* @param font the font to load
* @param effect the font effect
* @throws SlickException if the glyphs could not be loaded
*/
@SuppressWarnings("unchecked")
private static void loadFont(UnicodeFont font, Effect effect) throws SlickException {
font.addAsciiGlyphs();
font.getEffects().add(effect);
font.loadGlyphs();
}
示例6: save
import org.newdawn.slick.font.effects.Effect; //导入依赖的package包/类
/**
* Saves the settings to a file.
*
* @param file The file we're saving to
* @throws IOException if the file could not be saved.
* @throws SlickException if effect from effects is not ConfigurableEffect
*/
public void save(@Nonnull File file) throws SlickException, IOException {
try(
final FileOutputStream fileOutputStream = new FileOutputStream(file);
final PrintStream out = new PrintStream(fileOutputStream)
) {
out.println("font.size=" + fontSize);
out.println("font.bold=" + bold);
out.println("font.italic=" + italic);
out.println();
out.println("pad.top=" + paddingTop);
out.println("pad.right=" + paddingRight);
out.println("pad.bottom=" + paddingBottom);
out.println("pad.left=" + paddingLeft);
out.println("pad.advance.x=" + paddingAdvanceX);
out.println("pad.advance.y=" + paddingAdvanceY);
out.println();
out.println("glyph.page.width=" + glyphPageWidth);
out.println("glyph.page.height=" + glyphPageHeight);
out.println();
for (Iterator<Effect> iter = effects.iterator(); iter.hasNext();) {
if(!(iter.next() instanceof ConfigurableEffect)) {
throw new SlickException("Effect is not org.newdawn.slick.font.effects.ConfigurableEffect");
}
ConfigurableEffect effect = (ConfigurableEffect) iter.next();
out.println("effect.class=" + effect.getClass().getName());
for (Value value : effect.getValues()) {
out.println("effect." + value.getName() + "=" + value.getString());
}
out.println();
}
}
}
示例7: loadFont
import org.newdawn.slick.font.effects.Effect; //导入依赖的package包/类
/**
* Loads a Unicode font and its ASCII glyphs.
* @param font the font to load
* @param effect the font effect
* @param backup the backup font
* @throws SlickException if the glyphs could not be loaded
*/
@SuppressWarnings("unchecked")
private static void loadFont(UnicodeFont font, Effect effect, UnicodeFont backup) throws SlickException {
font.addBackupFont(backup);
font.addAsciiGlyphs();
font.getEffects().add(effect);
font.loadGlyphs();
}
示例8: getEffects
import org.newdawn.slick.font.effects.Effect; //导入依赖的package包/类
/**
* Returns a list of {@link org.newdawn.slick.font.effects.Effect}s that will be applied
* to the glyphs.
*
* @return The list of effects to be applied to the font
*/
@Nonnull
public List<Effect> getEffects () {
return effects;
}
示例9: getEffects
import org.newdawn.slick.font.effects.Effect; //导入依赖的package包/类
/**
* @see UnicodeFont#getEffects()
*
* @return The list of effects applied to the text
*/
@Nonnull
public List<Effect> getEffects() {
return effects;
}