Exemple #1
0
LONG FracBlank( struct Screen *Scr, UWORD Wid, UWORD Hei )
{
	float x = 0, y = 0, xx, yy, a, b, c;
	LONG i, xe, ye, flg_end = OK, mod = ( 1L << Scr->BitMap.Depth ) - 1;
	struct RastPort *Rast = &( Scr->RastPort );
	
	SetRast( Rast, 0 );
	ScreenToFront( Scr );
	
	a = (float)RangeRand( 1000 ) / 10 - 50.0;
	do
		b = (float)RangeRand( 1000 ) / 10 - 50.0;
	while( b == 0.0 );
	c = (float)RangeRand( 1000 ) / 10 - 50.0;
	
	for( i = 0; i < 50000 && flg_end == OK; i++ )
	{
		if(!( i % 50 ))
		{
			ScreenToFront( Scr );
			flg_end = ContinueBlanking();
		}
		
		if( x < 0 )
			xx = y + sqrt( fabs( b * x - c ));
		else
			xx = y - sqrt( fabs( b * x - c ));
		yy = a - x;
		xe = Wid / 2 + (SHORT)x;
		ye = Hei / 2 + (SHORT)y;
		
		if(( xe >= 0 )&&( ye >= 0 )&&( xe < Wid )&&( ye < Hei ))
		{
			SetAPen( Rast, ( ReadPixel( Rast, xe, ye ) + 1 ) % mod + 1 );
			WritePixel( Rast, xe, ye );
		}
		
		x = xx;
		y = yy;
	}

	return flg_end;
}
Exemple #2
0
LONG Dragon( struct Screen *Scr, SHORT Wid, SHORT Hei )
{
	LONG Color = 1, mod = (( 1L << Scr->BitMap.Depth ) - 1 ) * 5;
	LONG i, RetVal = OK, xd, yd;
	float a = PI-(( float )RangeRand( 100 )+10.0)/5000, xx, yy, x = 0, y = 0;
	struct RastPort *RP = &( Scr->RastPort );
	
	SetRast( RP, 0 );
	ScreenToFront( Scr );
	
	for( i = 0; i < 1000000 && RetVal == OK; i++ )
	{
		if(!( i % 100 ))
		{
			RetVal = ContinueBlanking();
			ScreenToFront( Scr );
		}
		
		xx = y - sin( x );
		yy = a - x;
		
		xd = Wid / 2 + (SHORT)( 2.0 * x );
		yd = Hei / 2 + (SHORT)( 2.0 * y );

		Color = ( Color + 1 ) % mod;

		if(( xd >= 0 )&&( yd >= 0 )&&( xd < Wid )&&( yd < Hei ))
		{
			SetAPen( RP, Color/5 + 1 );
			WritePixel( RP, xd, yd );
		}

		x = xx;
		y = yy;
	}

	return RetVal;
}
Exemple #3
0
LONG Blank( PrefObject *Prefs )
{
	LONG ToFrontCount = 0, Wid, Hei, Drops, x, y, r, i, incr, RetVal = OK;
	struct RastPort *Rast;
	struct Screen *Scr;
	struct Window *Wnd;
	LONG d, xs, ys, rs;
	
	Drops = Prefs[0].po_Level;
	
	Scr = OpenScreenTags( 0L, SA_Depth, Prefs[2].po_Depth, SA_Quiet, TRUE,
						 SA_Overscan, OSCAN_STANDARD, SA_Behind, TRUE,
						 SA_DisplayID, Prefs[2].po_ModeID, SA_ShowTitle, FALSE,
						 SA_Title, "Garshnescreen", TAG_DONE );
	if( Scr )
	{
		Wid = Scr->Width;
		Hei = Scr->Height;
		d = min( Wid, Hei );
		xs = 3 * Wid;
		ys = 4 * Hei;
		
		Rast = &( Scr->RastPort );
		SetRast( Rast, 0 );
		
		for( i = 0; i < 4; i++ )
			SetRGB4(&( Scr->ViewPort ), i, 4 * i, 4 * i, 4 * i );
		
		Wnd = BlankMousePointer( Scr );
		ScreenToFront( Scr );
		
		while( RetVal == OK )
		{
			if(!( ++ToFrontCount % 60 ))
				ScreenToFront( Scr );
			
			if(!( ToFrontCount % Drops ))
				SetRast(&( Scr->RastPort ), 0 );
			
			r = RangeRand( d/13 ) + d/25;
			if( Wid > Hei )
				rs = r * xs / ys;
			else
				rs = r * ys / xs;
			x = RangeRand( Wid - 2*rs ) + rs;
			y = RangeRand( Hei - 2*rs ) + rs;
			
			incr = max( Wid/160, 1 );

			for( i = 0; i < r; i += incr )
			{
				WaitTOF();
				SetAPen( &Scr->RastPort,
						( ULONG )RangeRand(( 1L << Prefs[2].po_Depth ) - 1 )
						+ 1 );
				if( Wid > Hei )
				{
					DrawEllipse(&( Scr->RastPort ), x, y, i * xs / ys, i );
					if( i )
					{
						SetAPen(&( Scr->RastPort ), 0 );
						DrawEllipse(&( Scr->RastPort ), x, y,
									xs * ( i - incr ) / ys, i - incr );
					}
				}
				else
				{
					DrawEllipse(&( Scr->RastPort ), x, y, i, ys * i / xs );
					if( i )
					{
						SetAPen(&( Scr->RastPort ), 0 );
						DrawEllipse(&( Scr->RastPort ), x, y, i - incr,
									( i - incr ) * ys / xs );
					}
				}

			}
			
			RetVal = ContinueBlanking();
		}
		UnblankMousePointer( Wnd );
	}
	else
		RetVal = FAILED;
	
	if( Scr )
		CloseScreen( Scr );
	
	return RetVal;
}
Exemple #4
0
LONG Blank( PrefObject *Prefs )
{
	struct Screen *LScr;
	struct Window *Wnd;
	LONG RetVal = OK,i,goatFlag = 0, ToFrontCount = 0;
	
	if (Prefs[SCREEN].po_Active )
		LScr = cloneTopScreen( FALSE, TRUE );
	else
		LScr = OpenScreenTags( 0l, SA_DisplayID, Prefs[MODE].po_ModeID,
							  SA_Depth, 2, SA_Overscan, OSCAN_STANDARD,
							  SA_ShowTitle, FALSE, SA_Title, "Garshnescreen",
							  SA_Quiet, TRUE, SA_Behind, TRUE, TAG_DONE );
	if( LScr )
	{
		if( GarshnelibBase->lib_Version < 39 || !Prefs[SCREEN].po_Active )
		{
			SetRGB4(&(LScr->ViewPort),0,0x0,0x0,0x0);
			SetRGB4(&(LScr->ViewPort),1,0x8,0x8,0x8);
			SetRGB4(&(LScr->ViewPort),2,0x7,0x4,0x2);
			SetRGB4(&(LScr->ViewPort),3,0x0,0xa,0x0);
			backgroundClr = 0;
			grassClr = GRASS;
			herderClr = HERDER;
			goatClr = GOAT;
		}
		else
		{
			backgroundClr = FindColor( LScr->ViewPort.ColorMap, 0, 0, 0, -1 );
			grassClr = FindColor( LScr->ViewPort.ColorMap, 0, 0x9L<<28, 0,
								 -1 );
			goatClr = FindColor( LScr->ViewPort.ColorMap, 0xAL<<28, 0xAL<<28,
								0xAL<<28, -1 );
			herderClr = FindColor( LScr->ViewPort.ColorMap, 0xBL<<28, 0x2L<<28,
								  0x4L<<28, -1 );
		}
	
		numGoats = Prefs[GOATS].po_Level;
		numHerders = Prefs[HERDERS].po_Level;
		reproduction = Prefs[REPRO].po_Level;
		Width = LScr->Width;
		Height = LScr->Height;
		
		for (i=0;i<numHerders;++i)
			herderQ[i] = 0;
		herderQ[0] = 1;
		herders[0].x = Width/2;
		herders[0].y = Height/2;
		for (i=0;i<numGoats;++i)
			goatQ[i] = 0;
		
		Wnd = BlankMousePointer( LScr );
		ScreenToFront( LScr );
		i = 0;
		while( RetVal == OK )
		{
			WaitTOF();

			if(!( ++ToFrontCount % 60 ))
				ScreenToFront( LScr );
			
			if( !Prefs[DELAY].po_Level ||
			   !( ToFrontCount % Prefs[DELAY].po_Level ))
			{
				myBlank( LScr, LScr->Width, LScr->Height );
				if (!goatFlag && i == 20)
				{
					goatQ[0] = 1;
					goats[0].x = Width/2;
					goats[0].y = Height/2;
					grassEaten[0] = 0;
					goatFlag = 1;
				}
				else
					++i;
			}

			RetVal = ContinueBlanking();
		}

		UnblankMousePointer( Wnd );
		CloseScreen( LScr );
	}
	else
		RetVal = FAILED;
	
	return RetVal;
}
Exemple #5
0
LONG Blank (PrefObject *Prefs)
{
	LONG Count, ScrToFrontCnt = 0, RetVal = TRUE, Size;
	LONG	Number;
	struct Screen *PatchScreen;

	PatchScreen = OpenScreenTags (NULL,
					SA_Depth, 3,
					SA_Overscan, OSCAN_STANDARD,
					SA_DisplayID, Prefs[MODE].po_ModeID,
					SA_Quiet, TRUE,
					SA_Behind, TRUE,
					TAG_DONE);
	Size = sizeof (LINET) * Prefs[NO_LINES].po_Active;
	Line = (LINET *) AllocVec (Size, 0L);

	if (PatchScreen && Line)
	{
		HalfWidth = PatchScreen->Width / 2;
		HalfHeight = PatchScreen->Height / 2;
		if (HalfWidth < HalfHeight)
		{
			Size = HalfWidth - 1;
		}
		else
		{
			Size = HalfHeight - 1;
		}

		SetRGB4 (&(PatchScreen->ViewPort), 0, 0, 0, 0);
		SetRast (&(PatchScreen->RastPort), 0);
		Colors = (1L << PatchScreen->RastPort.BitMap->Depth) - 1;
		ColorTable = RainbowPalette (PatchScreen, 0L, 1L, 0L);
		ScreenToFront (PatchScreen);
		Count = Prefs[SPEED].po_Level + 1;

		for (Number = 0 ; Number < Prefs[NO_LINES].po_Active ; Number++)
		{
			DrawLine (&(PatchScreen->RastPort), Prefs, Size, Number);
		}
		Number = 0;
		while (RetVal == TRUE)
		{
			WaitTOF();

			if (!(ScrToFrontCnt++ % 60))
			{
				ScreenToFront (PatchScreen);
			}

			if (++Count > MAX_SPEED)
			{
				Count = Prefs[SPEED].po_Level + 1;
				Number++;
				if (Number == Prefs[NO_LINES].po_Active)
				{
					Number = 0;
				}
				KillLine (&(PatchScreen->RastPort), Prefs, Number);
				DrawLine (&(PatchScreen->RastPort), Prefs, Size, Number);
			}
			RetVal = ContinueBlanking();
		}
		CloseScreen (PatchScreen);
	}
	else
	{
		RetVal = FALSE;
	}

	return RetVal;
}
Exemple #6
0
LONG Blank( PrefObject *Prefs )
{
	LONG delay_rate, i, j, counter = 0, RetVal = OK;
	struct RastPort *Rast;
	struct Screen *FTScr;
	struct Window *FTWin;
	struct Window *Wnd;
	
	NumToasters = Prefs[OBJECTS].po_Level;
	delay_rate = 11 - Prefs[SPEED].po_Level;
	
	Toasters = AllocVec( sizeof( Toaster ) * NumToasters, MEMF_CLEAR );
	FTScr = OpenScreenTags( NULL, SA_DisplayID, Prefs[MODE].po_ModeID,
						   SA_Depth, 4, SA_Overscan, OSCAN_STANDARD,
						   SA_Type, CUSTOMSCREEN, SA_Quiet, TRUE,
						   SA_Behind, TRUE, TAG_DONE );
	if( Toasters && FTScr )
	{
		for( i = 0; i < 48; i += 3 )
			if( GfxBase->lib_Version < 39 )
				SetRGB4(&( FTScr->ViewPort ), i/3, ( cmap[i] * 16 ) / 256,
						( cmap[i+1] * 16 ) / 256, ( cmap[i+2] * 16 ) / 256 );
			else
				SetRGB32(&( FTScr->ViewPort ), i/3, cmap[i]<<24, cmap[i+1]<<24,
						 cmap[i+2]<<24 );
		FTWin = OpenWindowTags( 0L, WA_Width, FTScr->Width, WA_Height,
							   FTScr->Height, WA_IDCMP, 0L, WA_Flags,
							   WFLG_SIMPLE_REFRESH|WFLG_BORDERLESS,
							   WA_CustomScreen, FTScr, TAG_DONE );
		if( FTWin )
		{
			Rast = FTWin->RPort;
			SetAPen( Rast, 0 );
			
			for( i = 0; i < NumToasters; i++ )
				if( !FindLaunchPos( i, ( LONG )FTWin->Width,
								   ( LONG )FTWin->Height ))
					Toasters[i].delay = 30;
			
			Wnd = BlankMousePointer( FTScr );
			ScreenToFront( FTScr );
			
			while( RetVal == OK )
			{
				WaitTOF();
				
				if(!( ++counter % 60 ))
					ScreenToFront( FTScr );
				
				if(!( counter % delay_rate ))
				{
					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							Toasters[i].old_x = Toasters[i].x;
							Toasters[i].old_y = Toasters[i].y;
							Toasters[i].x -= Toasters[i].xspeed;
							Toasters[i].y += Toasters[i].yspeed;
							Toasters[i].xcol = -1;
							Toasters[i].ycol = -1;
						}
					}

					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							j = -1;
							while(( j = TestExtent( j+1, i, Toasters[i].x,
												   Toasters[i].y )) >= 0 )
							{
								if( abs( Toasters[j].old_x -
										Toasters[i].old_x ) < IM_WIDBUF )
								{
									if( Toasters[i].y < Toasters[j].y )
										Toasters[i].ycol = j;
									if( Toasters[i].xspeed ==
									   Toasters[j].xspeed )
										Toasters[i].xspeed++;
								}
								else
								{
									if( Toasters[i].x > Toasters[j].x )
										Toasters[i].xcol = j;
									if( Toasters[i].yspeed ==
									   Toasters[j].yspeed )
										Toasters[i].yspeed++;
								}
								if( abs( Toasters[j].old_y -
										Toasters[i].old_y ) < IM_HEIBUF )
								{
									if( Toasters[i].x > Toasters[j].x )
										Toasters[i].xcol = j;
									if( Toasters[i].yspeed ==
									   Toasters[j].yspeed )
										Toasters[i].yspeed++;
								}
							}
						}
					}

					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							Toasters[i].x = Toasters[i].old_x - ActXSpeed( i );
							Toasters[i].y = Toasters[i].old_y + ActYSpeed( i );
						}
					}
					
					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							j = -1;
							while(( j = TestExtent( j+1, i, Toasters[i].x,
												   Toasters[i].y )) >= 0 )
							{
								if( abs( Toasters[j].old_x -
										Toasters[i].old_x ) < IM_WIDBUF )
									if( Toasters[i].x > Toasters[j].x )
										Toasters[i].x = Toasters[i].old_x;
								else
									if( Toasters[i].y < Toasters[j].y )
										Toasters[i].y = Toasters[i].old_y;
								if( abs( Toasters[j].old_y -
										Toasters[i].old_y ) < IM_HEIBUF )
									if( Toasters[i].y < Toasters[j].y )
										Toasters[i].y = Toasters[i].old_y;
							}
						}
					}

					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							Toasters[i].phase =
								( Toasters[i].phase + 1 ) % IMAGEMAX;
							EraseRect( Rast, Toasters[i].x + IM_WIDTH,
									  Toasters[i].old_y, Toasters[i].x +
									  IM_WIDTH + Toasters[i].xspeed,
									  Toasters[i].old_y + IM_HEIGHT );
							EraseRect( Rast, Toasters[i].old_x,
									  Toasters[i].old_y,
									  Toasters[i].old_x + IM_WIDTH,
									  Toasters[i].old_y + Toasters[i].yspeed );
							DrawImage( Rast, img[Toasters[i].phase],
									  Toasters[i].x, Toasters[i].y );
							if(( Toasters[i].x < -IM_WIDTH-1 )||
							   ( Toasters[i].y > FTWin->Height ))
								Toasters[i].delay = RangeRand( 50 );
						}
						else
							if(!( --Toasters[i].delay ))
								Toasters[i].delay =
									FindLaunchPos( i, ( LONG )FTWin->Width,
												  ( LONG )FTWin->Height )
										? 0 : 30;
					}
				}
				RetVal = ContinueBlanking();
			}

			SetSignal( 0L, SIGBREAKF_CTRL_C );
			UnblankMousePointer( Wnd );
			CloseWindow( FTWin );
		}
		else
			RetVal = FAILED;
		CloseScreen( FTScr );
	}
	else
		RetVal = FAILED;
	
	FreeVec( Toasters );

	return RetVal;
}
Exemple #7
0
LONG Blank( PrefObject *Prefs )
{
	LONG ToFrontCount = 0, Wid, Hei, i, x, y, Stars, Speed, RetVal = OK;
	struct RastPort *Rast;
	struct Screen *Scr;
	struct Window *Wnd;
	Coord3D *p;
	Coord2D *p2;
	
	Stars = Prefs[0].po_Level;
	Speed = Prefs[2].po_Level;
	
	Coords = AllocVec( Stars * sizeof( Coord3D ), MEMF_CLEAR );
	OldCoords = AllocVec( Stars * sizeof( Coord2D ), MEMF_CLEAR );
	Scr = OpenScreenTags( 0L, SA_Depth, 2, SA_Overscan, OSCAN_STANDARD,
						 SA_DisplayID, Prefs[4].po_ModeID, SA_Behind, TRUE,
						 SA_Quiet, TRUE, SA_ShowTitle, FALSE, SA_Title,
						 "Garshnescreen", TAG_DONE );

	if( Coords && OldCoords && Scr )
	{
		Wid = Scr->Width;
		Hei = Scr->Height;
		
		Rast = &( Scr->RastPort );
		SetRast( Rast, 0 );
		for( i = 0; i < 4; i++ )
			SetRGB4(&( Scr->ViewPort ), i, 4 * i, 4 * i, 4 * i );
		
		for( i = 0; i < Stars; i++ )
		{
			InitStar( &Coords[i], Speed );
			OldCoords[i].x = 0;
			OldCoords[i].y = 0;
		}
		
		Wnd = BlankMousePointer( Scr );
		ScreenToFront( Scr );
		
		while( RetVal == OK )
		{
			WaitTOF();

			if(!( ++ToFrontCount % 60 ))
				ScreenToFront( Scr );
			
			for( p2 = OldCoords, p = Coords, i = 0;
				i < Stars; i++, p++, p2++ )
			{
				x = p2->x;
				y = p2->y;
				
				SetAPen( Rast, 0 );
				switch( p->z / 200 )
				{
				case 0:
					WritePixel( Rast, x, y+1 );
					WritePixel( Rast, x+1, y+1 );
				case 1:
				case 2:
				case 3:
				case 4:
					WritePixel( Rast, x+1, y );
				default:
					WritePixel( Rast, x, y );
				}

				p->z -= p->speed;
				if( p->z <= -1000 )
					InitStar( p, Speed );
				
				x = Wid/2 + ( 200 * p->x ) / ( p->z + 1000 );
				y = Hei/2 + ( 200 * p->y ) / ( p->z + 1000 );
				
				if(( x < 0 )||( x > Wid-2 )||( y < 0 )||( y > Hei-2 ))
				{
					InitStar( p, Speed );
					p2->x = 0;
					p2->y = 0;
				}
				else
				{
					p2->x = x;
					p2->y = y;
					SetAPen( Rast, 3 );
					/* Warning: This is a little twisted. */
					switch( p->z/200 )
					{
					case 9:
					case 8:
						SetAPen( Rast, 2 );
						break;
					case 0:
						WritePixel( Rast, x, y+1 );
						WritePixel( Rast, x+1, y+1 );
					case 4:
					case 3:
					case 2:
					case 1:
						WritePixel( Rast, x+1, y );
					case 7:
					case 6:
					case 5:
						break;
					default:
						SetAPen( Rast, 1 );
						break;
					}
					WritePixel( Rast, x, y );
				}
			}
			if(!( ToFrontCount % 5 ))
				RetVal = ContinueBlanking();
		}
		UnblankMousePointer( Wnd );
	}
	else
		RetVal = FAILED;

	if( Scr )
		CloseScreen( Scr );
	if( Coords )
		FreeVec( Coords );
	if( OldCoords )
		FreeVec( OldCoords );

	return RetVal;
}
Exemple #8
0
LONG Blank( PrefObject *Prefs )
{
	struct Screen *Scr;
	struct Window *Wnd;
	LONG ToFrontCount = 0, RetVal = OK;
	
	MaxFires = Prefs[NUMBER].po_Level;
	Power = Prefs[POWER].po_Level;
	Radius = Prefs[RADIUS].po_Level;
	
	FireTable = AllocVec( sizeof( struct Fire ) * ( MAX_FIRE + 1 ),
						 MEMF_CLEAR );
	
	if( FireTable )
	{
		Scr = OpenScreenTags( 0L, SA_Depth, Prefs[MODE].po_Depth,
							 SA_Overscan, OSCAN_STANDARD, SA_Quiet, TRUE,
							 SA_DisplayID, Prefs[MODE].po_ModeID,
							 SA_Behind, TRUE, TAG_DONE );
		if( Scr )
		{
			LastFire = &( FireTable[MAX_FIRE] );
			
			Wid = Scr->Width;
			Hei = Scr->Height;
			
			if( Prefs[MODE].po_Depth < 3 )
				setCopperList( Hei, 1, &( Scr->ViewPort ), &custom );
			
			SetRGB4(&( Scr->ViewPort ), 0, 0, 0, 0 );
			SetRGB4(&( Scr->ViewPort ), 1, 0x0F, 0x0F, 0x0F );
			SetRast(&( Scr->RastPort ), 0 );
			
			NumFires = 0;
			Wnd = BlankMousePointer( Scr );
			ScreenToFront( Scr );
			
			while( RetVal == OK )
			{
				WaitTOF();
				IterateFire(&( Scr->RastPort ));
				if(!( ToFrontCount++ % 60 ))
					ScreenToFront( Scr );
				if(!( ToFrontCount % 5 ))
					RetVal = ContinueBlanking();
			}
			
			UnblankMousePointer( Wnd );
			if( Prefs[MODE].po_Depth < 3 )
				clearCopperList( &Scr->ViewPort );
			CloseScreen( Scr );
		}
		else
			RetVal = FAILED;

		FreeVec( FireTable );
	}
	else
		RetVal = FAILED;
	
	return RetVal;
}
Exemple #9
0
LONG Blank( PrefObject *Prefs )
{
	LONG ToFrontCount = 0, Wid, Hei, Drops, x, y, r, i, incr, RetVal = OK;
	struct RastPort *Rast;
	struct Screen *Scr;
	struct Window *Wnd;
	
	Drops = Prefs[0].po_Level;
	
	Scr = OpenScreenTags( 0L, SA_Depth, Prefs[2].po_Depth, SA_Quiet, TRUE,
						 SA_Overscan, OSCAN_STANDARD, SA_Behind, TRUE,
						 SA_DisplayID, Prefs[2].po_ModeID, TAG_DONE );
	if( Scr )
	{
		Wid = Scr->Width;
		Hei = Scr->Height;
		
		Rast = &( Scr->RastPort );
		SetRast( Rast, 0 );
		
		for( i = 0; i < 4; i++ )
			SetRGB4(&( Scr->ViewPort ), i, 4 * i, 4 * i, 4 * i );
		
		Wnd = BlankMousePointer( Scr );
		ScreenToFront( Scr );
		
		while( RetVal == OK )
		{
			if(!( ++ToFrontCount % 60 ))
				ScreenToFront( Scr );
			
			if(!( ToFrontCount % Drops ))
				SetRast(&( Scr->RastPort ), 0 );
			
			r = RangeRand( Wid/13 ) + Wid/25;
			x = RangeRand( Wid - 2*r ) + r;
			y = RangeRand( Hei - 2*r ) + r;
			
			incr = max( Wid/160, 1 );

			for( i = 0; i < r; i += incr )
			{
				WaitTOF();
				SetAPen( &Scr->RastPort,
						( ULONG )RangeRand(( 1L << Prefs[2].po_Depth ) - 1 )
						+ 1 );
				DrawEllipse(&( Scr->RastPort ), x, y, i, i );
				if( i )
				{
					SetAPen(&( Scr->RastPort ), 0 );
					DrawEllipse(&( Scr->RastPort ), x, y, i - incr, i - incr );
				}
			}
			
			RetVal = ContinueBlanking();
		}
		UnblankMousePointer( Wnd );
	}
	else
		RetVal = FAILED;
	
	if( Scr )
		CloseScreen( Scr );
	
	return RetVal;
}
Exemple #10
0
LONG IFS( struct Screen *scr, SHORT width, SHORT height, PrefObject *Prefs )
{
  LONG flg_end = OK;
  int colors = (1L << scr->BitMap.Depth);
    double x,y,			/* the coordinate which gets computed */
           prob;		/* probability for continuing withot Clscr */
    int num,			/* total number of fctns for the current IFS */
        thef;			/* the currently applied function */
    int i,j,k;			/* multi-purpose counters, array indices */
    int wx,wy;			/* window coordinate of current point */
    int tx,ty;			/* # pixels to transpose the Origin (x,y) */

    double aa[FNUM][4],		/* For each f: a 2x2 matrix and */
           vv[FNUM][2],		/*             a transposition vector */
           comp[FNUM],		/* the compression of each function (1/comp[n]
                                 * is the compression of the function) */
           totcomp;		/* sum of all the size factors. The larger this
                                 * is, the longer we should compute */
    double CONTINUEPROBABILITY,CONTPROBDECREASE;
    bool TRANSPOSE,USEPROBABILITY,oncedone;
    int LENGTH,FUNCTIONS;

    struct RastPort *rp = &( scr->RastPort );

    CONTINUEPROBABILITY = ((double)Prefs[PREF_CONTPROB].po_Level)/100.0;
    CONTPROBDECREASE    = ((double)Prefs[PREF_DECREASE].po_Level)/100.0;
    USEPROBABILITY      = !(Prefs[PREF_AREA].po_Level);
    TRANSPOSE           = !(Prefs[PREF_TRANSPOSE].po_Level);
    LENGTH              = Prefs[PREF_ITERATIONS].po_Level;
    FUNCTIONS           = Prefs[PREF_FUNCTIONS].po_Level;
    
    while (1)
      { Move(rp,0,0);
        SetRast(rp,0);
        SetAPen(rp,1);
        ScreenToFront( scr );

        prob = CONTINUEPROBABILITY;
        oncedone = FALSE;
        while (((double)RangeRand(1000))/1000 < prob || !oncedone) {
        oncedone = TRUE;
        prob = prob - CONTPROBDECREASE;
        num = RangeRand(FUNCTIONS-2)+2;
        
        /* Compute the iterated function */
        totcomp = 0;
        { int moverand = RangeRand(4);

          /* select a move factor with the appropriate probability */
          double MOVEFACTOR;
          switch(moverand)
            { case 0: MOVEFACTOR = MOVEFACTORA; break;
              case 1: 
              case 2: MOVEFACTOR = MOVEFACTORB; break;
              case 3: MOVEFACTOR = MOVEFACTORC; break;
              default: MOVEFACTOR = MOVEFACTORB; break; /* should never happen */
            }

          /* compute the functions and their compression */
          for (k=0; k<num; k++)
              { for (i=0; i<2; i++)
                    { vv[k][i] = (FLOATRAND() - 0.5) * MOVEFACTOR;
                    }
                for (i=0; i<4; i++)
                    { aa[k][i] = (FLOATRAND() - 0.5) * SIZEFACTOR;
                    }
                comp[k] = abs(aa[k][0]*aa[k][2]-aa[k][1]*aa[k][3]);
                totcomp = totcomp + comp[k];
              }
        }

        /* and a probability distribution, eg. 
         * 2,3,1,4 -> 0.2, 0.3, 0.1, 0.4 -> 0.2, 0.5, 0.6, 1.0 */
        for (k=0; k<num; k++)
            { comp[k] = comp[k]/totcomp;
              if (k>0)
                 { comp[k] = comp[k]+comp[k-1];
                 }
            }

        comp[num-1] = 1.1; /* just to be safe of numerical errors, we increment
                            * the final probability a bit */

        /* Initialize the transpositions of the origin */
        if (TRANSPOSE)
          {
            tx = (int)(RangeRand(width/2))-width/4;
            ty = (int)(RangeRand(height/2))-height/4;
          }
        else
          { tx = ty = 0;
          }


        /* set the color for the function */
        SetAPen(rp,(int)(RangeRand(colors-1)+1));

        /* and now: compute the IFS. We do this using several iterations
         * instead of just one big step. This gives a picture which looks
         * a bit more structured. */
        for (i=0; i<(int)(LENGTH*totcomp); i++)
            { x=y=0;
              for (j=0; j<ITER; j++)
                  { double xx;

                    /* Find a function to use */
                    if (USEPROBABILITY)
                       { double p;
                         p = FLOATRAND();
                         thef = 0;
                         while (comp[thef] < p)
                           { thef++;
                           }
                       }
                    else
                       { thef = RangeRand(num);
                       }

                    /* compute (x,y) = (x,y)*aa + vv */
                    xx = (x*aa[thef][0]+y*aa[thef][1])+vv[thef][0];
                    y = (x*aa[thef][2]+y*aa[thef][3])+vv[thef][1];
                    x = xx;
                    
                    /* Convert it to a window coordinate and plot it */
                    wx = WINCO(x,width);
                    wy = WINCO(y,height);
                   
                    /* And transpose it, if necessary */
		    wx = wx + tx;
		    wy = wy + ty;
		    
		    if (wx > 0 && wx < width && wy > 0 && wy < height)
                       WritePixel(rp,wx,wy);
                  }
              ScreenToFront( scr );
              flg_end = ContinueBlanking();
              if (flg_end != OK)
		{ return flg_end;
		}
            }
        }
      }
    return flg_end;
}