From c651046e3f1a8744ae042d669e317ae6632af361 Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Thu, 29 Mar 2018 18:39:37 +0200 Subject: [PATCH] Added canvas_fill(rgba) and a 50% black fill bound to the 'c' key. --- pixelnuke/canvas.c | 8 ++++++++ pixelnuke/canvas.h | 1 + pixelnuke/pixelnuke.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/pixelnuke/canvas.c b/pixelnuke/canvas.c index a9535e8..68e0e1e 100644 --- a/pixelnuke/canvas.c +++ b/pixelnuke/canvas.c @@ -376,6 +376,14 @@ void canvas_set_px(unsigned int x, unsigned int y, uint32_t rgba) { ptr[2] = b; } +void canvas_fill(uint32_t rgba) { + CanvasLayer * layer = canvas_base; + for(int x=0; xsize; x++) + for(int y=0; ysize; y++) + canvas_set_px(x, y, rgba); +} + + void canvas_get_px(unsigned int x, unsigned int y, uint32_t *rgba) { CanvasLayer * layer = canvas_base; GLubyte* ptr = canvas_offset(layer, x, y); diff --git a/pixelnuke/canvas.h b/pixelnuke/canvas.h index 826478a..8a0af57 100644 --- a/pixelnuke/canvas.h +++ b/pixelnuke/canvas.h @@ -15,6 +15,7 @@ void canvas_close(); void canvas_fullscreen(int display); int canvas_get_display(); +void canvas_fill(uint32_t rgba); void canvas_set_px(unsigned int x, unsigned int y, uint32_t rgba); void canvas_get_px(unsigned int x, unsigned int y, uint32_t *rgba); diff --git a/pixelnuke/pixelnuke.c b/pixelnuke/pixelnuke.c index 6bb32f7..af6a5a6 100644 --- a/pixelnuke/pixelnuke.c +++ b/pixelnuke/pixelnuke.c @@ -114,6 +114,8 @@ void px_on_key(int key, int scancode, int mods) { canvas_fullscreen(-1); } else if (key == 301) { // F12 canvas_fullscreen(canvas_get_display() + 1); + } else if (key == 67) { // c + canvas_fill(0x00000088); } else if (key == 81 || key == 256) { // q or ESC canvas_close(); }