summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/pixbounce/pixbounce.c298
1 files changed, 142 insertions, 156 deletions
diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c
index b8b2572..443f050 100644
--- a/src/modules/pixbounce/pixbounce.c
+++ b/src/modules/pixbounce/pixbounce.c
@@ -5,149 +5,147 @@
#include "til.h"
#include "draw.h"
-/* Copyright (C) 2018-19 Philip J. Freeman <elektron@halo.nu> */
+/* Copyright (C) 2018-22 Philip J. Freeman <elektron@halo.nu> */
-int pix_width = 16;
-int pix_height = 16;
-int num_pix = 6;
+typedef struct pixbounce_pixmap_t {
+ int width, height;
+ int pix_map[16*16];
+} pixbounce_pixmap_t;
-char pix_map[][16*16] = {
+int num_pix = 6;
- {
- 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0,
- 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
- 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0,
- 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0,
- 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0,
- 0, 0, 1, 0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, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
+ },
},
};
typedef struct pixbounce_context_t {
- int x, y;
- int x_dir, y_dir;
- int pix_num;
- uint32_t color;
- int multiplier;
+ int x, y;
+ int x_dir, y_dir;
+ pixbounce_pixmap_t *pix;
+ uint32_t color;
+ int multiplier;
} pixbounce_context_t;
-/* randomly pick another pixmap from the list, excluding the current one. */
-static int pick_pix(int num_pics, int last_pic)
-{
- int pix_num = last_pic;
-
- while(pix_num == last_pic)
- pix_num = rand() % num_pics;
-
- return pix_num;
-}
-
static uint32_t pick_color()
{
return makergb(rand()%256, rand()%256, rand()%256, 1);
@@ -165,7 +163,7 @@ static void * pixbounce_create_context(unsigned ticks, unsigned n_cpus, til_setu
ctxt->y = -1;
ctxt->x_dir = 0;
ctxt->y_dir = 0;
- ctxt->pix_num = rand() % num_pix;
+ ctxt->pix = &pixbounce_pixmap[rand()%num_pix];
ctxt->color = pick_color();
ctxt->multiplier = 1;
@@ -185,15 +183,15 @@ static void pixbounce_render_fragment(void *context, unsigned ticks, unsigned cp
int width = fragment->width, height = fragment->height;
/* check for very small fragment */
- if(pix_width*2>width||pix_height*2>height)
+ if(ctxt->pix->width*2>width||ctxt->pix->height*2>height)
return;
if(ctxt->x == -1) {
int multiplier_x, multiplier_y;
/* calculate multiplyer for the pixmap */
- multiplier_x = width / pix_width;
- multiplier_y = height / pix_height;
+ multiplier_x = width / ctxt->pix->width;
+ multiplier_y = height / ctxt->pix->height;
if(multiplier_x>=multiplier_y) {
ctxt->multiplier = multiplier_y * (rand()%55 + 22 )/ 100;
@@ -202,10 +200,10 @@ static void pixbounce_render_fragment(void *context, unsigned ticks, unsigned cp
}
/* randomly initialize location and direction of pixmap */
- ctxt->x = rand() % (width - pix_width * ctxt->multiplier) + 1;
- ctxt->y = rand() % (height - pix_height * ctxt->multiplier) + 1;
- ctxt->x_dir = (rand() % 3) - 1;
- ctxt->y_dir = (rand() % 3) - 1;
+ ctxt->x = rand() % (width - ctxt->pix->width * ctxt->multiplier) + 1;
+ ctxt->y = rand() % (height - ctxt->pix->height * ctxt->multiplier) + 1;
+ ctxt->x_dir = (rand() % 7) - 3;
+ ctxt->y_dir = (rand() % 7) - 3;
}
@@ -213,10 +211,10 @@ static void pixbounce_render_fragment(void *context, unsigned ticks, unsigned cp
til_fb_fragment_clear(fragment);
/* translate pixmap to multiplier size and draw it to the fragment */
- for(int cursor_y=0; cursor_y < pix_height*ctxt->multiplier; cursor_y++) {
- for(int cursor_x=0; cursor_x < pix_width*ctxt->multiplier; cursor_x++) {
- int pix_offset = ((cursor_y/ctxt->multiplier)*pix_width) + (cursor_x/ctxt->multiplier);
- if(pix_map[ctxt->pix_num][pix_offset] == 0) continue;
+ for(int cursor_y=0; cursor_y < ctxt->pix->height*ctxt->multiplier; cursor_y++) {
+ for(int cursor_x=0; cursor_x < ctxt->pix->width*ctxt->multiplier; cursor_x++) {
+ int pix_offset = ((cursor_y/ctxt->multiplier)*ctxt->pix->width) + (cursor_x/ctxt->multiplier);
+ if(ctxt->pix->pix_map[pix_offset] == 0) continue;
til_fb_fragment_put_pixel_unchecked(
fragment, TIL_FB_DRAW_FLAG_TEXTURABLE, ctxt->x+cursor_x, ctxt->y+cursor_y,
ctxt->color
@@ -225,24 +223,12 @@ static void pixbounce_render_fragment(void *context, unsigned ticks, unsigned cp
}
/* update pixmap location */
- if(ctxt->x+ctxt->x_dir < 0) {
- ctxt->x_dir = 1;
- ctxt->pix_num = pick_pix(num_pix, ctxt->pix_num);
- ctxt->color = pick_color();
- }
- if((ctxt->x+(pix_width*ctxt->multiplier))+ctxt->x_dir > width) {
- ctxt->x_dir = -1;
- ctxt->pix_num = pick_pix(num_pix, ctxt->pix_num);
- ctxt->color = pick_color();
- }
- if(ctxt->y+ctxt->y_dir < 0) {
- ctxt->y_dir = 1;
- ctxt->pix_num = pick_pix(num_pix, ctxt->pix_num);
+ if(ctxt->x+ctxt->x_dir < 0 || ctxt->x+ctxt->pix->width*ctxt->multiplier+ctxt->x_dir > width) {
+ ctxt->x_dir = ctxt->x_dir * -1;
ctxt->color = pick_color();
}
- if((ctxt->y+(pix_height*ctxt->multiplier))+ctxt->y_dir > height) {
- ctxt->y_dir = -1;
- ctxt->pix_num = pick_pix(num_pix, ctxt->pix_num);
+ if(ctxt->y+ctxt->y_dir < 0 || ctxt->y+ctxt->pix->height*ctxt->multiplier+ctxt->y_dir > height) {
+ ctxt->y_dir = ctxt->y_dir * -1;
ctxt->color = pick_color();
}
ctxt->x = ctxt->x+ctxt->x_dir;
© All Rights Reserved