From 71c24048386005c769c5de0451993d1f4c2a452c Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Fri, 21 Jan 2022 00:25:42 -0800 Subject: [PATCH] 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). --- data/images/shapes/heptagon.png | Bin 0 -> 877 bytes data/images/shapes/heptagon_f.png | Bin 0 -> 823 bytes docs/CHANGES.txt | 7 +- src/shapes.h | 116 ++++++++++++++++++------------ src/tuxpaint.c | 12 ++-- 5 files changed, 81 insertions(+), 54 deletions(-) create mode 100644 data/images/shapes/heptagon.png create mode 100644 data/images/shapes/heptagon_f.png diff --git a/data/images/shapes/heptagon.png b/data/images/shapes/heptagon.png new file mode 100644 index 0000000000000000000000000000000000000000..8720de47e74f7139d6cb07e630d4d65dff0ca6d5 GIT binary patch literal 877 zcmV-z1CsoSP)X0004nX+uL$Nkc;* zaB^>EX>4Tx04R}tkv&MmP!xqvTct%R9jqWClA$_T5EXIMDionYs1;guFnQ@8G-*gu zTpR`0f`dPcRR}v_ypovrW+RV2J!T! zrE}gVjK=+Gne~bXZU7%UF?eAmTZk_;vXW&X}`>PFL=9Bb# zTZ=r_O#~r11hd^iq-R^^8f$<24YJ`L;(K){{a7>y{D4^000SaNLh0L z04^f{04^f|c%?sf00007bV*G`2j&442p<{oOe@3y000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}0003*Nkl|M=Dgu7JL^cA|EocDrqXUEm(r_@#6ScmPhU zwXM4N4uD%=r9{s%@CY0xNuql6U0~0ne+$@A^_z&yc+NO0Q*25OA9v2ZdIB0vKnZXP zpDKXHm?_{R0N`D*G{MyaR(*#Q9v)}_o(7zCuHiu!5b#R_a4h8WtpPYGB8vgw)+*c{ zBW-aDc#EPa_E?ZvV3=i@)qLu%J^G(Tq@x`cdPS0{atmzMm1r(YrkQP^Uw48YipcZ` zzUvf$wwiA}3_s_bI|eTPC|xkd%;$Oj-uxUjYNViV*SR!LO7KO_00000NkvXXu0mjf Dw}N!A literal 0 HcmV?d00001 diff --git a/data/images/shapes/heptagon_f.png b/data/images/shapes/heptagon_f.png new file mode 100644 index 0000000000000000000000000000000000000000..cbd2563dea134755cd50e67b2b1659e87775123c GIT binary patch literal 823 zcmV-71IYY|P)X0004nX+uL$Nkc;* zaB^>EX>4Tx04R}tkv&MmP!xqvTct%R9jqWClA$_T5EXIMDionYs1;guFnQ@8G-*gu zTpR`0f`dPcRR}v_ypovrW+RV2J!T! zrE}gVjK=+Gne~bXZU7%UF?eAmTZk_;vXW&X}`>PFL=9Bb# zTZ=r_O#~r11hd^iq-R^^8f$<24YJ`L;(K){{a7>y{D4^000SaNLh0L z04^f{04^f|c%?sf00007bV*G`2j&442q6gCIS@+#000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}0003FNklJ1=kOSCx zkX*wPW%Q*rgmAVcZoL_kDJdx)`35A`vjlx2GvxpP002ovPDHLkV1jT+ BS*ZX3 literal 0 HcmV?d00001 diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 1bee125ac..6fc067144 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -7,7 +7,7 @@ Various contributors (see below, and AUTHORS.txt) http://www.tuxpaint.org/ -2022.January.20 (0.9.28) +2022.January.21 (0.9.28) * Improvements to "Paint" and "Lines" tools: ------------------------------------------ * Brush spacing may now be altered within Tux Paint. @@ -29,7 +29,10 @@ http://www.tuxpaint.org/ * 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: --------------------- diff --git a/src/shapes.h b/src/shapes.h index bb1287a8d..388224642 100644 --- a/src/shapes.h +++ b/src/shapes.h @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - January 20, 2022 + June 14, 2002 - January 21, 2022 $Id$ */ @@ -51,10 +51,12 @@ enum SHAPE_PENTAGON_FILL, SHAPE_HEXAGON, SHAPE_HEXAGON_FILL, - SHAPE_RHOMBUS, - SHAPE_RHOMBUS_FILL, + SHAPE_HEPTAGON, + SHAPE_HEPTAGON_FILL, SHAPE_OCTAGON, SHAPE_OCTAGON_FILL, + SHAPE_RHOMBUS, + SHAPE_RHOMBUS_FILL, SHAPE_TRIANGLE_STAR, SHAPE_TRIANGLE_STAR_FILL, SHAPE_RHOMBUS_STAR, @@ -82,10 +84,12 @@ const int shape_sides[NUM_SHAPES] = { 5, /* Pentagon */ 6, /* Hexagon */ 6, /* Hexagon */ - 4, /* Rhombus */ - 4, /* Rhombus */ + 7, /* Heptagon */ + 7, /* Heptagon */ 8, /* Octagon */ 8, /* Octagon */ + 4, /* Rhombus */ + 4, /* Rhombus */ 3, /* 3 points star */ 3, /* 3 points star */ 4, /* 4 points star */ @@ -112,10 +116,12 @@ const int shape_locked[NUM_SHAPES] = { 0, /* Pentagon */ 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 */ - 1, /* Octagon */ - 1, /* Octagon */ 0, /* 3 points star */ 0, /* 3 points star */ 0, /* 4 points star */ @@ -140,10 +146,12 @@ const int shape_filled[NUM_SHAPES] = { 1, /* Triangle */ 0, /* Pentagon */ 1, /* Pentagon */ - 0, /* Rhombus */ - 1, /* Rhombus */ + 0, /* Heptagon */ + 1, /* Heptagon */ 0, /* Octagon */ 1, /* Octagon */ + 0, /* Rhombus */ + 1, /* Rhombus */ 0, /* 3 points star */ 1, /* 3 points star */ 0, /* 4 points star */ @@ -156,31 +164,33 @@ const int shape_filled[NUM_SHAPES] = { /* Initial angles for shapes: */ -const int shape_init_ang[NUM_SHAPES] = { - 45, /* Square */ - 45, /* Square */ - 45, /* Rectangle */ - 45, /* Rectangle */ - 0, /* Circle */ - 0, /* Circle */ - 0, /* Ellipse */ - 0, /* Ellipse */ - 210, /* Triangle */ - 210, /* Triangle */ - 162, /* Pentagon */ - 162, /* Pentagon */ - 150, /* Hexagon */ - 150, /* Hexagon */ - 0, /* Rhombus */ - 0, /* Rhombus */ - 22, /* Octagon */ - 22, /* Octagon */ - 210, /* 3 points star */ - 210, /* 3 points star */ - 0, /* 4 points star */ - 0, /* 4 points star */ - 162, /* 5 points star */ - 162 /* 5 points star */ +const float shape_init_ang[NUM_SHAPES] = { + 45.0, /* Square */ + 45.0, /* Square */ + 45.0, /* Rectangle */ + 45.0, /* Rectangle */ + 0.0, /* Circle */ + 0.0, /* Circle */ + 0.0, /* Ellipse */ + 0.0, /* Ellipse */ + 210.0, /* Triangle ((360/3)+90) */ + 210.0, /* Triangle ((360/3)+90) */ + 162.0, /* Pentagon ((360/5)+90) */ + 162.0, /* Pentagon ((360/5)+90) */ + 150.0, /* Hexagon ((360/6)+90) */ + 150.0, /* Hexagon ((360/6)+90) */ + 141.42857143, /* Heptagon ((360/7)+90) */ + 141.42857143, /* Heptagon ((360/7)+90) */ + 22.5, /* Octagon ((360/8)/2 = 22.5) */ + 22.5, /* Octagon ((360/8)/2 = 22.5) */ + 0.0, /* Rhombus */ + 0.0, /* Rhombus */ + 210.0, /* 3 points star ((360/3)+90) */ + 210.0, /* 3 points star ((360/3)+90) */ + 0.0, /* 4 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, /* Hexagon */ 0, /* Hexagon */ - 0, /* Rhombus */ - 0, /* Rhombus */ + 0, /* Heptagon */ + 0, /* Heptagon */ 0, /* Octagon */ 0, /* Octagon */ + 0, /* Rhombus */ + 0, /* Rhombus */ 0, /* 3 points star */ 0, /* 3 points star */ 0, /* 4 points star */ @@ -230,10 +242,12 @@ const int shape_valley[NUM_SHAPES] = { 100, /* Pentagon */ 100, /* Hexagon */ 100, /* Hexagon */ - 100, /* Rhombus */ - 100, /* Rhombus */ + 100, /* Heptagon */ + 100, /* Heptagon */ 100, /* Octagon */ 100, /* Octagon */ + 100, /* Rhombus */ + 100, /* Rhombus */ 20, /* 3 points star */ 20, /* 3 points star */ 30, /* 4 points star */ @@ -274,14 +288,18 @@ const char *const shape_names[NUM_SHAPES] = { gettext_noop("Hexagon"), gettext_noop("Hexagon"), - // Rhombus shape tool (4 sides, not at right angles) - gettext_noop("Rhombus"), - gettext_noop("Rhombus"), + // Heptagon (aka septagon) shape tool (7 sides) + gettext_noop("Heptagon"), + gettext_noop("Heptagon"), // Octagon shape tool (8 sides) 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) 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."), - // 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."), + // Description of a heptagon + gettext_noop("A heptagon has seven sides."), + gettext_noop("A heptagon has seven sides."), // Description of an octagon 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 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/hexagon.png", DATA_PREFIX "images/shapes/hexagon_f.png", - DATA_PREFIX "images/shapes/diamond.png", - DATA_PREFIX "images/shapes/diamond_f.png", + DATA_PREFIX "images/shapes/heptagon.png", + DATA_PREFIX "images/shapes/heptagon_f.png", DATA_PREFIX "images/shapes/octagon.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_f.png", DATA_PREFIX "images/shapes/star4p.png", diff --git a/src/tuxpaint.c b/src/tuxpaint.c index d2497387d..ccf589079 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - January 19, 2022 + June 14, 2002 - January 21, 2022 */ #include "platform.h" @@ -13904,8 +13904,8 @@ static void free_surface_array(SDL_Surface * surface_array[], int count) /* Draw a shape! */ 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; - float a1, a2, rotn_rad; + int side, rx, ry, rmax, x1, y1, x2, y2, xp, yp, xv, yv, old_brush, step; + float a1, a2, rotn_rad, init_ang, angle_skip; 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: */ - angle_skip = 360 / shape_sides[cur_shape]; + angle_skip = 360.0 / (float) shape_sides[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; for (side = 0; side < shape_sides[cur_shape]; side++) { - a1 = (angle_skip * side + init_ang) * M_PI / 180; - a2 = (angle_skip * (side + 1) + 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.0; x1 = (int)(cos(a1) * rx); y1 = (int)(-sin(a1) * ry);