Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

50
LINES

< > BotCompany Repo | #1002181 // ASCII art bot

JavaX source code - run with: x30.jar

1  
//Please copy this and then fix some stuff then turn it into Javax. I don't know Java very well but you do.
2  
3  
import java.awt.Font;
4  
import java.awt.Graphics;
5  
import java.awt.Graphics2D;
6  
import java.awt.RenderingHints;
7  
import java.awt.image.BufferedImage;
8  
import java.io.File;
9  
import java.io.IOException;
10  
11  
import javax.imageio.ImageIO;
12  
13  
public class ASCIIArt {
14  
15  
  public static void main(String[] args) throws IOException {
16  
  
17  
	BufferedImage image = null;
18  
        try {
19  
            URL url = new URL(); // Ask for image
20  
            image = ImageIO.read(url);
21  
        } catch (IOException e) {
22  
        	e.printStackTrace();
23  
        }
24  
25  
	Graphics g = image.getGraphics();
26  
	g.setFont(new Font("SansSerif", Font.BOLD, 24));
27  
28  
	Graphics2D graphics = (Graphics2D) g;
29  
	graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
30  
				RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
31  
	graphics.drawString("JAVA", 10, 20);
32  
33  
	for (int y = 0; y < height; y++) {
34  
		StringBuilder sb = new StringBuilder();
35  
		for (int x = 0; x < width; x++) {
36  
37  
			sb.append(image.getRGB(x, y) == -16777216 ? " " : "$");
38  
				
39  
		}
40  
41  
		if (sb.toString().trim().isEmpty()) {
42  
			continue;
43  
		}
44  
45  
		System.out.println(sb); //Print image out
46  
	}
47  
48  
  }
49  
50  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002181
Snippet name: ASCII art bot
Eternal ID of this version: #1002181/1
Text MD5: ab313110a2e8ab48004a1ede65eebcc5
Author: bgrgndz
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-23 18:12:47
Source code size: 1251 bytes / 50 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 658 / 614
Referenced in: [show references]