X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Feuler2d.c;fp=hacks%2Feuler2d.c;h=d42a2bbfd16becf622d396a516afeb73dae43c05;hp=f804e427834a19b48499a00cfb1f6b66de8863b4;hb=39809ded547bdbb08207d3e514950425215b4410;hpb=4361b69d3178d7fc98d0388f9a223af6c2651aba diff --git a/hacks/euler2d.c b/hacks/euler2d.c index f804e427..d42a2bbf 100644 --- a/hacks/euler2d.c +++ b/hacks/euler2d.c @@ -51,6 +51,8 @@ static const char sccsid[] = "@(#)euler2d.c 5.00 2000/11/01 xlockmore"; # define SMOOTH_COLORS # define release_euler2d 0 +# define reshape_euler2d 0 +# define euler2d_handle_event 0 # include "xlockmore.h" /* in xscreensaver distribution */ #else /* STANDALONE */ # include "xlock.h" /* in xlockmore distribution */ @@ -91,7 +93,7 @@ ENTRYPOINT ModeSpecOpt euler2d_opts = #ifdef USE_MODULES ModStruct euler2d_description = { "euler2d", "init_euler2d", "draw_euler2d", (char *) NULL, - "refresh_euler2d", "init_euler2d", (char *) NULL, &euler2d_opts, + "refresh_euler2d", "init_euler2d", "free_euler2d", &euler2d_opts, 1000, 1024, 3000, 1, 64, 1.0, "", "Simulates 2D incompressible invisid fluid.", 0, NULL }; @@ -113,6 +115,7 @@ typedef struct { int height; int count; double xshift,yshift,scale; + double xshift2,yshift2; double radius; int N; @@ -483,7 +486,7 @@ ode_solve(euler2dstruct *sp) #define allocate(p,t,s) if ((p=(t*)malloc(sizeof(t)*s))==NULL)\ {free_euler2d(mi);return;} -static void +ENTRYPOINT void free_euler2d(ModeInfo * mi) { euler2dstruct *sp = &euler2ds[MI_SCREEN(mi)]; @@ -522,7 +525,7 @@ init_euler2d (ModeInfo * mi) delta_t = 0.001; if (power>1.0) delta_t *= pow(0.1,power-1); - MI_INIT (mi, euler2ds, free_euler2d); + MI_INIT (mi, euler2ds); sp = &euler2ds[MI_SCREEN(mi)]; #ifdef HAVE_JWXYZ @@ -534,9 +537,26 @@ init_euler2d (ModeInfo * mi) sp->count = 0; + sp->xshift2 = sp->yshift2 = 0; + sp->width = MI_WIDTH(mi); sp->height = MI_HEIGHT(mi); + if (sp->width > sp->height * 5 || /* window has weird aspect */ + sp->height > sp->width * 5) + { + if (sp->width > sp->height) + { + sp->height = sp->width * 0.8; + sp->yshift2 = -sp->height/2; + } + else + { + sp->width = sp->height * 0.8; + sp->xshift2 = -sp->width/2; + } + } + sp->N = MI_COUNT(mi)+number_of_vortex_points; sp->Nvortex = number_of_vortex_points; @@ -675,6 +695,8 @@ init_euler2d (ModeInfo * mi) else sp->yshift = (low[besti-nr_rotates/2]+high[besti-nr_rotates/2])/2.0*sp->scale+sp->height/2; + sp->xshift += sp->xshift2; + sp->yshift += sp->yshift2; /* Initialize boundary */ @@ -852,31 +874,13 @@ draw_euler2d (ModeInfo * mi) } -ENTRYPOINT void -reshape_euler2d(ModeInfo * mi, int width, int height) -{ - XClearWindow (MI_DISPLAY (mi), MI_WINDOW(mi)); - init_euler2d (mi); -} - +#ifndef STANDALONE ENTRYPOINT void refresh_euler2d (ModeInfo * mi) { MI_CLEARWINDOW(mi); } - -ENTRYPOINT Bool -euler2d_handle_event (ModeInfo *mi, XEvent *event) -{ - if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) - { - init_euler2d (mi); - return True; - } - return False; -} - - +#endif XSCREENSAVER_MODULE ("Euler2D", euler2d)