Fisheye improvement (works with drag again, this time sensibly).

This commit is contained in:
William Kendrick 2009-06-21 18:14:09 +00:00
parent 1f014fc60d
commit 294b2314f1
2 changed files with 17 additions and 8 deletions

View file

@ -8,7 +8,7 @@ http://www.tuxpaint.org/
$Id$ $Id$
2009.June.20 (0.9.21) 2009.June.21 (0.9.21)
* New Starters: * New Starters:
------------- -------------
* Silver Frame * Silver Frame
@ -35,7 +35,6 @@ $Id$
(Part of Tux4Kids' participation in Google Summer of Code 2008) (Part of Tux4Kids' participation in Google Summer of Code 2008)
* + Confetti - Paints random confetti bits on the canvas. * + Confetti - Paints random confetti bits on the canvas.
+ Fisheye - Warps part of the picture, as though seen through a fisheye.
+ TV - Adds television (CRT) interlacing lines over the image. + TV - Adds television (CRT) interlacing lines over the image.
+ Rosette - Paints at 3 points on the screen, in a rosette shape. + Rosette - Paints at 3 points on the screen, in a rosette shape.
+ Picasso - Paints at 3 points, in a "Picasso" art style. + Picasso - Paints at 3 points, in a "Picasso" art style.
@ -44,6 +43,7 @@ $Id$
(Part of Tux4Kids' participation in Google Summer of Code 2008) (Part of Tux4Kids' participation in Google Summer of Code 2008)
* + Rails - Draws train tracks / rails over the image. * + Rails - Draws train tracks / rails over the image.
+ Fisheye - Warps part of the picture, as though seen through a fisheye.
+ Fold - Folds the corners of the image up, like a piece of paper. + Fold - Folds the corners of the image up, like a piece of paper.
By Adam 'foo-script' Rakowski <foo-script@o2.pl> (GSOC 2008), By Adam 'foo-script' Rakowski <foo-script@o2.pl> (GSOC 2008),
with modifications by Bill Kendrick with modifications by Bill Kendrick

View file

@ -32,6 +32,7 @@
#include "SDL_mixer.h" #include "SDL_mixer.h"
Mix_Chunk * fisheye_snd; Mix_Chunk * fisheye_snd;
int last_x, last_y;
// Housekeeping functions // Housekeeping functions
@ -102,7 +103,11 @@ void fisheye_draw(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * las
int xx, yy; int xx, yy;
unsigned short int i; unsigned short int i;
/*SDL_BlitSurface(canvas, NULL, last, NULL); */ if(api->in_circle(last_x - x, last_y - y, 80)) return;
last_x = x;
last_y = y;
oryg=SDL_CreateRGBSurface(SDL_ANYFORMAT, 80, 80, canvas->format->BitsPerPixel, oryg=SDL_CreateRGBSurface(SDL_ANYFORMAT, 80, 80, canvas->format->BitsPerPixel,
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
@ -212,17 +217,21 @@ void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Surface * snapshot, int ox, int oy, int x, int y,
SDL_Rect * update_rect) SDL_Rect * update_rect)
{ {
api->line(api, which, canvas, snapshot, ox, oy, x, y, 1, fisheye_draw);
update_rect->x = min(ox, x) - 40;
update_rect->y = min(oy, y) - 40;
update_rect->w = max(ox, x) - update_rect->x + 40;
update_rect->h = max(oy, y) - update_rect->y + 40;
} }
void fisheye_click(magic_api * api, int which, int mode, void fisheye_click(magic_api * api, int which, int mode,
SDL_Surface * canvas, SDL_Surface * last, SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect) int x, int y, SDL_Rect * update_rect)
{ {
fisheye_draw(api, which, canvas, last, x, y); last_x = -80; /* A value that will be beyond any clicked position */
last_y = -80;
update_rect->x=x-40; fisheye_drag(api, which, canvas, last, x, y, x, y, update_rect);
update_rect->y=y-40;
update_rect->w=update_rect->h=80;
} }
void fisheye_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas) void fisheye_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)