mirror of https://github.com/9wm/xss.git
Fix some magic color bugs
This commit is contained in:
parent
db76af5ff1
commit
13e3f6e478
47
magic.c
47
magic.c
|
@ -22,26 +22,30 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include "obj.h"
|
#include "obj.h"
|
||||||
|
|
||||||
#define FPS 17
|
#define FPS 17 /* Frames Per Second */
|
||||||
#define TRAILPCT 50
|
#define TRAILPCT 50 /* Percentage of width to cover */
|
||||||
#define MAXDELTAPML 14
|
#define MAXDELTAPML 14 /* Maximum velocity per-mil width */
|
||||||
#define MINDELTAPML 2
|
#define MINDELTAPML 2 /* Minimum verocity per-mil width */
|
||||||
#define COLORDELTA 50
|
#define MINCOLORDELTA 40 /* Minimum color steps per line */
|
||||||
|
#define MAXCOLORDELTA 150 /* Maximum color steps per line */
|
||||||
|
|
||||||
#define nsec (1000000000 / FPS)
|
#define nsec (1000000000 / FPS)
|
||||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
|
|
||||||
#define sum(a, b, v, m) \
|
#define sum(a, b, v, m) \
|
||||||
if (b + v < 0) { \
|
if (b < -v) { \
|
||||||
a = -1 * (b + v); \
|
a = -1 * (b + v); \
|
||||||
v *= -1; \
|
v *= -1; \
|
||||||
} else if (b + v > m) { \
|
} else if (v > m - b) { \
|
||||||
a = (m*2) - (b + v); \
|
a = (m*2) - (b + v); \
|
||||||
v *= -1; \
|
v *= -1; \
|
||||||
} else { \
|
} else { \
|
||||||
a = b + v; \
|
a = b + v; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define randint(x) (random() % (x))
|
||||||
|
#define rand(l, h) (randint(h-l) + l)
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char * const argv[])
|
main(int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
|
@ -129,24 +133,27 @@ main(int argc, char * const argv[])
|
||||||
int u, l;
|
int u, l;
|
||||||
|
|
||||||
u = width * MAXDELTAPML / 1000;
|
u = width * MAXDELTAPML / 1000;
|
||||||
l = width * MINDELTAPML / 1000;
|
l = max(width * MINDELTAPML / 1000, 1);
|
||||||
velocity.x1 = (short)(random() % (u - l)) + l;
|
velocity.x1 = (short)rand(l, u);
|
||||||
velocity.y1 = (short)(random() % (u - l)) + l;
|
velocity.y1 = (short)rand(l, u);
|
||||||
velocity.x2 = (short)(random() % (u - l)) + l;
|
velocity.x2 = (short)rand(l, u);
|
||||||
velocity.y2 = (short)(random() % (u - l)) + l;
|
velocity.y2 = (short)rand(l, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlines = (width * TRAILPCT) / (max(velocity.y1, velocity.y2) * 100);
|
nlines = (width * TRAILPCT) / (max(velocity.y1, velocity.y2) * 100);
|
||||||
lines = (XSegment *)calloc(nlines, sizeof(XSegment));
|
lines = (XSegment *)calloc(nlines, sizeof(XSegment));
|
||||||
|
|
||||||
lines[0].x1 = (short)(random() % width);
|
lines[0].x1 = (short)randint(width);
|
||||||
lines[0].y1 = (short)(random() % height);
|
lines[0].y1 = (short)randint(height);
|
||||||
lines[0].x2 = (short)(random() % width);
|
lines[0].x2 = (short)randint(width);
|
||||||
lines[0].y2 = (short)(random() % height);
|
lines[0].y2 = (short)randint(height);
|
||||||
red = (unsigned short)(random() % 65536);
|
|
||||||
green = (unsigned short)(random() % 65536);
|
red = (unsigned short)randint(65536);
|
||||||
blue = (unsigned short)(random() % 65536);
|
green = (unsigned short)randint(65536);
|
||||||
dred = dgreen = dblue = COLORDELTA;
|
blue = (unsigned short)randint(65536);
|
||||||
|
dred = rand(MINCOLORDELTA, MAXCOLORDELTA);
|
||||||
|
dgreen = rand(MINCOLORDELTA, MAXCOLORDELTA);
|
||||||
|
dblue = rand(MINCOLORDELTA, MAXCOLORDELTA);
|
||||||
|
|
||||||
for (i = 0; ;) {
|
for (i = 0; ;) {
|
||||||
XSegment segments[2];
|
XSegment segments[2];
|
||||||
|
|
Loading…
Reference in New Issue