static PyObject* osl_drawGradientRect(PyObject *self, PyObject *args, PyObject *kwargs) { int x1, y1, x2, y2; unsigned long c1, c2, c3, c4; if (!PyArg_ParseTuple(args, "iiiikkkk:drawGradientRect", &x1, &y1, &x2, &y2, &c1, &c2, &c3, &c4)) return NULL; oslDrawGradientRect(x1, y1, x2, y2, c1, c2, c3, c4); Py_INCREF(Py_None); return Py_None; }
/* 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; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Main: /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int main(){ int skip = 0; SetupCallbacks(); initOSLib(); oslIntraFontInit(INTRAFONT_CACHE_MED); //Loads image: OSL_IMAGE *bkg = oslLoadImageFilePNG("bkg.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888); OSL_IMAGE *rect_01 = oslLoadImageFilePNG("rect_01.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888); //Load fonts: OSL_FONT *pgfFont = oslLoadFontFile("flash0:/font/ltn0.pgf"); oslIntraFontSetStyle(pgfFont, 0.5, RGBA(255,255,255,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT); OSL_FONT *oftFont = oslLoadFontFile("font.oft"); oslSetTextColor(RGBA(255,255,255,255)); oslSetBkColor(RGBA(0,0,0,0)); while(runningFlag && !osl_quit){ if (!skip){ oslStartDrawing(); oslDrawImageXY(bkg, 0, 0); oslDrawImageXY(rect_01, 50, 50); oslSetFont(pgfFont); oslDrawString(55, 55, "pgf on alpha image"); oslSetFont(oftFont); oslDrawString(55, 70, "oft on alpha image"); oslDrawFillRect(30, 150, 200, 250, RGB(150, 150, 150)); oslSetFont(pgfFont); oslDrawString(35, 155, "pgf on rect"); oslSetFont(oftFont); oslDrawString(35, 170, "oft on rect"); oslDrawFillRect(300, 150, 400, 250, RGB(100, 100, 100)); oslSetFont(pgfFont); oslDrawString(305, 155, "pgf on rect"); oslSetFont(oftFont); oslDrawString(305, 170, "oft on rect"); oslDrawGradientRect(300, 20, 430, 120, RGBA(100, 100, 100, 100),RGBA(100, 100, 100, 100), RGBA(200, 200, 200, 100), RGBA(200, 200, 200, 100)); oslSetFont(pgfFont); oslDrawString(305, 25, "pgf on gradient rect"); oslSetFont(oftFont); oslDrawString(305, 40, "oft on gradient rect"); oslEndDrawing(); } oslEndFrame(); skip = oslSyncFrame(); } //Quit OSL: oslEndGfx(); oslQuit(); sceKernelExitGame(); return 0; }