#!/usr/bin/perl -w
# By Kragen Sitaker, 2000.  In the public domain.
use strict;
print <<EOH;
%!
2 setlinewidth
% (x) .06 103.53 67.2 charat  will put 'x', scaled .06, at physical
% coordinates 103.53, 67.2, and remove all four arguments from the
% stack.
/charat {
	gsave 
		translate
		dup scale
		0 0 moveto
		show
	grestore
} bind def
/Times-Roman findfont 12 scalefont setfont
EOH

# about the last four lines of this go off the top of the page.  Oh
# well.
my $text = <<eotext;
HEXTEXT PROGRAM BY KRAGEN SITAKER
Biointensive Gardening/Mini-farming:

John Jeavons and Ecology Action have refined a production system that
makes it possible for one person to grow all of his or her family's food
using truly sustainable methods that maintain the fertility of the soil
without relying on nonrenewable resources like petrochemicals or
imported organic matter. [From: John Jeavons, How To Grow More
Vegetables, Fruits, Nuts, Berries, Grains, And Other Crops On Less Land
Than You Can Imagine (Berkeley CA: Ten Speed Press, 1995). NAL Call #
SB324.5 J43 1995] The concepts and practices of biointensive gardening
were synthesized and introduced to the US by the English master
horticulturalist, Alan Chadwick. Important components include
double-dug, raised beds; intensive planting; composting; companion
planting; and whole system synergy. [Biointensive: A Sustainable
Solution To Growing Food (Ecology Action). Available at Ecology Action
Website (9/99): http://solstice.crest.org/sustainable/ecology_action/]
+++++ It is a method of plant raising that is simple to learn and
perform, but is based on sophisticated principles dating back 4000 years
in China, 2000 years in Greece, and 300 years in Europe.  Several
important aspects of the method are: + Double-Dug, Raised Beds +
Intensive Planting + Composting + Companion Planting + A Whole Gardening
Method +++++ Seeds or seedlings are planted in 3 to 5 foot wide beds
using a hexagonal spacing pattern.  Each plant is placed the same
distance from all seeds nearest to it, so that when the plants mature,
their leaves touch. This provides a "mini-climate" under the leaves
which retains moisture, protects the valuable microbiotic life of the
soil, retards weed growth, and provides for high yields. The method
avoids problems encountered when planting in narrow rows.  
eotext

$text =~ s/\n/ /g;
$text =~ s/ /-/g;

my @letters = map { ($_ =~ /[()\\]/) ? "\\$_" : $_ } split //, $text;


# Because I'm stupid and don't understand PostScript, I'll use physical
# coordinates in the Postscript and do all the math in Perl.
# 
# My coordinate system looks like this:
# 
#  (-1,1)  (0,2)   (1,2)
#
#      (0,1)   (1,1) 
#
#  (0,0)   (1,0)   (2,0)
#
# Ideally, (0,0), (0,1), and (1,0) are an equilateral triangle.

my $cos = cos (30 * 3.1415926/180);
my $sin = sin (30 * 3.1415926/180);
my $scale = 18;  # one fourth of an inch
my @origin = (20, 20);
sub phys {
	my ($x, $y) = @_;
	return (
		$origin[0] + $scale * $x + $scale * $sin * $y,
		$origin[1] + $scale * $cos * $y
	);
}

# allowable error is 1/1200 of an inch, or 0.06 points.
sub dotat {
	my ($x, $y, $size) = @_;
	my $letter = shift @letters;
	printf "(%s) %.4f %.2f %.2f charat\n", $letter, $size, phys $x, $y;
}

# these physical numbers are taken from a Xerox Document Center printing
# on US Letter paper (8.5" by 11"); they ought to be reasonably close to
# valid for other people.
my $max_phys_x = 597.9;
my $max_x = ($max_phys_x - $origin[0])/$scale;  # valid for y=0
my $max_phys_y = 780.72;
my $max_y = ($max_phys_y - $origin[1])/($scale * $cos);

for my $y (0..int $max_y) {
	for my $x (int(-$y/2)..int($max_x)+int(-$y/2)-1) {
		my $size;
		if ($y % 12 == 0 and $x % 12 == 0) {
			$size = 1/2;
		} elsif ($y % 3 == 0 and $x % 3 == 0) {
			$size = 1/3;
		} else {
			$size = 1/6;
		}
		dotat $x, $y, $size;
	}
}

print "showpage\n";
