ASCII Art Java example | Code Factory

package com.codeFactory;import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
* @author code.factory
public class ASCIIArt {
public static void main(String[] args) throws IOException {int width = 130;
int height = 30;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setFont(new Font("SansSerif", Font.BOLD, 15));
Graphics2D graphics = (Graphics2D) g;
graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
graphics.drawString("Code Factory", 10, 20);
for (int y = 0; y < height; y++) {
StringBuilder sb = new StringBuilder();
for (int x = 0; x < width; x++) {
sb.append(image.getRGB(x, y) == -16777216 ? " " : "#");
if (sb.toString().trim().isEmpty()) {




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Beginners guide to Apache Spark for data analytics — Part 2

A manager-friendly workflow automation software

My Steps for Getting Started with Java Development on Windows

How To Create an Automated Planogram Compliance Detector in the Neurolabs Platform

A screenshot of the input image used to make the planogram as well as the image being processed and accompanying output JSON file.

How to Shut Down Windows At a Specific Time

Start Menu

Sequelize: Using SoftDelete/Restore on table relationship with paranoid

Deploy your app on AWS free

This week in Wagmi DAO

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Code Factory

Code Factory

More from Medium

Singleton Design Pattern in Java

SOLID Principles in Java

Java 13 Features

Transpose Matrix Using Java