Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

3D Hidden Text

by bladx (Chaplain)
on Aug 24, 2001 at 05:26 UTC ( #107582=sourcecode: print w/replies, xml ) Need Help??
Category: Fun Stuff
Author/Contact Info Andy::bladx ...
Description: This is really one of my first perl programs (using the module, which by the way, is really cool!) and is also written for use with a CGI as well. What it does, it basically re-creates what those magic eye book pictures kind of look like, except that it is more like the old days when 3d glasses were new. It's easy to change the variables to change what colors (or even add new colors,) to what is there, and although it is very simple, hopefully it's fun for someone ... (other than me. :-)) BTW, there is a working version of this at: here ... if you want to see it.
#!/usr/bin/perl -w
use strict;
use GD;

# Create a new image object.
my ($width,$height) = (300,300);
my $im = new GD::Image($width,$height);

# Allocate a few custom colors.
my $black = $im->colorAllocate(0,0,0);
my $blue = $im->colorAllocate(0,0,255);
my $green = $im->colorAllocate(0,255,0);
my $lgrey = $im->colorAllocate(200,200,200);
my $lred = $im->colorAllocate(255,190,190);
my $red = $im->colorAllocate(255,0,0);
my $white = $im->colorAllocate(255,255,255);
my $yellow = $im->colorAllocate(255,255,0);

# Make image transparent and interlaced.

# Pass these values and run subroutine Box.
# (Since this data does not need to be kept
# secure really, I went ahead and decided
# to pass variables the basic way.

sub Box {
# Sets up and prints the funky pattern that
# kinda masks the words you are supposed to
# try to see.

# Find's (not necessarily the perfect center,)
# center of whatever value width used to be,
# and changes it into the new value, since we
# don't need the old value of width anymore.
$width = $width/4;

# Prints out whatever string you want to put here,
# in a nifty old-skool C-style for-loop.
for (my $x=$width;$x<=$width;$x++) {
  for (my $y=0;$y<=300;$y+=15) {
    $im->string($_[2],$x,$y,"The Andy-man can!",$_[3]);

# Finish up Box subroutine, and run the Lines sub.

sub Lines {
# This subroutine sets up and prints some funky
# lines to obscure your otherwise easily seen
# 'hidden' string.
for (my $x=0;$x<=300;$x++) {
  for (my $y=0;$y<=300;$y+=15) {

# This little bite-size piece of code simply
# prints out the little footprint for the title
# of the script to reside on.
for (my $x=0;$x<=300;$x++) {
  for (my $y=280;$y<=300;$y++) {

$im->string(gdSmallFont,5,283,"Subliminal Messages with 3d Glasses Sup


# Makes sure that this script works on most any
# platform that it might be run on.
binmode STDOUT;

# Sets the type of picture for the web,
# to know that it is a .png
print "Content-type: image/png\n\n";

# We are all done, so now we just have to
# have it output to the web!
print $im->png;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://107582]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2020-09-27 09:49 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (142 votes). Check out past polls.