From 8d67915b3ecddcd9e990450016dd9cf1470e0624 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sat, 4 Sep 2021 14:28:01 -0700 Subject: [PATCH] "Panels" magic tool; convert image to 2x2 repeat Useful for making 4-panel comics; or repeat multiple times to create a compound-eye effect. Closes https://sourceforge.net/p/tuxpaint/feature-requests/204/ --- docs/CHANGES.txt | 9 +++- magic/docs/en/README.txt | 2 +- magic/docs/en/html/README.html | 2 +- magic/icons/panels.png | Bin 0 -> 7787 bytes magic/magic-docs/en/html/index.html | 1 + magic/magic-docs/en/html/panels.html | 9 ++++ magic/magic-docs/en/index.txt | 1 + magic/magic-docs/en/panels.txt | 6 +++ magic/magic-docs/src/magic-docs.php | 4 ++ magic/src/perspective.c | 71 +++++++++++++++++++++++---- 10 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 magic/icons/panels.png create mode 100644 magic/magic-docs/en/html/panels.html create mode 100644 magic/magic-docs/en/panels.txt diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 575e4b5fe..a595b146f 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -8,7 +8,14 @@ http://www.tuxpaint.org/ $Id$ -2021.September.2 (0.9.27) +2021.September.4 (0.9.27) + * New Magic Tools: + ---------------- + * "Panels" - Convert your picture to 4-panel-comic-style + 2x2 image, repeating the original. (Repeat for "compound eye" + style effects!) + (Closes https://sourceforge.net/p/tuxpaint/feature-requests/204/) + * Documentation updates --------------------- * Ensured Tux Paint's built-in help ("tuxpaint --help"), diff --git a/magic/docs/en/README.txt b/magic/docs/en/README.txt index f5173ae38..672494c2d 100644 --- a/magic/docs/en/README.txt +++ b/magic/docs/en/README.txt @@ -1,6 +1,6 @@ Creating Tux Paint Magic Tool Plugins - Copyright 2007-2018 by various contributors; see AUTHORS.txt + Copyright 2007-2021 by various contributors; see AUTHORS.txt http://www.tuxpaint.org/ July 5, 2007 - February 20, 2021 diff --git a/magic/docs/en/html/README.html b/magic/docs/en/html/README.html index e6fcd52ef..23b246a99 100644 --- a/magic/docs/en/html/README.html +++ b/magic/docs/en/html/README.html @@ -9,7 +9,7 @@ alink="#FF00FF">

Creating Tux Paint Magic Tool Plugins

-

Copyright 2007-2018 by various contributors; see AUTHORS.txt
+

Copyright 2007-2021 by various contributors; see AUTHORS.txt
http://www.tuxpaint.org/

July 5, 2007 - February 20, 2021

diff --git a/magic/icons/panels.png b/magic/icons/panels.png new file mode 100644 index 0000000000000000000000000000000000000000..7da5adb71af5414d72d10ddb149c3ba9a2a4d3a0 GIT binary patch literal 7787 zcmeHMc{r5q_g5slL?L95EoRJMEMwn|Eg?e6tc-0mGYqn1EwW@w6w2P4B}+nISR4f=Di_0W41R3B?z+-VP7y!xJ9Rt94;jmOxULys`IL}Ei zOUV8t2a)EwXiUR;O=UfAfU0T9sELxHX!tcry?bIuk8#|L=-mH7ZVT87Z`N56n7)iu z-dbtmwB5cN^DXx)nYi_%Heg{<>6`D>&g$A{4+*^Qw;iGf*I#`5T>Hv9&zFIfaoXRn zC#_CwuQqrlwD7p%``GD*iqq!@HQ%INyYC$6lj6}B_b!uuvE)P5K8d<617DCne*49p ziQPr^ah|{#1?OCuuOHsS0^DBB7O`1vn{K?E(VX1fOThe$UMh#GtRYK!%ai95q@f#0vcN1s(@va)GFhAHKL8O2wR+c^S{ zjd6Kk)%==j^F@x0nog~yKBa2Rx8)68{4hGd81rdP9qc0Sz?842l;l`{r8xWglw5Z- zBXx_+pwXGZqZPLuj?1BV>F&ydxZ*^uA4Jy2aQmKT#Kbkr0l)%7^`HVW=%`8gj>}g# z_L_6B%7q4NDmML08rdw)%ig!6w&1GlTF{CQT6B=CyIS)uv?0%Ci(u7uw z%DQCD8f?LxI*sdkR;(VkM+#ibSgj#arc1da|Bk7x+x98TE4b-PmNl8!sgU)e!NH3% z@_h@s22w`kz6xme=tSt zy;usqpJeB;ZkgJ!6lALD>=qVRuMpsW*EEnXfMZQ}D0tGt@r<3R7xbwpbEL}1(0Qk- z;*#Bo+}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VghHcWx_E*sg0h`BSA+vb%H7T3P;fvvOv4neA}9^|sd~6#>VhC)DF!NnMmRSQ zuRm2SaIP4065@bOh@1>qUO`a~q6m?emzVyT_Mx>UhCrlL;sGWE4EiNG*cKQi849t8 zgF2-E{GKIDi-19p@B|Ay-bF?500MAed05^6<)53Pk0Vkvybmh=SIwJauK%35@Y6Y*FQ89~5kI8ZXBWJ4*S!)yRzhg6FHJr=Sf=71-# zGz17%1cGHPAhIy991Kc%mWP4Cf>OT{mO6N=f6rK1>i=+}e5ml3V}N4!bB%JmP);kU zKaQ(koE^~kU;O;qi~phr3iQ8D{t>_b()BN0|A>Kqr2KDn{Y%$BV&ESs|65)EZ*(#I z+3;Z8DBps}ly;`?X~@C9nMaX^dfHU`w_-Z$C^LF@eQP2W6(ifhbtC|NEtax)oCG)4 zIX+EKbBb1JJ$@&e(u+dj+8P%6EsK2`PUaUmXg@4fkBwBDYH=W+_ri}y9P5d#hycBI ztzhB&DDtqJ+D=_GBisJb$!BumjyrCmk4?X1lh038*N3*WR92G}0?^vM-1n#RO=F3D zl^h?RJT?y4jec{Ee9UGxF6pfIm(VAEda6yhk9!75S4M~*p#D44uRGTU!V*E=Zi6xf z3xUNZb;~!-+o49o@p0K;!a{!cvtFnwY+1KlcExVKgfbH*MpY&g`FT_BURY?dQqiKG(be5+gXE5E=ieIWPOj7S-0ha>u5!P2Ew{96+A#Hw mhi}28GvBrOtsS+=d4}iRPP@@$2^I>cRB#;=?Ltlap#K49Kq!6y literal 0 HcmV?d00001 diff --git a/magic/magic-docs/en/html/index.html b/magic/magic-docs/en/html/index.html index ed77bc230..b50bcda63 100644 --- a/magic/magic-docs/en/html/index.html +++ b/magic/magic-docs/en/html/index.html @@ -39,6 +39,7 @@
  • Square Mosaic
  • Negative
  • Noise
  • +
  • Panels
  • Pattern
  • Perspective
  • Picasso
  • diff --git a/magic/magic-docs/en/html/panels.html b/magic/magic-docs/en/html/panels.html new file mode 100644 index 000000000..b7db99cf6 --- /dev/null +++ b/magic/magic-docs/en/html/panels.html @@ -0,0 +1,9 @@ + +Tux Paint "Magic" Tool: Panels + + + +

    Tux Paint "Magic" Tool: Panels

    +

    By Bill Kendrick <bill@newbreedsoftware.com>

    +

    Shrink the image and repeat it four times in a 2-by-2 grid. Useful for creating 4-panel comics. Can also be used to create a compound-eye effect.

    + \ No newline at end of file diff --git a/magic/magic-docs/en/index.txt b/magic/magic-docs/en/index.txt index 667124e6b..7d4cdcf23 100644 --- a/magic/magic-docs/en/index.txt +++ b/magic/magic-docs/en/index.txt @@ -35,6 +35,7 @@ * Square Mosaic * Negative * Noise + * Panels * Pattern * Perspective * Picasso diff --git a/magic/magic-docs/en/panels.txt b/magic/magic-docs/en/panels.txt new file mode 100644 index 000000000..a5201368a --- /dev/null +++ b/magic/magic-docs/en/panels.txt @@ -0,0 +1,6 @@ + Tux Paint "Magic" Tool: Panels + + By Bill Kendrick + + Shrink the image and repeat it four times in a 2-by-2 grid. Useful for + creating 4-panel comics. Can also be used to create a compound-eye effect. diff --git a/magic/magic-docs/src/magic-docs.php b/magic/magic-docs/src/magic-docs.php index 2904c7b98..1b852e004 100644 --- a/magic/magic-docs/src/magic-docs.php +++ b/magic/magic-docs/src/magic-docs.php @@ -221,6 +221,10 @@ $tools = array( 'desc'=>'Add random noise and static to your picture.', 'author'=>$AUTHOR_ANDREWC), + array('name'=>'Panels', + 'desc'=>'Shrink the image and repeat it four times in a 2-by-2 grid. Useful for creating 4-panel comics. Can also be used to create a compound-eye effect.', + 'author'=>$AUTHOR_KENDRICK), + array('name'=>'Pattern', 'desc'=>'Draws a tiled pattern around the picture.', 'author'=>$AUTHOR_PERE, diff --git a/magic/src/perspective.c b/magic/src/perspective.c index b8d087d4a..692805769 100644 --- a/magic/src/perspective.c +++ b/magic/src/perspective.c @@ -8,7 +8,7 @@ Credits: Andrew Corcoran - Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt + Copyright (c) 2002-2021 by Bill Kendrick and others; see AUTHORS.txt bill@newbreedsoftware.com http://www.tuxpaint.org/ @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: August 29, 2019 + Last updated: September 4, 2021 $Id$ */ @@ -114,6 +114,7 @@ float top_advc_y, right_advc_y, bottom_advc_y, left_advc_y; enum { TOOL_PERSPECTIVE, + TOOL_PANELS, TOOL_ZOOM, perspective_NUM_TOOLS }; @@ -134,28 +135,29 @@ static Mix_Chunk *perspective_snd_effect[perspective_NUM_TOOLS + 1]; const char *perspective_snd_filenames[perspective_NUM_TOOLS + 1] = { "perspective.ogg", + "zoom_down.ogg", /* TODO: Could use a different sound */ "zoom_up.ogg", "zoom_down.ogg", }; const char *perspective_icon_filenames[perspective_NUM_TOOLS] = { "perspective.png", + "panels.png", "zoom.png", }; const char *perspective_names[perspective_NUM_TOOLS] = { gettext_noop("Perspective"), + gettext_noop("Panels"), gettext_noop("Zoom"), - }; const char *perspective_descs[perspective_NUM_TOOLS] = { gettext_noop("Click on the corners and drag where you want to stretch the picture."), + gettext_noop("Click to turn your picture into 2-by-2 panels."), gettext_noop("Click and drag up to zoom in or drag down to zoom out the picture."), - - }; Uint32 perspective_api_version(void) @@ -358,8 +360,56 @@ void perspective_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, old_h = new_h; } break; + case TOOL_PANELS: + { + SDL_Surface *scaled_surf; + + scaled_surf = api->scale(canvas, canvas->w / 2, canvas->h / 2, 0); + + /* Top left */ + update_rect->x = 0; + update_rect->y = 0; + update_rect->w = scaled_surf->w; + update_rect->h = scaled_surf->h; + SDL_BlitSurface(scaled_surf, NULL, canvas, update_rect); + + /* Top right */ + update_rect->x = scaled_surf->w; + update_rect->y = 0; + update_rect->w = scaled_surf->w; + update_rect->h = scaled_surf->h; + SDL_BlitSurface(scaled_surf, NULL, canvas, update_rect); + + /* Bottom left */ + update_rect->x = 0; + update_rect->y = scaled_surf->h; + update_rect->w = scaled_surf->w; + update_rect->h = scaled_surf->h; + SDL_BlitSurface(scaled_surf, NULL, canvas, update_rect); + + /* Bottom right */ + update_rect->x = scaled_surf->w; + update_rect->y = scaled_surf->h; + update_rect->w = scaled_surf->w; + update_rect->h = scaled_surf->h; + SDL_BlitSurface(scaled_surf, NULL, canvas, update_rect); + + update_rect->x = 0; + update_rect->y = 0; + update_rect->w = canvas->w; + update_rect->h = canvas->h; + + SDL_FreeSurface(scaled_surf); + + api->playsound(perspective_snd_effect[which], 127, 255); + } + break; + } + + if (which != TOOL_PANELS) + { + perspective_drag(api, which, canvas, last, x, y, x, y, update_rect); } - perspective_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -482,7 +532,6 @@ void perspective_preview(magic_api * api, int which ATTRIBUTE_UNUSED, } } -// No setup happened: void perspective_shutdown(magic_api * api ATTRIBUTE_UNUSED) { //Clean up sounds @@ -546,9 +595,13 @@ void perspective_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE SDL_FreeSurface(canvas_back); } -int perspective_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) +int perspective_modes(magic_api * api ATTRIBUTE_UNUSED, int which) { - return (MODE_PAINT_WITH_PREVIEW); + if (which == TOOL_PANELS) { + return (MODE_FULLSCREEN); + } else { + return (MODE_PAINT_WITH_PREVIEW); + } } void perspective_line(void *ptr_to_api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,