~ubuntu-branches/ubuntu/breezy/xscreensaver/breezy

« back to all changes in this revision

Viewing changes to hacks/helix.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2005-10-11 21:00:42 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20051011210042-u7q6zslgevdxspr3
Tags: 4.21-4ubuntu17
updated pt_BR again, fixed to UTF-8 

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * 1992:      jwz created.
20
20
 */
21
21
 
 
22
/* 25 April 2002: Matthew Strait <straitm@mathcs.carleton.edu> added
 
23
-subdelay option so the drawing process can be watched */
 
24
 
22
25
#include <math.h>
23
26
#include "screenhack.h"
24
27
#include "erase.h"
29
32
static GC draw_gc;
30
33
static unsigned int default_fg_pixel;
31
34
static int sleep_time;
 
35
static int subdelay;
32
36
 
33
37
static void
34
38
init_helix (Display *dpy, Window window)
99
103
      XDrawLine (dpy, window, draw_gc, x1, y1, x2, y2);
100
104
      x2 = xmid + (((double) radius2) * sins [pmod ((angle * factor3), 360)]);
101
105
      y2 = ymid + (((double) radius1) * coss [pmod ((angle * factor4), 360)]);
102
 
 
103
106
      XDrawLine (dpy, window, draw_gc, x1, y1, x2, y2);
104
107
      angle += d_angle;
 
108
 
 
109
      /* if we sleep every time, it's too slow */
 
110
      if(subdelay && i%16 == 0) usleep(subdelay);
 
111
 
105
112
      XFlush (dpy);
106
113
    }
107
114
}
139
146
      if (tmp == 0)     /* Do not want it getting stuck... */
140
147
        tmp = 1;        /* Would not need if floating point */
141
148
      d_angle += dir * tmp;
 
149
 
 
150
      /* this draws faster, so we sleep somewhat more often */
 
151
      if(subdelay && d_angle%4 == 0) usleep(subdelay);
 
152
      
 
153
      /* without this, the subdelay effect is lost */
 
154
      XFlush (dpy);
142
155
    }
143
156
}
144
157
 
287
300
char *defaults [] = {
288
301
  ".background: black",
289
302
  "*delay:      5",
 
303
  "*subdelay:   0",
290
304
  0
291
305
};
292
306
 
293
307
XrmOptionDescRec options [] = {   
294
308
  { "-delay",           ".delay",               XrmoptionSepArg, 0 },
295
 
  { 0 },
 
309
  { "-subdelay",        ".subdelay",            XrmoptionSepArg, 0 },
 
310
  { 0,                  0,                      0,               0 },
296
311
};
297
312
int options_size = (sizeof (options) / sizeof (options[0]));
298
313
 
300
315
screenhack (Display *dpy, Window window)
301
316
{
302
317
  sleep_time = get_integer_resource("delay", "Integer");
 
318
  subdelay = get_integer_resource("subdelay", "Integer");
303
319
  init_helix (dpy, window);
304
320
  while (1)
305
321
    random_helix_or_trig (dpy, window);