aboutsummaryrefslogtreecommitdiff
path: root/Plugins/shuffle.c
diff options
context:
space:
mode:
authorJuha Vehviläinen <jusu@users.sourceforge.net>2002-07-06 17:50:18 +0000
committerJuha Vehviläinen <jusu@users.sourceforge.net>2002-07-06 17:50:18 +0000
commit4d64e4cd434426234a5c313c151cd79b6afc299e (patch)
tree5c23dd6acc65b869741d3bb9d33912d74bb7407d /Plugins/shuffle.c
*** empty log message ***svn2git-root
svn path=/trunk/Framestein/; revision=27
Diffstat (limited to 'Plugins/shuffle.c')
-rw-r--r--Plugins/shuffle.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/Plugins/shuffle.c b/Plugins/shuffle.c
new file mode 100644
index 0000000..0604595
--- /dev/null
+++ b/Plugins/shuffle.c
@@ -0,0 +1,42 @@
+#include <string.h>
+#include "plugin.h"
+
+void perform_effect(_frame f, _args a)
+{
+ int i, o=1000, x1, y1, x2, y2, range=10;
+ char *t;
+ pixel8 *p1, *p2;
+ pixel32 dot;
+ byte pixelsize=f.pixelformat/8;
+
+ if(f.pixelformat>32) return;
+
+ if(a.s)
+ {
+ o = atoi(a.s);
+ if(o==0) o=1000;
+
+ if(t = strstr(a.s, " "))
+ if((range = atoi(t+1))==0) return;
+ }
+
+ for(i=0; i<o; i++)
+ {
+ x1 = rand()%f.width;
+ y1 = rand()%f.height;
+ x2 = x1 + (rand()%(range*2) - range);
+ y2 = y1 + (rand()%(range*2) - range);
+
+ if(x2<0) x2=0;
+ if(x2>=f.width) x2=f.width-1;
+ if(y2<0) y2=0;
+ if(y2>=f.height) y2=f.height-1;
+
+ p1 = scanline(f, y1);
+ p2 = scanline(f, y2);
+
+ memcpy(&dot, &p2[x2*pixelsize], pixelsize);
+ memcpy(&p2[x2*pixelsize], &p1[x1*pixelsize], pixelsize);
+ memcpy(&p1[x1*pixelsize], &dot, pixelsize);
+ }
+}