2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite;
7 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
8 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.ForwardOrientedTexture;
9 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas.TextCanvas;
10 import eu.svjatoslav.sixth.e3d.renderer.raster.texture.Texture;
12 public class ForwardOrientedTextBlock extends ForwardOrientedTexture {
14 public ForwardOrientedTextBlock(final Point3D point, final double scale,
15 final int maxUpscaleFactor, final String text,
16 final eu.svjatoslav.sixth.e3d.renderer.raster.Color textColor) {
17 super(point, scale, getTexture(text, maxUpscaleFactor, textColor));
21 public static Texture getTexture(final String text,
22 final int maxUpscaleFactor,
23 final eu.svjatoslav.sixth.e3d.renderer.raster.Color textColor) {
25 final Texture texture = new Texture(text.length()
26 * TextCanvas.FONT_CHAR_WIDTH_TEXTURE_PIXELS, TextCanvas.FONT_CHAR_HEIGHT_TEXTURE_PIXELS,
29 // texture.graphics.setColor(Color.BLUE);
30 // texture.graphics.fillRect(0, 0, texture.primaryBitmap.width,
31 // texture.primaryBitmap.width);
33 texture.graphics.setFont(TextCanvas.FONT);
34 texture.graphics.setColor(textColor.toAwtColor());
36 for (int c = 0; c < text.length(); c++)
37 texture.graphics.drawChars(new char[]{text.charAt(c),}, 0, 1,
38 (c * TextCanvas.FONT_CHAR_WIDTH_TEXTURE_PIXELS),
39 (int) (TextCanvas.FONT_CHAR_HEIGHT_TEXTURE_PIXELS / 1.45));