#!/usr/bin/perl

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

eval 'exec /usr/app/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

use Gimp qw(:auto __ N_);
use Gimp::Fu;

sub goldenmean {
	my ($short, $type) = @_;

	$long = int(($short * 1.618) + 0.5);

	$width = $short;
	$height = $long;

	if ($type == 1) {
		$width = $long;
		$height = $short;
	}

	$img = gimp_image_new($width, $height, RGB);
	$layer = gimp_layer_new($img, $width, $height, RGB_IMAGE, "Layer 1", 100, NORMAL_MODE);

	gimp_image_add_layer($layer, -1);
	gimp_palette_set_background([255, 255, 255]);
	$layer->gimp_edit_fill(BG_IMAGE_FILL);

	return $img;
}

register	"golden_mean",
		"Creates a new image with a ratio according to the Golden Mean",
		"Select shortest side and orientation and I will automagically calculate the long side. As a plug-in companion, see <Image>/Center Guide.",
		"Claes G Lindblad <claesg\@algonet.se>",
		"Claes G Lindblad <claesg\@algonet.se>",
		"990328",
		N_"<Toolbox>/Xtns/Render/Golden Mean...",
		undef,
	[
	[PF_INT32, "short", "Shortest side", 233],
	[PF_RADIO, "type", "Orientation", 0, [Portrait => 0, Landscape => 1]]
	],
	\&goldenmean;

exit main;

