• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ASCII renderer in pure java with no external dependencies

Java ASCII Render

Maven Central Java CI with Maven Quality Gate Status Lines of Code GitHub

ASCII renderer in pure java with no external dependencies. Java ASCII Render supports graphical primitives/elements, layers, context, canvas.

                               EXPERIMENTAL RESULT                              
                                                                                
    Theme: Teleportation of matter through extremely dense elements             
                                                                                
    Date: 1998-11-19                                                            
    Time: 08:47                                                                 
    Subject: Gordon Freeman                                                     
                                                                                
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    Observation of Einstein-Podo    
    β”‚ 1.00β”Ό****                       *****β”‚    lsky-Rosen Entanglement on S    
    β”‚ 0.75β”Ό   ***                   ***    β”‚    upraquantum Structures by In    
    β”‚ 0.50β”Ό     **                 **      β”‚    duction Through Nonlinear Tr    
    β”‚ 0.25β”Ό       **             **        β”‚    ansuranic Crystal of Extreme    
    β”‚ 0.00β”Ό        **           **         β”‚    ly Long Wavelength (ELW) Pul    
    β”‚-0.25β”Ό         ***       ***          β”‚    se from Mode-Locked Source A    
    β”‚-0.50β”Ό           *********            β”‚    rray shows a very promising     
    β”‚-0.75β”Ό               *                β”‚    result.                         
    β”‚-1.00┼───────┼───────┼───────┼───────┼│                                    
    β”‚     0      90      180     270    360β”‚                 *******************
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 CONCLUSION: APPROVE

Download and Install

To download and install Java ASCII Render you currently have the following options.

Maven

Add dependency to com.indvd00m.ascii.render:ascii-render:

	<dependency>
		<groupId>com.indvd00m.ascii.render</groupId>
		<artifactId>ascii-render</artifactId>
		<version>2.2.0</version>
	</dependency>

Plain-old JAR

Download the following JARs and add them to your classpath:

Compatibility

Java ASCII Render requires Java 6 (or higher).

Available graphical elements and usage examples

Rectangle

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(20).height(10);
		builder.element(new Rectangle());
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Dot

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚         *        β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(20).height(10);
		builder.element(new Rectangle());
		builder.element(new Dot());
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Line

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  β”‚
β”‚ ●●               β”‚
β”‚   ●●●            β”‚
β”‚      ●●●         β”‚
β”‚         ●●●      β”‚
β”‚            ●●●   β”‚
β”‚               ●● β”‚
β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(20).height(10);
		builder.element(new Rectangle());
		builder.element(new Line(new Point(2, 2), new Point(17, 7)));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Circle

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       ***        β”‚
β”‚      *   *       β”‚
β”‚     *     *      β”‚
β”‚     *     *      β”‚
β”‚     *     *      β”‚
β”‚      *   *       β”‚
β”‚       ***        β”‚
β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(20).height(10);
		builder.element(new Rectangle());
		builder.element(new Circle(9, 4, 3));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Ellipse

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     *******      β”‚
β”‚   **       **    β”‚
β”‚                  β”‚
β”‚ *             *  β”‚
β”‚                  β”‚
β”‚   **       **    β”‚
β”‚     *******      β”‚
β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(20).height(10);
		builder.element(new Rectangle());
		builder.element(new Ellipse(9, 4, 14, 6));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Label

Single-line string.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚Label with long t…│
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(20).height(10);
		builder.element(new Rectangle());
		builder.element(new Label("Label with long text", 1, 4, 18));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Text

Multiline string.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  β”‚
β”‚                  β”‚
β”‚Lorem Ipsum is simβ”‚
β”‚ply dummy text of β”‚
β”‚the printing and …│
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(20).height(10);
		builder.element(new Rectangle());
		builder.element(new Text("Lorem Ipsum is simply dummy text of the printing and typesetting industry.", 1, 3, 18, 3));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

PseudoText

Antialising option is customizable, enabled by default.

                                                β–ˆβ–ˆ                                                    
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’                                        β–ˆβ–ˆ           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ                         β–ˆβ–ˆ    
 β–ˆβ–ˆ β–‘β–‘β–ˆβ–ˆβ–’                                       β–ˆβ–ˆ               β–ˆβ–ˆ                             β–ˆβ–ˆ    
 β–ˆβ–ˆ   β–‘β–ˆβ–ˆ                                       β–ˆβ–ˆ               β–ˆβ–ˆ                             β–ˆβ–ˆ    
 β–ˆβ–ˆ   β–‘β–ˆβ–ˆ  β–‘β–’β–ˆβ–ˆβ–ˆβ–ˆβ–“β–’   β–‘β–“β–ˆβ–ˆβ–ˆβ–’    β–ˆβ–ˆ    β–ˆβ–ˆ   β–’β–ˆβ–ˆβ–ˆβ–’β–ˆβ–ˆ   β–’β–ˆβ–ˆβ–ˆβ–ˆβ–‘      β–ˆβ–ˆ       β–‘β–“β–ˆβ–ˆβ–ˆβ–’   β–“β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–“   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
 β–ˆβ–ˆ   β–‘β–ˆβ–ˆ  β–“β–ˆβ–“β–‘β–‘β–‘β–’β–“  β–‘β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–‘   β–ˆβ–ˆ    β–ˆβ–ˆ  β–‘β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–ˆ  β–‘β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–‘     β–ˆβ–ˆ      β–‘β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆβ–“β–“β–ˆβ–ˆβ–‘     β–ˆβ–ˆ    
 β–ˆβ–ˆ β–‘β–‘β–ˆβ–ˆβ–’  β–ˆβ–ˆβ–’β–‘      β–“β–ˆβ–’  β–‘β–ˆβ–“   β–ˆβ–ˆ    β–ˆβ–ˆ  β–“β–ˆβ–’  β–’β–ˆβ–ˆ  β–“β–ˆβ–’  β–’β–ˆβ–“     β–ˆβ–ˆ      β–“β–ˆβ–’  β–‘β–ˆβ–“   β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–‘      β–ˆβ–ˆ    
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’   β–“β–ˆβ–ˆβ–ˆβ–ˆβ–“β–’   β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ   β–ˆβ–ˆ    β–ˆβ–ˆ  β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ  β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ     β–ˆβ–ˆ      β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ    β–’β–ˆβ–ˆβ–’       β–ˆβ–ˆ    
 β–ˆβ–ˆ        β–‘β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆ    β–ˆβ–ˆ  β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ  β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ     β–ˆβ–ˆ      β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ    β–‘β–ˆβ–ˆβ–‘       β–ˆβ–ˆ    
 β–ˆβ–ˆ           β–‘β–‘β–“β–ˆβ–ˆ  β–ˆβ–ˆβ–‘        β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ  β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ  β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ     β–ˆβ–ˆ      β–ˆβ–ˆβ–‘         β–“β–ˆβ–ˆβ–“       β–ˆβ–ˆ    
 β–ˆβ–ˆ             β–‘β–ˆβ–ˆ  β–“β–ˆβ–’        β–ˆβ–ˆβ–‘  β–‘β–ˆβ–ˆ  β–“β–ˆβ–’  β–’β–ˆβ–ˆ  β–“β–ˆβ–’  β–’β–ˆβ–“     β–ˆβ–ˆ      β–“β–ˆβ–’        β–’β–ˆβ–ˆβ–ˆβ–ˆβ–’      β–ˆβ–ˆβ–‘   
 β–ˆβ–ˆ        β–ˆβ–’β–‘β–‘β–‘β–“β–ˆβ–“  β–‘β–ˆβ–ˆβ–’β–‘β–‘β–’β–“   β–“β–ˆβ–“β–‘β–‘β–ˆβ–ˆβ–ˆ  β–‘β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–ˆ  β–‘β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–‘     β–ˆβ–ˆ      β–‘β–ˆβ–ˆβ–’β–‘β–‘β–’β–“  β–‘β–ˆβ–ˆβ–’β–’β–ˆβ–ˆβ–‘     β–“β–ˆβ–’β–‘  
 β–ˆβ–ˆ        β–‘β–“β–ˆβ–ˆβ–ˆβ–ˆβ–’β–‘   β–‘β–“β–ˆβ–ˆβ–ˆβ–“β–‘   β–‘β–“β–ˆβ–ˆβ–ˆβ–‘β–ˆβ–ˆ   β–’β–ˆβ–ˆβ–ˆβ–’β–ˆβ–ˆ   β–’β–ˆβ–ˆβ–ˆβ–ˆβ–’      β–ˆβ–ˆ       β–‘β–“β–ˆβ–ˆβ–ˆβ–“β–‘  β–“β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–“     β–‘β–“β–ˆβ–ˆβ–ˆ 
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(120).height(20);
		builder.element(new PseudoText("PseudoText"));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Plot

Plot with axis and labels based on array of points.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 3.73β”Ό              *                                  **                     β”‚
β”‚     β”‚             **                                  *                      β”‚
β”‚     β”‚             *                                  **                      β”‚
β”‚     β”‚            *                                  **                       β”‚
β”‚ 1.87β”Ό          **                                 ***                        β”‚
β”‚     β”‚       ****                               ****                          β”‚
β”‚     β”‚  ******                              *****                             β”‚
β”‚     β”‚***                             *******                             ****β”‚
β”‚-0.00β”Ό                            *****                              ******   β”‚
β”‚     β”‚                         ****                               ****        β”‚
β”‚     β”‚                       ***                                 **           β”‚
β”‚     β”‚                      **                                  *             β”‚
β”‚-1.87β”Ό                     **                                  *              β”‚
β”‚     β”‚                     *                                  **              β”‚
β”‚     β”‚                    **                                  *               β”‚
β”‚     β”‚                                                        *               β”‚
β”‚-3.73┼─────────────────┼─────────────────┼─────────────────┼─────────────────┼│
β”‚     0                90                180               270              360β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
		List<IPlotPoint> points = new ArrayList<IPlotPoint>();
		for (int degree = 0; degree <= 360; degree++) {
			if (degree > 75 && degree < 105) {
				continue;
			}
			if (degree > 255 && degree < 285) {
				continue;
			}
			double val = Math.tan(Math.toRadians(degree));
			IPlotPoint plotPoint = new PlotPoint(degree, val);
			points.add(plotPoint);
		}
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(80).height(20);
		builder.element(new Rectangle(0, 0, 80, 20));
		builder.layer(new Region(1, 1, 78, 18));
		builder.element(new Axis(points, new Region(0, 0, 78, 18)));
		builder.element(new AxisLabels(points, new Region(0, 0, 78, 18)));
		builder.element(new Plot(points, new Region(0, 0, 78, 18)));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Table

Table with rows and columns.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚12345678β”‚        β”‚        β”‚        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        β”‚        β”‚        β”‚        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β•†β”β”β”β”β”β”β”β”β•…β”€β”€β”€β”€β”€β”€β”€β”€β•†β”β”β”β”β”β”β”β”β”ͺ
β”‚        ┃        ┃        ┃1234567…┃
└────────┺━━━━━━━━┹────────┺━━━━━━━━┛
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(37).height(7);
		Table table = new Table(4, 3);
		table.setElement(1, 1, new Label("1234567890"));
		table.setElement(4, 3, new Text("1234567890"), true);
		table.setHighlighted(2, 3, true);
		builder.element(table);
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Overlay

Possibility to combine results of several renders.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  β”‚
β”‚                  β”‚
β”‚Loreβ”Œβ”€β”€β”€β”€β”€β”€β”€β”s simβ”‚
β”‚ply β”‚Overlayβ”‚t of β”‚
β”‚the β””β”€β”€β”€β”€β”€β”€β”€β”˜and …│
β”‚                  β”‚
β”‚                  β”‚
β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
		IRender render1 = new Render();
		IContextBuilder builder1 = render1.newBuilder();
		builder1.width(9).height(3);
		builder1.element(new Rectangle());
		builder1.element(new Text("Overlay", 1, 1, 7, 1));
		ICanvas canvas1 = render1.render(builder1.build());

		IRender render2 = new Render();
		IContextBuilder builder2 = render2.newBuilder();
		builder2.width(20).height(10);
		builder2.element(new Rectangle());
		builder2.element(
				new Text("Lorem Ipsum is simply dummy text of the printing and typesetting industry.", 1, 3, 18, 3));
		builder2.element(new Overlay(5, 3, canvas1, true));
		ICanvas canvas2 = render2.render(builder2.build());
		String s = canvas2.getText();
		System.out.println(s);

PseudoCanvas

In some cases you can get better results by synthetic increasing of "pixel resolution". This is possible by calling render.setPseudoCanvas(true) method. After that render would use β––β–—β–˜β–™β–šβ–›β–œβ–β–žβ–Ÿβ–„β–β–Œβ–€β–ˆ chars for drawing 4 points in 1 char. This is would work only if you do not use any special symbols for drawing (but you still can use Overlay to combine two different renders).

Example 1: line in 30x10 resolution:

β–ˆβ–ˆ                            
  β–ˆβ–ˆβ–ˆ                         
     β–ˆβ–ˆβ–ˆβ–ˆ                     
         β–ˆβ–ˆβ–ˆ                  
            β–ˆβ–ˆβ–ˆ               
               β–ˆβ–ˆβ–ˆ            
                  β–ˆβ–ˆβ–ˆ         
                     β–ˆβ–ˆβ–ˆβ–ˆ     
                         β–ˆβ–ˆβ–ˆ  
                            β–ˆβ–ˆ
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(30).height(10);
		builder.element(new Line(new Point(0, 0), new Point(29, 9), 'β–ˆ'));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

And same line in 60x20 resolution:

β–€β–„β––                           
  ▝▀▄▖                        
     ▝▀▄▄                     
         β–€β–šβ–„                  
            β–€β–šβ–„               
               β–€β–šβ–„            
                  β–€β–šβ–„         
                     β–€β–€β–„β––     
                        ▝▀▄▖  
                           ▝▀▄
		IRender render = new Render();
		render.setPseudoCanvas(true);
		IContextBuilder builder = render.newBuilder();
		builder.width(60).height(20);
		builder.element(new Line(new Point(0, 0), new Point(59, 19)));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Example 2: pseudo text in 60x10 resolution:

                                                            
                          β–ˆ                                 
 β–ˆβ–ˆβ–ˆ                      β–ˆ      β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ                      
 β–ˆ  β–ˆ                     β–ˆ        β–ˆ               β–ˆ        
 β–ˆ  β–ˆ β–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆ  β–ˆ  β–ˆ   β–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ    β–ˆ    β–ˆβ–ˆ  β–ˆ  β–ˆ  β–ˆβ–ˆβ–ˆβ–ˆ      
 β–ˆβ–ˆβ–ˆ  β–ˆ     β–ˆ  β–ˆ β–ˆ  β–ˆ  β–ˆ  β–ˆ β–ˆ  β–ˆ   β–ˆ   β–ˆ  β–ˆ  β–ˆβ–ˆ    β–ˆ        
 β–ˆ     β–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆ β–ˆ  β–ˆ  β–ˆ  β–ˆ β–ˆ  β–ˆ   β–ˆ   β–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ    β–ˆ        
 β–ˆ       β–ˆ  β–ˆ    β–ˆ  β–ˆ  β–ˆ  β–ˆ β–ˆ  β–ˆ   β–ˆ   β–ˆ     β–ˆβ–ˆ    β–ˆ        
 β–ˆ    β–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ    β–ˆ    β–ˆβ–ˆβ–ˆ β–ˆ  β–ˆ   β–ˆβ–ˆβ–ˆ      
                                                            
		IRender render = new Render();
		IContextBuilder builder = render.newBuilder();
		builder.width(60).height(10);
		builder.element(new PseudoText("PseudoText", false));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

And same pseudo text in 120x20 resolution:

                                                            
                                                            
                        β–„                                   
▐▛▀▙                    β–ˆ      β–€β–€β–ˆβ–€β–€            β–β–Œ          
β–β–Œ β–β–Œ β–—β–„β–„   β–„β–„  β–„  β–„  β–„β––β–ˆ  β–—β–„β––   β–ˆ   β–—β–„β––  β–„β––β–—β–„ β–—β–Ÿβ–™β–„         
β–β–Œ β–Ÿβ–˜β–β–Œ  β–˜ β–Ÿβ–˜β–β–™ β–ˆ  β–ˆ β–Ÿβ–˜β–β–ˆ β–—β–› β–œβ––  β–ˆ  β–—β–› β–œβ–– β–β–ˆβ–ˆβ–˜  β–β–Œ          
β–β–›β–€β–˜ β–β–ˆβ–ˆβ–™β–– β–ˆβ–„β–„β–ˆ β–ˆ  β–ˆ β–ˆ  β–ˆ β–β–Œ β–β–Œ  β–ˆ  β–β–™β–„β–Ÿβ–Œ  β–β–Œ   β–β–Œ          
β–β–Œ      β–œβ–Œ β–ˆ    β–ˆ  β–ˆ β–ˆ  β–ˆ β–β–Œ β–β–Œ  β–ˆ  β–β–Œ     β–ˆβ–ˆ   β–β–Œ          
β–β–Œ   β–β–„β–„β–žβ–˜ β–β–™β–„β–ž β–œβ–™β–žβ–ˆ β–β–™β–žβ–ˆ  β–œβ–„β–›   β–ˆ   β–œβ–„β–„β–˜ β–Ÿβ–Œβ–β–™  ▝▙▄         
                                                            
		IRender render = new Render();
		render.setPseudoCanvas(true);
		IContextBuilder builder = render.newBuilder();
		builder.width(120).height(20);
		builder.element(new PseudoText("PseudoText", false));
		ICanvas canvas = render.render(builder.build());
		String s = canvas.getText();
		System.out.println(s);

Download release

https://github.com/indvd00m/java-ascii-render/releases

Release notes

Version 0.9.0

Version 1.0.0

  • Reworking API. Add new elements.

Version 1.1.0

  • Add PseudoText element.
  • Use Bresenham's algorithm for line drawing.

Version 1.2.0

  • Simplify extending existing elements.

Version 1.2.1

  • Pass axis type to format method in AxisLabels element.

Version 1.2.2

  • Add deploy to maven central.

Version 1.2.3

  • Add url to pom's.

Version 1.2.4

  • Add some useful methods to builder.

Version 1.3.0

  • Add table element.

Version 1.4.0

  • Add overlay element.
  • Added possibility to trim canvas.
  • Simplified extending of existing implementation.

Version 1.5.0

  • Improved canvas draw performance.

Version 2.0.0

  • Canvas now is empty by default - contains only \0 and \n symbols. Previous Canvas implementation contained \s and \n symbols. This new changes break backward compatibility for drawing behavior in some cases (but do not break compile time API compatibility). Now overlapping of layers would work correctly when you directly draw spaces \s to layer.
  • Added opacity for layers.

Version 2.1.0

  • Added table cells highlighting.

Version 2.1.1

  • Added some useful constructors.

Version 2.1.2

  • Fixed javadoc.

Version 2.1.3

  • Simplified extending of Table element.

Version 2.2.0

  • Added possibility to increase "pixel" resolution.

Roadmap

This component is developed as a hobby with no public roadmap or any guarantees of upcoming releases. That said, the following features are planned for upcoming releases:

  • Fluent API for elements.

Issue tracking

The issues for this project are tracked on its github.com page. All bug reports and feature requests are appreciated.

Building and running tests

git clone https://github.com/indvd00m/java-ascii-render.git
cd java-ascii-render
mvn clean install

Contributions

Contributions are welcome, but there are no guarantees that they are accepted as such. Process for contributing is the following:

  • Fork this project
  • Create an issue to this project about the contribution (bug or feature) if there is no such issue about it already. Try to keep the scope minimal.
  • Develop and test the fix or functionality carefully. Only include minimum amount of code needed to fix the issue.
  • Refer to the fixed issue in commit
  • Send a pull request for the original project
  • Comment on the original issue that you have implemented a fix for it

License & Author

Java ASCII Render is distributed under Apache License 2.0. For license terms, see LICENSE.

Java ASCII Render is written by David E. Veliev.