# Draw a trololologram [closed]

Your challenge here is to draw a trololologram.

You can choose any language.

The answer with more upvotes and the one that exploits more holes wins.

• You can't use any network resource or external file (except the source-code)
• You can't post someone else's answer
• You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).
• You can't store the image in any database.
• You can't simply print/echo 'trololologram' (case insensitive)
• The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background. The rendered version can't "be invisible" or "hidden behind the screen" or similar.
• The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count).

The main goal is to twist the rules and bend them at your own will and stil render a trololologram on screen.

Have fun!

• I believe this challenge is impossible, since all computer generated graphics have to be in some image format, but this is prohibited by the rules. – user12205 Feb 20 '14 at 21:41
• @ace OP should clarify but I believes he means that it should be drawn on the fly by the program, not pre-rendered and displayed. – Jason C Feb 20 '14 at 21:47
• I hope it is more clear now. Sorry for the trouble. – Ismael Miguel Feb 20 '14 at 22:01
• The link at the top is in danger of becoming a circular reference, as this page rises up the Google ranks. Which might actually give us a loophole . . . – Neil Slater Feb 21 '14 at 13:42
• If you create a challenge about trolling and expect serious answers, you're gonna have a bad time... – Nyx Feb 21 '14 at 18:49

For this challenge, I am posting five programs in this answer, all in Java.

## Program 1

You can't simply print/echo 'trololologram' (case insensitive)

public class JustPrintIt {
public static void main(String[] args) {
System.out.println("trololologram");
}
}


## Program 2

You can't [...] pre-rendered ([...] and any form of ascii art).

public class AsciiArt {
public static void main(String[] args) {
System.out.println(
"    ########################       \n" +
"  ##                        #      \n" +
"  #                          #     \n" +
" #                            ##   \n" +
" #                              #  \n" +
" #                              #  \n" +
"  #                            #   \n" +
"  #                          ##    \n" +
"  #                     #####      \n" +
"  #            #########           \n" +
"   ############                    \n");
}
}


## Program 3

You can't use any network resource or external file (except the source-code)

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's [...]).

You can't store the image in any database.

The code must render the trolologram on the screen [...].

The image must show in the screen. It can't output the code to a file [...].

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Base64;
import javax.imageio.ImageIO;

public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException {
String url = "http://img171.imageshack.us/img171/8555/trolologramw400.jpg";
ImageIO.write(im, "png", new File("trolologram.png"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(im, "png", baos);

String d = "data://" + new String(Base64.getEncoder().encode(baos.toByteArray()));
Class.forName("com.mysql.jdbc.Driver");
try (Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306", "root", "root")) {
try (PreparedStatement ps = con.prepareStatement("CREATE DATABASE troll")) {
ps.executeUpdate();
} catch (SQLException e) {
if (!e.getMessage().contains("database exists")) throw e;
}
try (PreparedStatement ps = con.prepareStatement("CREATE TABLE troll.image (imagedata text not null)")) {
ps.executeUpdate();
} catch (SQLException e) {
}
try (PreparedStatement ps = con.prepareStatement("INSERT INTO troll.image (imagedata) VALUES (?)")) {
ps.setString(1, d);
ps.executeUpdate();
}
}
}
}


## Program 4

Your challenge here is to draw a trololologram.

You can't use any network resource or external file (except the source-code)

You can't post someone else's answer

You can't have it stored in any image format or pre-rendered [...].

[...] (minimum size of 90x90) and must be with a black border and white background. [...].

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public static void main(String[] args) throws IOException {

// See this: http://codegolf.stackexchange.com/a/20085/3755
String url = "http://placehold.it/99/png&text=Hello+world!";

BufferedImage im2 = new BufferedImage(89, 89, BufferedImage.TYPE_INT_ARGB);
im2.createGraphics().drawImage(im, 0, 0, null);
SwingUtilities.invokeLater(() -> createAndShowGUI(im2));
}

private static void createAndShowGUI(BufferedImage im) {
JFrame frame = new JFrame("");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JComponent panel = new JComponent() {
@Override
public Dimension getPreferredSize() {
return new Dimension(im.getWidth(), im.getHeight());
}

@Override
public Dimension getMinimumSize() {
return new Dimension(im.getWidth(), im.getHeight());
}

@Override
public Dimension getMaximumSize() {
return new Dimension(im.getWidth(), im.getHeight());
}

@Override
public void paintComponent(Graphics g) {
g.drawImage(im, 0, 0, null);
}
};

frame.pack();
frame.setVisible(true);
}
}


## Program 5

You can't use any network resource or external file (except the source-code)

You can't have it stored in any image format or pre-rendered [...].

The code must render the trolologram on the screen [...] and must be with a black border and white background. The rendered version can't "be invisible" or [...].

The image must show in the screen. [...].

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class ShowTheTrolologramOnScreenButNot {
public static void main(String[] args) throws IOException {
String url = "http://img171.imageshack.us/img171/8555/trolologramw400.jpg";
for (int i = 0; i < im.getHeight(); i++) {
for (int j = 0; j < im.getWidth(); j++) {
int rgb = im.getRGB(j, i);
int r = 255 - (rgb >> 16 & 0xff);
int g = 255 - (rgb >> 8 & 0xff);
int b = 255 - rgb & 0xff;
im.setRGB(j, i, 0xFF000000 + (r << 16) + (g << 8) + b);
}
}
SwingUtilities.invokeLater(() -> createAndShowGUI(im));
}

private static void createAndShowGUI(BufferedImage im) {
JFrame frame = new JFrame("");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JComponent panel = new JComponent() {
@Override
public Dimension getPreferredSize() {
return new Dimension(im.getWidth(), im.getHeight());
}

@Override
public Dimension getMinimumSize() {
return new Dimension(im.getWidth(), im.getHeight());
}

@Override
public Dimension getMaximumSize() {
return new Dimension(im.getWidth(), im.getHeight());
}

@Override
public void paintComponent(Graphics g) {
g.drawImage(im, 0, 0, null);
}
};
panel.setVisible(false); // :)

frame.pack();
frame.setVisible(true);
}
}


## And finally...

So here it is:

The answer with more upvotes and the one that exploits more holes wins.

There is hole in this: you did not said that it must be a valid answer to be accepted!

• That is not an hole. And yet, you didn't posted one single valid answer. And yes, I didn't, but invalid answers will be ignored. – Ismael Miguel Feb 21 '14 at 9:22
• @IsmaelMiguel There is nothing in your question saying that invalid answers can't be accepted and for me, this is a hole (after all, this is code-trolling). So, what I tried was to make my answer the most invalid as I could by intentionally breaking all the rules. – Victor Stafusa Feb 21 '14 at 11:22
• I know it and I know it. But there is nothing saying that i have to accept invalid answer either. I believe that by being invalid, it's implied that I won't accept it as the correct answer and winner. – Ismael Miguel Feb 21 '14 at 12:08
• @IsmaelMiguel Ok. You do not need to accept it (I was not expecting this anyway). But it was quite fun to code something to violate all the rules instead of something to follow all the rules. – Victor Stafusa Feb 21 '14 at 12:10
• I accept it as an answer, and I actually though it was a funny answer. But accepting it as a possible winner? Sorry but the answer itself is invalid. But still, you will get +1 from me. – Ismael Miguel Feb 21 '14 at 12:15

# Java 8

Here it is:

You can't use any network resource or external file (except the source-code)

You can't post someone else's answer

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).

It is indeed not an image format. It is not ascii-art either, since all the characters are the same. It is not pre-rendered either, its source is just english text.

If you insists, this is ascii-art:

/-------\
|       |
| O   O |
|       |
| ----- |
\-------/


This is not ascii-art:

XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX


You can't store the image in any database.

It does not, but it saves an SQL's INSERT statement into a file.

You can't simply print/echo 'trololologram' (case insensitive)

Yes, I do not do simply that.

The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background. The rendered version can't "be invisible" or "hidden behind the screen" or similar.

Indeed it has a minimum size of 90x90.

The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count).

Indeed, it does not outputs code to a file, it outputs something else!

Here, a screenshot:

Here, the code:

import java.awt.Dimension;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

/*
THIS IMAGE IS NOT PRE-RENDERED, I SWEAR THAT!#THIS image is not pre-rendered, i swEAR THAT!#THis IMAGE IS NOT PRE-RENDERED, I SWeAR THAT!#THiS IMAGE IS NOT PRE-RENDERED, I SWEaR THAT!#ThIS IMAGE IS NOT PRE-RENDERED, I SWEAr tHAT!#ThIS IMAGE IS NOT PRE-RENDERED, I SWEAR ThAT!#ThIS IMAGE IS NOT PRE-RENDERED, I SWEAR ThAT!#THiS IMAGE IS NOT PRE-RENDERED, I SWEAR tHAT!#THiS IMAGE IS NOT PRE-RENDERED, I SWEar THAT!#THiS IMAGE IS NOT PRE-RENDEREd, i sweAR THAT!#THiS IMAGE IS NOT Pre-rendereD, I SWEAR THAT!#THIs image is not pRE-RENDERED, I SWEAR THAT!#THIS IMAGE IS NOT PRE-RENDERED, I SWEAR THAT!
*/

public class Trolologram {
public static void main(String[] args) throws IOException {
.replaceAll("\n|\r", "#")
.replaceAll("##+", "#")
.replaceAll(".*\\Q/" + "*\\E", "")
.replaceAll("\\Q*" + "/\\E.*", "");
String x = createImage(s.substring(1, s.length() - 2));
System.out.println("'trololologram' (case insensitive)");
writeContents("'trololologram' (case insensitive)##" + s, new File("database.output"));
SwingUtilities.invokeLater(() -> {
UIManager.put("swing.boldMetal", Boolean.FALSE);
createAndShowGUI(x);
});
}

private static String readContents(File input) throws IOException {
StringBuilder sb = new StringBuilder((int) input.length());
try (FileInputStream fis = new FileInputStream(input)) {
int a;
while ((a = fis.read()) != -1) {
sb.append((char) a);
}
}
return sb.toString();
}

private static void writeContents(String toWrite, File output) throws IOException {
try (FileOutputStream fos = new FileOutputStream(output)) {
for (char c : toWrite.toCharArray()) {
fos.write(c == '#' ? '\n' : c);
}
fos.write('\n');
fos.write('\n');
for (char c : toWrite.substring(37).toCharArray()) {
if (" ,!-".contains("" + c)) continue;
fos.write(c == '#' ? '\n' : c <= 'Z' ? ' ' : '#');
}
fos.write('\n');
fos.write('\n');
fos.write(("INSERT INTO troll (imagedata) VALUES ('" + toWrite.substring(37) + "')").getBytes());
}
}

private static String createImage(String s) {
String[] lines = s.split("#");
StringBuilder html = new StringBuilder(10000);
html.append("<html>");
boolean first = true;
for (String line : lines) {
if (first) {
first = false;
} else {
html.append("<br>");
}
html.append("<code>");
for (char c : line.toCharArray()) {
if (" !,-".contains("" + c)) continue;
String color = c <= 'Z' ? "white" : "black";
html.append("<font color=" + color + ">X</font>");
}
html.append("</code>");
}
return html.toString();
}

private static JLabel label(boolean a, String text) {
JLabel theLabel = new JLabel(text) {
@Override
public Dimension getPreferredSize() {
return new Dimension(a ? 350 : 500, 400);
}

@Override
public Dimension getMinimumSize() {
return new Dimension(a ? 350 : 500, 400);
}

@Override
public Dimension getMaximumSize() {
return new Dimension(a ? 350 : 500, 400);
}
};
theLabel.setVerticalAlignment(SwingConstants.CENTER);
theLabel.setHorizontalAlignment(SwingConstants.CENTER);
return theLabel;
}

private static String Q = "<html>Your challenge here is to draw a <font color='#4e82c2'>trololologram</font>." +
"<br>" +
"You can choose any language." +
"<br>" +
"The answer with more upvotes and the one that exploits more holes wins." +
"<br>" +
"<ul>" +
"<br><li>You can't use any network resource or external file (except the source-code)" +
"<br><li>You can't post someone else's answer" +
"<br><li>You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art)." +
"<br><li>You can't store the image in any database." +
"<br><li>You can't simply print/echo 'trololologram' (case insensitive)" +
"<br><li>The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background. The rendered version can't \"be invisible\" or \"hidden behind the screen\" or similar." +
"<br><li>The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count)." +
"</ul>" +
"<br>" +
"The main goal is to twist the rules and bend them at your own will and stil render a trololologram on screen." +
"<br>" +
"Have fun!";

private static void createAndShowGUI(String x) {
JFrame frame = new JFrame("'trololologram' (case insensitive)");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));

frame.pack();
frame.setVisible(true);
}
}

• While this solution is great, I have a strange feeling that you guys have completely nothing to do except coding :) – VisioN Feb 21 '14 at 0:07
• @IsmaelMiguel Done. You can see the usefulness of the comment in the screenshot. – Victor Stafusa Feb 21 '14 at 0:20
• Still a form of ascii art. And it's pre-rendered inside a comment. If you somehow store that info inside an array of numbers, I will count that as a valid answer. But dont make it an array of 1 and 0. Still will count as some sort of ascii art. – Ismael Miguel Feb 21 '14 at 0:30
• @IsmaelMiguel If I put everything in one single line, it is not ascii-art anymore, right? Sorry for insisting, I must find a way to abuse this. – Victor Stafusa Feb 21 '14 at 1:27
• I have to consider it valid. – Ismael Miguel Feb 21 '14 at 2:50

# HTML/JavaScript (with a vengeance)

Since the humorous trollesque approach did not meet with an unadulterated success, here is my hackish JavaScript attempt, complete with its state-of-the-art HTML wrapper:

<script>function _(_,l,I,j){_-=i%$/5;l-=i*(j||.4)/$;return _*_+l*l<I*I/4}l='<pre>';$=90;for( i=0;i<4e3;i++)l+=i%$?' %'[!(_(6,9,2,.8)|_(13,12,3,1)|_(7,48,5,1.4)|_(10,33,2,1))&(_(5,7,8)|_(
15,7,6)|_(-20,9,74)&_(38,9,72)&_(9,20,40)&_(-8,-10,64))]:'\n';document.write(l)</script>


Should produce something like this:

Skeptical people can see a live example here.

EDIT: let's review the rules point per point

You can't use any network resource or external file (except the source-code)

No problem there. You can run a script from within an HTML page directly from your hard disk.

You can't post someone else's answer

Check.

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).

Check.

You can't store the image in any database.

Check, provided the function parameters are not considered part of a database.

You can't simply print/echo 'trololologram' (case insensitive)

I was tempted to use the characters in "trololologram" instead of "%" as a filler, but that would have had an intolerable impact on the size of the program.

The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background.

Check (you did not specify the interior color).

The rendered version can't "be invisible" or "hidden behind the screen" or similar.

Check.

The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count).

As long as your browser window is not obscured, it's clearly showing the image on the screen. It's your genuine display, no cryptic device or virtual screen or viewport.

An HTML page, once rendered, is (among other things) an image displayed on the screen.
You can capture it, store it to disk, photoshop it, email it to relatives and friends, print it on genuines bits of dead trees and light a fire with it for all I care, but it's a friggin image.

About the ressemblance with the original trololologram, I do not claim to be an artist. Consider this code as a proof of concept. If someone wants to spend the hour(s) needed to tweak and add more elements to get closer to the original, he/she is welcome to do so.

• Just one question: where is it rendered as an image? – Ismael Miguel Feb 22 '14 at 22:49
• I'm not even gonna comment about that. It's a good answer, but I'm not gonna comment about it. – Ismael Miguel Feb 22 '14 at 23:40
• ??? Obfuscation aside, it's just a bit of code drawing a shape based on homotetic circles combinations. I can add a readable version if you want. The remark about MySQL was not meant to be offensive either. I always found DB interfaces tend to produce ungainly code, that's all. And as others have already stated, the question invites a certain amount of trollishness. – user16991 Feb 23 '14 at 0:03
• I know it does invite trollishness. But I want people to troll, but to follow those rules. – Ismael Miguel Feb 23 '14 at 0:17
• Come on, the first answer was a bad joke. No offense, but it was. This one is an answer, but it still has lots of things that make it invalid. For example: it doesn't render an image and the accuracy of the trololologram is quite questionable (I didn't said anything about the accuracy in the question). It really is a nice code and almost reaches the goal. But it has to be an image. – Ismael Miguel Feb 23 '14 at 1:21

# Autoit 3 Script

$trol=ASCIIGenerate(4,1,1,0)&ASCIIGenerate(24,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(2,0,0,0)&ASCIIGenerate(24,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(26,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(1,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(28,1,0,0)&ASCIIGenerate(2,0,0,1)&ASCIIGenerate(1,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(30,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(1,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(30,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(28,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(26,1,0,0)&ASCIIGenerate(2,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(21,1,0,0)&ASCIIGenerate(5,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(12,1,0,0)&ASCIIGenerate(9,0,0,1)&ASCIIGenerate(3,1,1,0)&ASCIIGenerate(12,0,0,1) RunWait("cmd /C @echo off&color F0&"&$trol&"pause > nul")

Func ASCIIGenerate($num,$char,$echo,$and)
Local $i=0 Local$str=""
If $echo=1 Then$str&="echo "
EndIf
Do
Switch $char Case 0$str&="#"
Case 1
$str&=" " EndSwitch$i+=1
Until $i=$num
If $and=1 Then$str&="&"
EndIf
Return \$str
EndFunc


Output:

Holes exploited:

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).

The ASCII art is generated by the script on the fly. The script itself only has info on which and how many characters it must draw onscreen and when start a new line.

You can't store the image in any database. The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count).

The script doesn't create nor contain any files. When generated, the ASCII art is loaded onto the computer's RAM and then shown via CMD commands (without using any batch files, only cmd /c ).

The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background. The rendered version can't "be invisible" or "hidden behind the screen" or similar.

The image displayed onscreen is way bigger than 90x90 and it's black on a white background.

• You didn't exploited any hole. – Ismael Miguel Feb 22 '14 at 23:43
• Acutally, I did. You said no to any form of pre-rendered ASCII art and still, while the source code in itself doesn't contain any, it still generates and shows it onscreen. That pretty much sounds like a hole to me. – user17067 Feb 23 '14 at 11:06
• Generating ascii art is totally different from what I meant. – Ismael Miguel Feb 23 '14 at 19:51

# HTML/CSS

<p style='font-size:100px'}>&#x1f606;


# 😆

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).

Well it's not me that does the rendering, it's the browser.
And there is no ASCII here, only unicode :p.

• Is this a serious answer? Or are you trolling? – Ismael Miguel Feb 22 '14 at 5:16
• Since it's a question about trolling (practically asking to get troll-answers) the trolling in itself does not make this a bad answer (see the other answers). The end result, however, hardly resembles the requested output. So I'd have to guess that's why the downvotes. shrug – Vincent Vancalbergh Feb 22 '14 at 7:29
• Must be my warped French sense of humor failing to translate or something :)... – user16991 Feb 22 '14 at 10:49
• Even ○ would be a better answer. – Ismael Miguel Feb 23 '14 at 0:12

## HTML

Even ○ would be a better answer. – Ismael Miguel Feb 23 at 0:12

Well here it is:

○


(with the browser zoomed in until it gets 90x90)