예제 #1
0
static PyObject* image_correctHalfBorder(PyImage *self,
                                         PyObject *args,
                                         PyObject *kwargs)
{
    if (!PyArg_ParseTuple(args, ":correctHalfBorder"))
       return NULL;

    oslCorrectImageHalfBorder(self->pImg);

    Py_INCREF(Py_None);
    return Py_None;
}
예제 #2
0
/*
	Affiche le logo OSLib
	Ne cherchez pas à comprendre cette fonction si vous débutez :p
*/
int oslShowSplashScreen1()			{
	OSL_IMAGE *texte, *etoile;
	OSL_IMAGE *fond;
	int skip=0;
	int x, y;
	int angle, nFrame, val;
	float dist;
	int pousNb;
	float pousX[100], pousY[100];
	int i, imgAngle;
	float tblVitPous[8] = {0.2, 0.3, 0.15, 0.2, 0.35, 0.2, 0.15, 0.3};
	int fade = 0;

	//Add these files to the list
	oslAddVirtualFileList((OSL_VIRTUALFILENAME*)__osl_logo_ram_files, oslNumberof(__osl_logo_ram_files));

	texte = oslLoadImageFile("ram:/logo/texte.png", OSL_IN_VRAM | OSL_UNSWIZZLED, OSL_PF_8888);
	if (!texte)
		return 0;

	logoDecalePixels(texte);

	oslStartDrawing();
	oslSetDithering(1);
	oslSetDrawBuffer(texte);
	oslDrawGradientRect(0,0, WIDTH,HEIGHT, RGB(0,0,0), RGB(0,0,128), RGB(0,0,128), RGB(0,0,0));
	oslSetDrawBuffer(OSL_DEFAULT_BUFFER);
	oslEndDrawing();

	oslMoveImageTo(texte, OSL_IN_RAM);
	oslSwizzleImage(texte);

	fond = logoCreeImageFond();
	if (!fond)		{
		oslDeleteImage(texte);
		return 0;
	}

	oslSetTransparentColor(RGB(255,0,254));
	etoile = oslLoadImageFile("ram:/logo/etoile.png", OSL_IN_RAM, OSL_PF_5551);
	if (!etoile)		{
		oslDeleteImage(texte);
		oslDeleteImage(fond);
		return 0;
	}
	oslDisableTransparentColor();

	texte->centerX = texte->sizeX / 2;
	texte->centerY = texte->sizeY / 2;

	angle = 270;
	dist = 160.0f;
	nFrame = 0;
	pousNb=0;
	imgAngle = 78;

	while (!osl_quit)
	{
		if (!skip)			{
			oslStartDrawing();
			logoCreePaletteRotative(fond, 2000-nFrame*8);
			oslDrawImage(fond);
			x = WIDTH/2;
			y = HEIGHT/2;
			if (dist > 0)			{
				x += oslCos(angle, dist);
				y -= oslSin(angle, dist);
				texte->stretchX = texte->sizeX * (1+dist*0.03f);
				texte->stretchY = texte->sizeY * (1+dist*0.03f);
				texte->angle = imgAngle;
			}
			else		{
				texte->stretchX = texte->sizeX;
				texte->stretchY = texte->sizeY;
				texte->angle = 0;
			}
			oslSetBilinearFilter(1);
			//Effet spécial pour le texturage des nuages
			if (nFrame >= 50)		{
				val = (nFrame - 50) * 6;
				if (val > 255)
					val = 255;
				oslSetAlpha(OSL_FX_ALPHA|OSL_FX_COLOR, RGBA(val,val,val,0xff));
			}
			else
				oslSetAlpha(OSL_FX_ALPHA|OSL_FX_COLOR, RGBA(0,0,0,0xff));
			oslDrawImageXY(texte, x, y);

			oslSetImageTileSize(etoile, 0,0, 16,16);
			oslCorrectImageHalfBorder(etoile);
			oslImageSetRotCenter(etoile);
			etoile->angle = 360 - ((nFrame * 3) % 360);
			etoile->stretchX = 16;
			etoile->stretchY = 16;
			oslSetAlpha(OSL_FX_ALPHA|OSL_FX_COLOR, RGBA(0xff,0,0,0xff));
			oslDrawImageXY(etoile, 480-9, 272-9);

			//Dessine l'étoile
			if (nFrame >= 140 && nFrame < 240)			{
				val = nFrame - 140;
				angle = (val * 5) % 360;
				i = nFrame - (240 - 256/12);
				if (val*16 < 255)
					oslSetAlpha(OSL_FX_ALPHA, val*16);
				else if (i > 0)
					oslSetAlpha(OSL_FX_ALPHA, 255-i*12);
				else
					oslSetAlpha(OSL_FX_RGBA, 0);
				etoile->angle = (val * 8) % 360;
				etoile->x = WIDTH/2 + oslCosi(angle, 120);
				etoile->y = HEIGHT/2 - oslSini(angle, 50);
				etoile->stretchX = 16 * 2;
				etoile->stretchY = 16 * 2;
				oslDrawImage(etoile);
				oslResetImageHalfBorder(etoile);
			}

			//Restaure l'environnement
			oslSetBilinearFilter(0);
			//Dessine les poussières
			oslSetAlpha(OSL_FX_ADD, 0xff);
			oslSetImageTileSize(etoile, 0,16, 8,8);
			oslImageSetRotCenter(etoile);
			for (i=0;i<pousNb;i++)
				oslDrawImageSimpleXY(etoile, pousX[i], pousY[i]);

			oslSetAlpha(OSL_FX_RGBA, 0);
//			oslSysBenchmarkDisplay();
			//Fade
			if (nFrame < 32)
				oslDrawFillRect(0,0, WIDTH,HEIGHT, RGBA(0,0,0,255-(nFrame<<3)));
			if (fade > 0)		{
				if (fade >= 31)
					fade = 31;
				oslDrawFillRect(0,0, WIDTH,HEIGHT, RGBA(0,0,0,(fade<<3)));
			}
			oslEndDrawing();
		}
		nFrame++;
		//L'étoile tourne sur le logo
		if (nFrame >= 140 && nFrame < 240)			{
			val = nFrame - 140;
			angle = (val * 5) % 360;
			if (angle >= 200 && angle <= 340)		{
				pousX[pousNb] = WIDTH/2 + oslCos(angle, 120);
				pousY[pousNb] = HEIGHT/2 - oslSin(angle, 50);
				pousNb++;
			}
		}
		if (fade > 0)
			fade++;
		if (nFrame > 290 && fade == 0)
			fade = 1;
		for (i=0;i<pousNb;i++)		{
			pousY[i] += tblVitPous[i%8];
		}

		dist -= 2.0f;
		angle -= 4;
		imgAngle -= 1;
		if (angle < 0)
			angle += 360;
		skip = oslSyncFrameEx(1,4,0);
		//Lecture des touches
		oslReadKeys();
		if ((osl_keys->pressed.value & (OSL_KEYMASK_START|OSL_KEYMASK_CIRCLE|OSL_KEYMASK_CROSS)) && fade == 0)
			fade = 1;
		if (fade >= 32)
			break;
	}
	oslSetAlpha(OSL_FX_RGBA, 0);
	oslDeleteImage(texte);
	oslDeleteImage(fond);
	oslDeleteImage(etoile);

	oslRemoveVirtualFileList((OSL_VIRTUALFILENAME*)__osl_logo_ram_files, oslNumberof(__osl_logo_ram_files));
	return 1;
}