{
}
-#define PACK_RGB16(r, g, b) \
- (((((r) >> 3) & 0x1f) << 11) | ((((g) >> 2) & 0x3f) << 5) | (((b) >> 3) & 0x1f))
-
static void draw(void)
{
int i, j;
}
}
}
+
+
+/* TODO bound blur rad to image size to avoid inner loop conditionals */
+/* TODO make version with pow2 (rad*2+1) to avoid div with count everywhere */
+void blur_grey_horiz(uint16_t *dest, uint16_t *src, int xsz, int ysz, int rad)
+{
+ int i, j;
+
+ for(i=0; i<ysz; i++) {
+ int sum = src[0] * (rad + 1);
+ int count = rad * 2 + 1;
+ uint16_t lastpix = src[xsz - 1];
+
+ /* add up the contributions for the -1 pixel */
+ for(j=0; j<rad; j++) {
+ sum += src[j];
+ }
+
+ /* first part adding src[rad] and subtracting src[0] */
+ for(j=0; j<rad; j++) {
+ sum += src[rad] - src[0];
+ ++src;
+ *dest++ = sum / count;
+ }
+
+ /* middle part adding src[rad] and subtracting src[-(rad+1)] */
+ for(j=0; j<xsz - rad; j++) {
+ sum += src[rad] - src[-(rad + 1)];
+ ++src;
+ *dest++ = sum / count;
+ }
+
+ /* last part adding lastpix and subtracting src[-(rad+1)] */
+ for(j=0; j<rad; j++) {
+ sum += lastpix - src[-(rad + 1)];
+ ++src;
+ *dest++ = sum / count;
+ }
+ }
+}
+
+void blur_grey_vert(uint16_t *dest, uint16_t *src, int xsz, int ysz, int radius)
+{
+}
#ifndef GFXUTIL_H_
#define GFXUTIL_H_
+#include "inttypes.h"
+
#define PACK_RGB16(r, g, b) \
- (((((r) >> 3) & 0x1f) << 11) | ((((g) >> 2) & 0x3f) << 5) | (((b) >> 3) & 0x1f))
+ (((((uint16_t)(r) >> 3) & 0x1f) << 11) | \
+ ((((uint16_t)(g) >> 2) & 0x3f) << 5) | \
+ (((uint16_t)(b) >> 3) & 0x1f))
#define UNPACK_R16(c) (((c) >> 8) & 0xf8)
#define UNPACK_G16(c) (((c) >> 3) & 0xfc)
int clip_line(int *x0, int *y0, int *x1, int *y1, int xmin, int ymin, int xmax, int ymax);
void draw_line(int x0, int y0, int x1, int y1, unsigned short color);
+void blur_grey_horiz(uint16_t *dest, uint16_t *src, int xsz, int ysz, int radius);
+void blur_grey_vert(uint16_t *dest, uint16_t *src, int xsz, int ysz, int radius);
+
#endif /* GFXUTIL_H_ */
struct particle {
float x, y, z;
float vx, vy, vz; /* velocity */
- float r, g, b;
+ int r, g, b;
float life;
};
p->x = (float)x / (float)xsz - 0.5;
p->y = -(float)y / (float)xsz + 0.5 / aspect;
p->z = ((float)i / (float)num * 2.0 - 1.0) * 0.005;
- p->r = p->g = p->b = 0.9;
+ p->r = 0;
+ p->g = 0x1f;
+ p->b = 255;
p->vx = p->vy = p->vz = 0.0f;
p->life = MAX_LIFE;
++p;
v->y = p->y;
v->z = p->z;
v->w = 1.0f;
- v->r = v->g = v->b = 200;
+ v->r = p->r;
+ v->g = p->g;
+ v->b = p->b;
v->a = cround64(p->life * 255.0 / MAX_LIFE);
++v;