intentando afinar el rotozoomer

This commit is contained in:
Gabriel Lorenzo 2003-06-02 22:04:57 +00:00
parent d4a12a746e
commit 9634853c67
5 changed files with 27 additions and 19 deletions

View file

@ -578,13 +578,16 @@ void first_load(FUNCTION_PARAMS)
* y se encarga de meter un registro en la pila de bliteos, permitiendo especificar * y se encarga de meter un registro en la pila de bliteos, permitiendo especificar
* ciertos parámetros describiendo cómo debe dibujarse el gráfico, incluyendo Z, * ciertos parámetros describiendo cómo debe dibujarse el gráfico, incluyendo Z,
* transparencia, etc. * transparencia, etc.
* Esta función no se encarga de discernir si el gráfico esta dentro o fuera de * La función hace "clipping" al gráfico automáticamente según la región que se le
* la región o pantalla, eso se debe calcular antes y pasarle la información * indique.
* resultante a Dibuja().
* @param src Superficie donde se encuentra el gráfico a dibujar * @param src Superficie donde se encuentra el gráfico a dibujar
* @param srcrect Región del gráfico que queremos dibujar * @param x Coordenada X destino
* @param dstrect Región de la pantalla en la que debe aparecer el gráfico * @param y Coordenada Y destino
* @param cx Y del centro del gráfico (relativo al mismo)
* @param cy X del centro del gráfico
* @param region Región de pantalla en la que se dibujará
* @param z Profundidad del gráfico, permite que pueda dibujarse delante o detrás de otros gráficos * @param z Profundidad del gráfico, permite que pueda dibujarse delante o detrás de otros gráficos
* @param flags Flags de espejado horizontal(1)/vertical(2) (sólo se tendrán en cuenta estos dos bits)
* @param trans Transparencia del gráfico (0..255) * @param trans Transparencia del gráfico (0..255)
* @param size Tamaño (en porcentaje) al que debe escalarse el gráfico, 100% es el tamaño original * @param size Tamaño (en porcentaje) al que debe escalarse el gráfico, 100% es el tamaño original
* @param angle Ángulo (en milésimas de grado) para rotar el gráfico. (0 = sin rotación) * @param angle Ángulo (en milésimas de grado) para rotar el gráfico. (0 = sin rotación)
@ -611,7 +614,7 @@ int Dibuja(SDL_Surface *src,int x,int y,int cx,int cy,int region,int z,int flags
zoom=size*0.01f; zoom=size*0.01f;
angulo=angle/1000; angulo=(angle%360000)/1000;
if(flags&3) { if(flags&3) {
temp=SDL_CreateRGBSurface(src->flags,src->w,src->h,src->format->BitsPerPixel,0,0,0,0); temp=SDL_CreateRGBSurface(src->flags,src->w,src->h,src->format->BitsPerPixel,0,0,0,0);
@ -646,9 +649,9 @@ int Dibuja(SDL_Surface *src,int x,int y,int cx,int cy,int region,int z,int flags
if(temp!=src) if(temp!=src)
SDL_FreeSurface(temp); SDL_FreeSurface(temp);
/* /*!
* Pequeño hack para arreglar transparency * Pequeño hack para arreglar transparency
* TODO: Debería limpiarse y revisarse un poco :P * \todo Debería limpiarse y revisarse un poco :P
*/ */
if(blits[last_blit].src->flags & SDL_SRCALPHA) { if(blits[last_blit].src->flags & SDL_SRCALPHA) {
for(i=0;i<blits[last_blit].src->h*blits[last_blit].src->w*blits[last_blit].src->format->BytesPerPixel;i+=blits[last_blit].src->format->BytesPerPixel) { for(i=0;i<blits[last_blit].src->h*blits[last_blit].src->w*blits[last_blit].src->format->BytesPerPixel;i+=blits[last_blit].src->format->BytesPerPixel) {
@ -660,17 +663,19 @@ int Dibuja(SDL_Surface *src,int x,int y,int cx,int cy,int region,int z,int flags
SDL_SetAlpha(blits[last_blit].src,SDL_SRCALPHA,trans); SDL_SetAlpha(blits[last_blit].src,SDL_SRCALPHA,trans);
} }
#define redondea(x) (int)(floor(x)+(((x)-(int)(x))<.5?0:1))
if(size!=100) { if(size!=100) {
if(angle!=0) if(angle!=0)
i=j=(int)(sqrt(cx*cx+cy*cy)*zoom+1); i=j=(sqrt(cx*cx+cy*cy)*zoom+1);
else { else {
i=cx*zoom; i=(int)(cx*zoom);
j=cy*zoom; j=(int)(cy*zoom);
} }
} }
else { else {
if(angle!=0) if(angle!=0)
i=j=(int)(sqrt(cx*cx+cy*cy)+1); i=j=ceil(sqrt(cx*cx+cy*cy)+1);
else { else {
i=cx; i=cx;
j=cy; j=cy;

View file

@ -6,8 +6,9 @@ begin
set_mode(320,200,24); set_mode(320,200,24);
graph=load_bmp("hola.bmp"); graph=load_bmp("hola.bmp");
smooth=1; smooth=1;
x=160; x=1600;
y=100; y=1000;
resolution=10;
size=200; size=200;
fuente=load_fnt("system.fnt"); fuente=load_fnt("system.fnt");
write(fuente,160,40,4,"HOLA"); write(fuente,160,40,4,"HOLA");

View file

@ -19,14 +19,16 @@ begin
write_int(1,80,40,0,&mouse.right); write_int(1,80,40,0,&mouse.right);
write_int(1,80,50,0,&mouse.wheelup); write_int(1,80,50,0,&mouse.wheelup);
write_int(1,80,60,0,&mouse.wheeldown); write_int(1,80,60,0,&mouse.wheeldown);
mi_mapa=load_bmp("hola.bmp"); write_int(1,319,199,8,&mouse.angle);
write_int(1,319,189,8,&mouse.size);
mi_mapa=load_bmp("center.bmp");
mouse.graph=mi_mapa; mouse.graph=mi_mapa;
cursor(); cursor();
loop loop
if(key(_q)) mouse.angle-=1000; end if(key(_q)) mouse.angle-=1000; end
if(key(_w)) mouse.angle+=1000; end if(key(_w)) mouse.angle+=1000; end
if(key(_a)) mouse.size+=5; end if(key(_a)) mouse.size+=1; end
if(key(_z)) mouse.size-=5; end if(key(_z)) mouse.size-=1; end
if(key(_e)) mouse.angle=0; end if(key(_e)) mouse.angle=0; end
if(key(_x)) mouse.size=100; end if(key(_x)) mouse.size=100; end
if(key(_s)) smooth=!smooth; end if(key(_s)) smooth=!smooth; end

Binary file not shown.

View file

@ -39,7 +39,7 @@
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="zlib.lib sdlmain.lib sdl.lib" AdditionalDependencies="zlib.lib"
ShowProgress="0" ShowProgress="0"
OutputFile="../../../bin/stub.exe" OutputFile="../../../bin/stub.exe"
LinkIncremental="2" LinkIncremental="2"
@ -50,7 +50,7 @@
GenerateMapFile="TRUE" GenerateMapFile="TRUE"
MapExports="TRUE" MapExports="TRUE"
MapLines="TRUE" MapLines="TRUE"
SubSystem="2" SubSystem="1"
EntryPointSymbol="" EntryPointSymbol=""
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool