[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Extra Subroutine for ColorGamma




What it says. :-)

This is the CoolFade2 subroutine from "main.c", which is basically one of
the options in the test/demo app. This works fine, too.

You'll have to add 3 or 4 routines to @EXPORT or @EXPORT_OK to support
this sub. Other than that, just paste it into test.plx, and let 'er rip.

Users have reported that the fades tend to go pretty fast... well, they
look OK on my 6100/60. :-)

Please, if you fiddle with other subs in the API, and you find a buggy
one, let me know. Thanks.

Arved

sub CoolFade2 {
	my $normal = new_GIHdl();
	my $state1 = new_GIHdl();
	my $state2 = new_GIHdl();
	
	die "Bad start" if StartFading($normal);
	
	HideCursor;
	
	# slow linear halfway to blue (underwater effect?)
	for ($i=0;$i<=128;$i+=2)
	{
		FadeFromGammaToColor( $normal, $blue, $i, 256 );

	}
	
	Wait(20);
	
	# slow linear to greenish
	$state1 = GetMonitorState;
	$state2 = CalcFadeToColor( $normal, $green, 50, 100 );
	
	for ($i=0;$i<=256;$i+=2)
	{
		FadeFromGammaToGamma( $state1, $state2, $i, 256 );
		
	}
	
	Wait(20);
	
	# what the heck, let's go twice through all the colors at
	# exactly half saturation.
	
	foreach $j (0..6, 0..6)
	{
		DisposeGammaRef($state1);
		$state1 = $state2;
		$state2 = CalcFadeToColor( $normal, $roygbiv[$j], 50, 100 );
		
		for ($i=0;$i<=64;$i+=3)
		{
			FadeFromGammaToGamma( $state1, $state2, $i, 64 );
			
		}
	}
		
	# and back to normal
	for ($i=0;$i<=128;$i+=2)
	{
		FadeFromGammaToGamma( $state2, $normal, $i, 128 );
	}
	
	DisposeGammaRef( $state1 );
	DisposeGammaRef( $state2 );

	StopFading( $normal, 1 );

	ShowCursor;
}