2 * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public License
6 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite;
12 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
13 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.ForwardOrientedTexture;
14 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas.TextCanvas;
15 import eu.svjatoslav.sixth.e3d.renderer.raster.texture.Texture;
17 public class ForwardOrientedTextBlock extends ForwardOrientedTexture {
19 public ForwardOrientedTextBlock(final Point3D point, final double scale,
20 final int maxUpscaleFactor, final String text,
21 final eu.svjatoslav.sixth.e3d.renderer.raster.Color textColor) {
22 super(point, scale, getTexture(text, maxUpscaleFactor, textColor));
26 public static Texture getTexture(final String text,
27 final int maxUpscaleFactor,
28 final eu.svjatoslav.sixth.e3d.renderer.raster.Color textColor) {
30 final Texture texture = new Texture(text.length()
31 * TextCanvas.FONT_CHAR_WIDTH, TextCanvas.FONT_CHAR_HEIGHT,
34 // texture.graphics.setColor(Color.BLUE);
35 // texture.graphics.fillRect(0, 0, texture.primaryBitmap.width,
36 // texture.primaryBitmap.width);
38 texture.graphics.setFont(TextCanvas.FONT);
39 texture.graphics.setColor(textColor.toAwtColor());
41 for (int c = 0; c < text.length(); c++)
42 texture.graphics.drawChars(new char[]{text.charAt(c),}, 0, 1,
43 (c * TextCanvas.FONT_CHAR_WIDTH) - 0,
44 (0 * TextCanvas.FONT_CHAR_HEIGHT) + 11);