Added heptagon (7-sided) shape
Also, using floats more, allowing for proper heptagon support, as well as a non-skewed starting angle for octagons (22.5 degrees).
This commit is contained in:
parent
1050e74336
commit
71c2404838
5 changed files with 81 additions and 54 deletions
BIN
data/images/shapes/heptagon.png
Normal file
BIN
data/images/shapes/heptagon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 877 B |
BIN
data/images/shapes/heptagon_f.png
Normal file
BIN
data/images/shapes/heptagon_f.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 823 B |
|
|
@ -7,7 +7,7 @@ Various contributors (see below, and AUTHORS.txt)
|
||||||
http://www.tuxpaint.org/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
|
|
||||||
2022.January.20 (0.9.28)
|
2022.January.21 (0.9.28)
|
||||||
* Improvements to "Paint" and "Lines" tools:
|
* Improvements to "Paint" and "Lines" tools:
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
* Brush spacing may now be altered within Tux Paint.
|
* Brush spacing may now be altered within Tux Paint.
|
||||||
|
|
@ -29,7 +29,10 @@ http://www.tuxpaint.org/
|
||||||
|
|
||||||
* Improvements to "Shapes" tool:
|
* Improvements to "Shapes" tool:
|
||||||
------------------------------
|
------------------------------
|
||||||
* Added hexagon (6-sided polygon) shape.
|
* Added hexagon (6-sided polygon) and heptagon (7-sided) shapes.
|
||||||
|
|
||||||
|
* Using floats more, allowing for proper heptagon support, as
|
||||||
|
well as a non-skewed starting angle for octagons (22.5 degrees).
|
||||||
|
|
||||||
* Localization Updates:
|
* Localization Updates:
|
||||||
---------------------
|
---------------------
|
||||||
|
|
|
||||||
116
src/shapes.h
116
src/shapes.h
|
|
@ -23,7 +23,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 - January 20, 2022
|
June 14, 2002 - January 21, 2022
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -51,10 +51,12 @@ enum
|
||||||
SHAPE_PENTAGON_FILL,
|
SHAPE_PENTAGON_FILL,
|
||||||
SHAPE_HEXAGON,
|
SHAPE_HEXAGON,
|
||||||
SHAPE_HEXAGON_FILL,
|
SHAPE_HEXAGON_FILL,
|
||||||
SHAPE_RHOMBUS,
|
SHAPE_HEPTAGON,
|
||||||
SHAPE_RHOMBUS_FILL,
|
SHAPE_HEPTAGON_FILL,
|
||||||
SHAPE_OCTAGON,
|
SHAPE_OCTAGON,
|
||||||
SHAPE_OCTAGON_FILL,
|
SHAPE_OCTAGON_FILL,
|
||||||
|
SHAPE_RHOMBUS,
|
||||||
|
SHAPE_RHOMBUS_FILL,
|
||||||
SHAPE_TRIANGLE_STAR,
|
SHAPE_TRIANGLE_STAR,
|
||||||
SHAPE_TRIANGLE_STAR_FILL,
|
SHAPE_TRIANGLE_STAR_FILL,
|
||||||
SHAPE_RHOMBUS_STAR,
|
SHAPE_RHOMBUS_STAR,
|
||||||
|
|
@ -82,10 +84,12 @@ const int shape_sides[NUM_SHAPES] = {
|
||||||
5, /* Pentagon */
|
5, /* Pentagon */
|
||||||
6, /* Hexagon */
|
6, /* Hexagon */
|
||||||
6, /* Hexagon */
|
6, /* Hexagon */
|
||||||
4, /* Rhombus */
|
7, /* Heptagon */
|
||||||
4, /* Rhombus */
|
7, /* Heptagon */
|
||||||
8, /* Octagon */
|
8, /* Octagon */
|
||||||
8, /* Octagon */
|
8, /* Octagon */
|
||||||
|
4, /* Rhombus */
|
||||||
|
4, /* Rhombus */
|
||||||
3, /* 3 points star */
|
3, /* 3 points star */
|
||||||
3, /* 3 points star */
|
3, /* 3 points star */
|
||||||
4, /* 4 points star */
|
4, /* 4 points star */
|
||||||
|
|
@ -112,10 +116,12 @@ const int shape_locked[NUM_SHAPES] = {
|
||||||
0, /* Pentagon */
|
0, /* Pentagon */
|
||||||
0, /* Hexagon */
|
0, /* Hexagon */
|
||||||
0, /* Hexagon */
|
0, /* Hexagon */
|
||||||
|
0, /* Heptagon */
|
||||||
|
0, /* Heptagon */
|
||||||
|
1, /* Octagon */ /* FIXME: Consider unlocking? -bjk 2022.01.21 */
|
||||||
|
1, /* Octagon */ /* FIXME: Consider unlocking? -bjk 2022.01.21 */
|
||||||
0, /* Rhombus */
|
0, /* Rhombus */
|
||||||
0, /* Rhombus */
|
0, /* Rhombus */
|
||||||
1, /* Octagon */
|
|
||||||
1, /* Octagon */
|
|
||||||
0, /* 3 points star */
|
0, /* 3 points star */
|
||||||
0, /* 3 points star */
|
0, /* 3 points star */
|
||||||
0, /* 4 points star */
|
0, /* 4 points star */
|
||||||
|
|
@ -140,10 +146,12 @@ const int shape_filled[NUM_SHAPES] = {
|
||||||
1, /* Triangle */
|
1, /* Triangle */
|
||||||
0, /* Pentagon */
|
0, /* Pentagon */
|
||||||
1, /* Pentagon */
|
1, /* Pentagon */
|
||||||
0, /* Rhombus */
|
0, /* Heptagon */
|
||||||
1, /* Rhombus */
|
1, /* Heptagon */
|
||||||
0, /* Octagon */
|
0, /* Octagon */
|
||||||
1, /* Octagon */
|
1, /* Octagon */
|
||||||
|
0, /* Rhombus */
|
||||||
|
1, /* Rhombus */
|
||||||
0, /* 3 points star */
|
0, /* 3 points star */
|
||||||
1, /* 3 points star */
|
1, /* 3 points star */
|
||||||
0, /* 4 points star */
|
0, /* 4 points star */
|
||||||
|
|
@ -156,31 +164,33 @@ const int shape_filled[NUM_SHAPES] = {
|
||||||
|
|
||||||
/* Initial angles for shapes: */
|
/* Initial angles for shapes: */
|
||||||
|
|
||||||
const int shape_init_ang[NUM_SHAPES] = {
|
const float shape_init_ang[NUM_SHAPES] = {
|
||||||
45, /* Square */
|
45.0, /* Square */
|
||||||
45, /* Square */
|
45.0, /* Square */
|
||||||
45, /* Rectangle */
|
45.0, /* Rectangle */
|
||||||
45, /* Rectangle */
|
45.0, /* Rectangle */
|
||||||
0, /* Circle */
|
0.0, /* Circle */
|
||||||
0, /* Circle */
|
0.0, /* Circle */
|
||||||
0, /* Ellipse */
|
0.0, /* Ellipse */
|
||||||
0, /* Ellipse */
|
0.0, /* Ellipse */
|
||||||
210, /* Triangle */
|
210.0, /* Triangle ((360/3)+90) */
|
||||||
210, /* Triangle */
|
210.0, /* Triangle ((360/3)+90) */
|
||||||
162, /* Pentagon */
|
162.0, /* Pentagon ((360/5)+90) */
|
||||||
162, /* Pentagon */
|
162.0, /* Pentagon ((360/5)+90) */
|
||||||
150, /* Hexagon */
|
150.0, /* Hexagon ((360/6)+90) */
|
||||||
150, /* Hexagon */
|
150.0, /* Hexagon ((360/6)+90) */
|
||||||
0, /* Rhombus */
|
141.42857143, /* Heptagon ((360/7)+90) */
|
||||||
0, /* Rhombus */
|
141.42857143, /* Heptagon ((360/7)+90) */
|
||||||
22, /* Octagon */
|
22.5, /* Octagon ((360/8)/2 = 22.5) */
|
||||||
22, /* Octagon */
|
22.5, /* Octagon ((360/8)/2 = 22.5) */
|
||||||
210, /* 3 points star */
|
0.0, /* Rhombus */
|
||||||
210, /* 3 points star */
|
0.0, /* Rhombus */
|
||||||
0, /* 4 points star */
|
210.0, /* 3 points star ((360/3)+90) */
|
||||||
0, /* 4 points star */
|
210.0, /* 3 points star ((360/3)+90) */
|
||||||
162, /* 5 points star */
|
0.0, /* 4 points star */
|
||||||
162 /* 5 points star */
|
0.0, /* 4 points star */
|
||||||
|
162.0, /* 5 points star ((360/5)+90) */
|
||||||
|
162.0 /* 5 points star ((360/5)+90) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -201,10 +211,12 @@ const int shape_no_rotate[NUM_SHAPES] = {
|
||||||
0, /* Pentagon */
|
0, /* Pentagon */
|
||||||
0, /* Hexagon */
|
0, /* Hexagon */
|
||||||
0, /* Hexagon */
|
0, /* Hexagon */
|
||||||
0, /* Rhombus */
|
0, /* Heptagon */
|
||||||
0, /* Rhombus */
|
0, /* Heptagon */
|
||||||
0, /* Octagon */
|
0, /* Octagon */
|
||||||
0, /* Octagon */
|
0, /* Octagon */
|
||||||
|
0, /* Rhombus */
|
||||||
|
0, /* Rhombus */
|
||||||
0, /* 3 points star */
|
0, /* 3 points star */
|
||||||
0, /* 3 points star */
|
0, /* 3 points star */
|
||||||
0, /* 4 points star */
|
0, /* 4 points star */
|
||||||
|
|
@ -230,10 +242,12 @@ const int shape_valley[NUM_SHAPES] = {
|
||||||
100, /* Pentagon */
|
100, /* Pentagon */
|
||||||
100, /* Hexagon */
|
100, /* Hexagon */
|
||||||
100, /* Hexagon */
|
100, /* Hexagon */
|
||||||
100, /* Rhombus */
|
100, /* Heptagon */
|
||||||
100, /* Rhombus */
|
100, /* Heptagon */
|
||||||
100, /* Octagon */
|
100, /* Octagon */
|
||||||
100, /* Octagon */
|
100, /* Octagon */
|
||||||
|
100, /* Rhombus */
|
||||||
|
100, /* Rhombus */
|
||||||
20, /* 3 points star */
|
20, /* 3 points star */
|
||||||
20, /* 3 points star */
|
20, /* 3 points star */
|
||||||
30, /* 4 points star */
|
30, /* 4 points star */
|
||||||
|
|
@ -274,14 +288,18 @@ const char *const shape_names[NUM_SHAPES] = {
|
||||||
gettext_noop("Hexagon"),
|
gettext_noop("Hexagon"),
|
||||||
gettext_noop("Hexagon"),
|
gettext_noop("Hexagon"),
|
||||||
|
|
||||||
// Rhombus shape tool (4 sides, not at right angles)
|
// Heptagon (aka septagon) shape tool (7 sides)
|
||||||
gettext_noop("Rhombus"),
|
gettext_noop("Heptagon"),
|
||||||
gettext_noop("Rhombus"),
|
gettext_noop("Heptagon"),
|
||||||
|
|
||||||
// Octagon shape tool (8 sides)
|
// Octagon shape tool (8 sides)
|
||||||
gettext_noop("Octagon"),
|
gettext_noop("Octagon"),
|
||||||
gettext_noop("Octagon"),
|
gettext_noop("Octagon"),
|
||||||
|
|
||||||
|
// Rhombus shape tool (4 sides, not at right angles)
|
||||||
|
gettext_noop("Rhombus"),
|
||||||
|
gettext_noop("Rhombus"),
|
||||||
|
|
||||||
// Triangle star (3 points star)
|
// Triangle star (3 points star)
|
||||||
gettext_noop("Star"),
|
gettext_noop("Star"),
|
||||||
|
|
||||||
|
|
@ -333,14 +351,18 @@ const char *const shape_tips[NUM_SHAPES] = {
|
||||||
gettext_noop("A hexagon has six sides."),
|
gettext_noop("A hexagon has six sides."),
|
||||||
gettext_noop("A hexagon has six sides."),
|
gettext_noop("A hexagon has six sides."),
|
||||||
|
|
||||||
// Description of a rhombus
|
// Description of a heptagon
|
||||||
gettext_noop("A rhombus has four equal sides, and opposite sides are parallel."),
|
gettext_noop("A heptagon has seven sides."),
|
||||||
gettext_noop("A rhombus has four equal sides, and opposite sides are parallel."),
|
gettext_noop("A heptagon has seven sides."),
|
||||||
|
|
||||||
// Description of an octagon
|
// Description of an octagon
|
||||||
gettext_noop("An octagon has eight equal sides."),
|
gettext_noop("An octagon has eight equal sides."),
|
||||||
gettext_noop("An octagon has eight equal sides."),
|
gettext_noop("An octagon has eight equal sides."),
|
||||||
|
|
||||||
|
// Description of a rhombus
|
||||||
|
gettext_noop("A rhombus has four equal sides, and opposite sides are parallel."),
|
||||||
|
gettext_noop("A rhombus has four equal sides, and opposite sides are parallel."),
|
||||||
|
|
||||||
gettext_noop("A star with 3 points."),
|
gettext_noop("A star with 3 points."),
|
||||||
gettext_noop("A star with 3 points."),
|
gettext_noop("A star with 3 points."),
|
||||||
gettext_noop("A star with 4 points."),
|
gettext_noop("A star with 4 points."),
|
||||||
|
|
@ -367,10 +389,12 @@ const char *const shape_img_fnames[NUM_SHAPES] = {
|
||||||
DATA_PREFIX "images/shapes/pentagon_f.png",
|
DATA_PREFIX "images/shapes/pentagon_f.png",
|
||||||
DATA_PREFIX "images/shapes/hexagon.png",
|
DATA_PREFIX "images/shapes/hexagon.png",
|
||||||
DATA_PREFIX "images/shapes/hexagon_f.png",
|
DATA_PREFIX "images/shapes/hexagon_f.png",
|
||||||
DATA_PREFIX "images/shapes/diamond.png",
|
DATA_PREFIX "images/shapes/heptagon.png",
|
||||||
DATA_PREFIX "images/shapes/diamond_f.png",
|
DATA_PREFIX "images/shapes/heptagon_f.png",
|
||||||
DATA_PREFIX "images/shapes/octagon.png",
|
DATA_PREFIX "images/shapes/octagon.png",
|
||||||
DATA_PREFIX "images/shapes/octagon_f.png",
|
DATA_PREFIX "images/shapes/octagon_f.png",
|
||||||
|
DATA_PREFIX "images/shapes/diamond.png",
|
||||||
|
DATA_PREFIX "images/shapes/diamond_f.png",
|
||||||
DATA_PREFIX "images/shapes/star3p.png",
|
DATA_PREFIX "images/shapes/star3p.png",
|
||||||
DATA_PREFIX "images/shapes/star3p_f.png",
|
DATA_PREFIX "images/shapes/star3p_f.png",
|
||||||
DATA_PREFIX "images/shapes/star4p.png",
|
DATA_PREFIX "images/shapes/star4p.png",
|
||||||
|
|
|
||||||
|
|
@ -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 - January 19, 2022
|
June 14, 2002 - January 21, 2022
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
@ -13904,8 +13904,8 @@ static void free_surface_array(SDL_Surface * surface_array[], int count)
|
||||||
/* Draw a shape! */
|
/* Draw a shape! */
|
||||||
static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush)
|
static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush)
|
||||||
{
|
{
|
||||||
int side, angle_skip, init_ang, rx, ry, rmax, x1, y1, x2, y2, xp, yp, xv, yv, old_brush, step;
|
int side, rx, ry, rmax, x1, y1, x2, y2, xp, yp, xv, yv, old_brush, step;
|
||||||
float a1, a2, rotn_rad;
|
float a1, a2, rotn_rad, init_ang, angle_skip;
|
||||||
int xx, yy, offx, offy, max_x, max_y;
|
int xx, yy, offx, offy, max_x, max_y;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13958,7 +13958,7 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush)
|
||||||
|
|
||||||
/* Draw the shape: */
|
/* Draw the shape: */
|
||||||
|
|
||||||
angle_skip = 360 / shape_sides[cur_shape];
|
angle_skip = 360.0 / (float) shape_sides[cur_shape];
|
||||||
|
|
||||||
init_ang = shape_init_ang[cur_shape];
|
init_ang = shape_init_ang[cur_shape];
|
||||||
|
|
||||||
|
|
@ -13977,8 +13977,8 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush)
|
||||||
max_y = 0;
|
max_y = 0;
|
||||||
for (side = 0; side < shape_sides[cur_shape]; side++)
|
for (side = 0; side < shape_sides[cur_shape]; side++)
|
||||||
{
|
{
|
||||||
a1 = (angle_skip * side + init_ang) * M_PI / 180;
|
a1 = (angle_skip * side + init_ang) * M_PI / 180.0;
|
||||||
a2 = (angle_skip * (side + 1) + init_ang) * M_PI / 180;
|
a2 = (angle_skip * (side + 1) + init_ang) * M_PI / 180.0;
|
||||||
x1 = (int)(cos(a1) * rx);
|
x1 = (int)(cos(a1) * rx);
|
||||||
y1 = (int)(-sin(a1) * ry);
|
y1 = (int)(-sin(a1) * ry);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue