The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/app/bin/perl

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

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

register	"triangle",
		"Creates a triangular selection with the diagonal as one of its sides.",
		"Tick appropriate radio buttons.",
		"Claes G Lindblad <claesg\@algonet.se>",
		"Claes G Lindblad <claesg\@algonet.se>",
		"990328",
		N_"<Image>/Select/Triangle...",
		"*",
		[
		[PF_RADIO, "type", "Select position", 0,
			[Upper_left => 0, Lower_left => 1, Upper_right => 2, Lower_right => 3]
		],
		[PF_RADIO, "mode", "Selection mode", 2,
			[Add => 0, Subtract => 1, Replace => 2, Intersect => 3]
		]
		],
	sub {
		my ($img, $layer, $type, $mode) = @_;

		$w = $img->width();
		$h = $img->height();

		if ($type == 0) {
			@lista= [0, 0, $w, 0, 0, $h, 0, 0];
		};
		if ($type == 1) {
			@lista= [0, 0, 0, $h, $w, $h, 0, 0];
		};
		if ($type == 2) {
			@lista= [0, 0, $w, 0, $w, $h, 0, 0];
		};
		if ($type == 3) {
			@lista= [$w, 0, $w, $h, 0, $h, $w, 0];
		};
		$img->free_select(8, @lista, $mode, 0, 0, 0);
	};
exit main;