Define & use NUM_ERASER_SIZES
...everywhere "NUM_ERASERS / 2" was being used
This commit is contained in:
parent
ab722453e8
commit
8e9a51d478
2 changed files with 17 additions and 16 deletions
|
|
@ -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.May.9 (0.9.30)
|
2023.May.10 (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
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
(See COPYING.txt)
|
(See COPYING.txt)
|
||||||
|
|
||||||
June 14, 2002 - May 9, 2023
|
June 14, 2002 - May 10, 2023
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
@ -1969,8 +1969,10 @@ static int brush_counter, brush_frame;
|
||||||
|
|
||||||
#define NUM_ERASERS 16 /* How many sizes of erasers
|
#define NUM_ERASERS 16 /* How many sizes of erasers
|
||||||
(from ERASER_MIN to _MAX as squares, then again
|
(from ERASER_MIN to _MAX as squares, then again
|
||||||
from ERASER_MIN to _MAX as circles; best if a
|
from ERASER_MIN to _MAX as circles;
|
||||||
multiple of 4, since selector is 2 buttons across) */
|
must be a multiple of 2;
|
||||||
|
best if a multiple of 4, since selector is 2 buttons across) */
|
||||||
|
#define NUM_ERASER_SIZES (NUM_ERASERS / 2)
|
||||||
#define ERASER_MIN 5 /* Smaller than 5 will not render as a circle! */
|
#define ERASER_MIN 5 /* Smaller than 5 will not render as a circle! */
|
||||||
#define ERASER_MAX 128
|
#define ERASER_MAX 128
|
||||||
|
|
||||||
|
|
@ -6582,7 +6584,7 @@ static void mainloop(void)
|
||||||
eraser_draw(old_x, old_y, new_x, new_y);
|
eraser_draw(old_x, old_y, new_x, new_y);
|
||||||
|
|
||||||
sz = calc_eraser_size(cur_eraser);
|
sz = calc_eraser_size(cur_eraser);
|
||||||
if (cur_eraser >= NUM_ERASERS / 2)
|
if (cur_eraser >= NUM_ERASER_SIZES)
|
||||||
{
|
{
|
||||||
/* Circle eraser */
|
/* Circle eraser */
|
||||||
circle_xor(new_x, new_y, sz / 2);
|
circle_xor(new_x, new_y, sz / 2);
|
||||||
|
|
@ -6651,16 +6653,16 @@ static void mainloop(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cur_eraser < NUM_ERASERS / 2)
|
if (cur_eraser < NUM_ERASER_SIZES)
|
||||||
{
|
{
|
||||||
w = (ERASER_MIN +
|
w = (ERASER_MIN +
|
||||||
(((NUM_ERASERS / 2) - cur_eraser - 1) * ((ERASER_MAX - ERASER_MIN) / ((NUM_ERASERS / 2) - 1))));
|
((NUM_ERASER_SIZES - cur_eraser - 1) * ((ERASER_MAX - ERASER_MIN) / (NUM_ERASER_SIZES - 1))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
w = (ERASER_MIN +
|
w = (ERASER_MIN +
|
||||||
(((NUM_ERASERS / 2) - (cur_eraser - NUM_ERASERS / 2) - 1) *
|
((NUM_ERASER_SIZES - (cur_eraser - NUM_ERASERS / 2) - 1) *
|
||||||
((ERASER_MAX - ERASER_MIN) / ((NUM_ERASERS / 2) - 1))));
|
((ERASER_MAX - ERASER_MIN) / (NUM_ERASER_SIZES - 1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
h = w;
|
h = w;
|
||||||
|
|
@ -11232,7 +11234,7 @@ static void draw_erasers(void)
|
||||||
{
|
{
|
||||||
/* Square */
|
/* Square */
|
||||||
|
|
||||||
sz = (2 + (((NUM_ERASERS / 2) - 1 - i) * (38 / ((NUM_ERASERS / 2) - 1)))) * button_scale;
|
sz = (2 + ((NUM_ERASER_SIZES - 1 - i) * (38 / (NUM_ERASER_SIZES - 1)))) * button_scale;
|
||||||
|
|
||||||
x = ((i % 2) * button_w) + WINDOW_WIDTH - r_ttoolopt.w + 24 * button_scale - sz / 2;
|
x = ((i % 2) * button_w) + WINDOW_WIDTH - r_ttoolopt.w + 24 * button_scale - sz / 2;
|
||||||
y = ((j / 2) * button_h) + r_ttoolopt.h + 24 * button_scale - sz / 2 + off_y;
|
y = ((j / 2) * button_h) + r_ttoolopt.h + 24 * button_scale - sz / 2 + off_y;
|
||||||
|
|
@ -11269,7 +11271,7 @@ static void draw_erasers(void)
|
||||||
{
|
{
|
||||||
/* Circle */
|
/* Circle */
|
||||||
|
|
||||||
sz = (2 + (((NUM_ERASERS / 2) - 1 - (i - NUM_ERASERS / 2)) * (38 / ((NUM_ERASERS / 2) - 1)))) * button_scale;
|
sz = (2 + ((NUM_ERASER_SIZES - 1 - (i - NUM_ERASERS / 2)) * (38 / (NUM_ERASER_SIZES - 1)))) * button_scale;
|
||||||
|
|
||||||
x = ((i % 2) * button_w) + WINDOW_WIDTH - r_ttoolopt.w + 24 * button_scale - sz / 2;
|
x = ((i % 2) * button_w) + WINDOW_WIDTH - r_ttoolopt.w + 24 * button_scale - sz / 2;
|
||||||
y = ((j / 2) * button_h) + 40 * button_scale + 24 * button_scale - sz / 2 + off_y;
|
y = ((j / 2) * button_h) + 40 * button_scale + 24 * button_scale - sz / 2 + off_y;
|
||||||
|
|
@ -12193,11 +12195,10 @@ static void circle_xor(int x, int y, int sz)
|
||||||
|
|
||||||
static int calc_eraser_size(int which_eraser)
|
static int calc_eraser_size(int which_eraser)
|
||||||
{
|
{
|
||||||
#define NUM_SIZES (NUM_ERASERS / 2)
|
if (which_eraser >= NUM_ERASER_SIZES)
|
||||||
if (which_eraser >= NUM_SIZES)
|
which_eraser -= NUM_ERASER_SIZES;
|
||||||
which_eraser -= NUM_SIZES;
|
|
||||||
|
|
||||||
return (((NUM_SIZES - 1 - which_eraser) * ((ERASER_MAX - ERASER_MIN) / (NUM_SIZES - 1))) + ERASER_MIN);
|
return (((NUM_ERASER_SIZES - 1 - which_eraser) * ((ERASER_MAX - ERASER_MIN) / (NUM_ERASER_SIZES - 1))) + ERASER_MIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -12212,7 +12213,7 @@ static void do_eraser(int x, int y, int update)
|
||||||
|
|
||||||
sz = calc_eraser_size(cur_eraser);
|
sz = calc_eraser_size(cur_eraser);
|
||||||
|
|
||||||
if (cur_eraser < NUM_SIZES)
|
if (cur_eraser < NUM_ERASER_SIZES)
|
||||||
{
|
{
|
||||||
/* Square eraser: */
|
/* Square eraser: */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue