Bloom: Support sizes

This commit is contained in:
Bill Kendrick 2023-04-22 10:58:42 -07:00
parent 03e0bf65b0
commit f5a340a152
2 changed files with 26 additions and 7 deletions

View file

@ -6,7 +6,7 @@ Copyright (c) 2002-2023
Various contributors (see below, and AUTHORS.txt) Various contributors (see below, and AUTHORS.txt)
https://tuxpaint.org/ https://tuxpaint.org/
2023.April.20 (0.9.30) 2023.April.22 (0.9.30)
* Improvements to Stamp tool: * Improvements to Stamp tool:
--------------------------- ---------------------------
* Avoid playing English descriptive sound for a stamp * Avoid playing English descriptive sound for a stamp
@ -35,13 +35,14 @@ https://tuxpaint.org/
Bill Kendrick <bill@newbreedsoftware.com> Bill Kendrick <bill@newbreedsoftware.com>
* Various Magic tools now support sizing options: * Various Magic tools now support sizing options:
+ Kaleidoscope, Symmetric L/R & U/D, Pattern, Tiles + Bloom
+ Blur + Blur
+ Bricks + Bricks
+ Clone + Clone
+ Confetti + Confetti
+ Foam + Foam
+ Googly Eyes + Googly Eyes
+ Kaleidoscope, Symmetric L/R & U/D, Pattern, Tiles
+ Light + Light
+ Metal Paint + Metal Paint
+ Negative & Opposite + Negative & Opposite

View file

@ -3,7 +3,7 @@
Applies a "bloom" effect to the image. Applies a "bloom" effect to the image.
(https://en.wikipedia.org/wiki/Bloom_(shader_effect)) (https://en.wikipedia.org/wiki/Bloom_(shader_effect))
Last updated: February 27, 2023 Last updated: April 22, 2023
*/ */
#include <stdio.h> #include <stdio.h>
@ -16,13 +16,13 @@
#include "SDL_mixer.h" #include "SDL_mixer.h"
/* Radius of the painting tool */ /* Radius of the painting tool */
#define BLOOM_PAINT_RADIUS 24 static int BLOOM_PAINT_RADIUS = 24;
/* Overall weight to apply the sampled pixels */ /* Overall weight to apply the sampled pixels */
#define BLOOM_WEIGHT_CONST 0.05 #define BLOOM_WEIGHT_CONST 0.05
/* Length of spike shape */ /* Length of spike shape */
#define BLOOM_SPIKE_LENGTH 5 static int BLOOM_SPIKE_LENGTH = 5;
/* From https://www.shadertoy.com/view/lsXGWn */ /* From https://www.shadertoy.com/view/lsXGWn */
//float sample_weights[9] = { //float sample_weights[9] = {
@ -42,7 +42,7 @@ Uint8 * bloom_mask = NULL;
int bloom_scale; int bloom_scale;
Uint32 bloom_api_version(void); Uint32 bloom_api_version(void);
int bloom_init(magic_api * api); int bloom_init(magic_api * api, Uint32 disabled_features);
int bloom_get_tool_count(magic_api * api); int bloom_get_tool_count(magic_api * api);
SDL_Surface *bloom_get_icon(magic_api * api, int which); SDL_Surface *bloom_get_icon(magic_api * api, int which);
char *bloom_get_name(magic_api * api, int which); char *bloom_get_name(magic_api * api, int which);
@ -80,7 +80,7 @@ Uint32 bloom_api_version(void)
return (TP_MAGIC_API_VERSION); return (TP_MAGIC_API_VERSION);
} }
int bloom_init(magic_api * api) int bloom_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
{ {
char fname[1024]; char fname[1024];
@ -381,3 +381,21 @@ float luminance(float r, float g, float b) {
float change_luminance(float c_in, float l_in, float l_out) { float change_luminance(float c_in, float l_in, float l_out) {
return c_in * (l_out / l_in); return c_in * (l_out / l_in);
} }
Uint8 bloom_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
{
return 4;
}
Uint8 bloom_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
{
return 2;
}
void bloom_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
BLOOM_PAINT_RADIUS = size * 12;
BLOOM_SPIKE_LENGTH = sqrt(BLOOM_PAINT_RADIUS + 1);
bloom_scale = sqrt(2 * (BLOOM_PAINT_RADIUS * BLOOM_PAINT_RADIUS));
}