-
-
Save miura/24a6d91c7358454cb444 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Code 13 | |
macro "Generate Dot Animation XY move" { | |
// **** initial values **** | |
sizenum=10; //dot size in pixel | |
int=255; //dot intensity in 8bit grayscale | |
frames=200; //frames in stack | |
w=200; //width of frame | |
h=400; //height of frame | |
x_position = sizenum; //starting x position: | |
y_position= (h/2)-(sizenum/2); //y positon of the oval top-left corner: constant | |
//**** set colors ***** | |
setForegroundColor(int, int, int); | |
setBackgroundColor(0, 0, 0); | |
//**** ask speed ***** | |
speed=getNumber("Speed [pix/frame]?",10) | |
//**** prepare stack **** | |
stackname="dotanimation"+speed; | |
xspeed = speed; | |
yspeed = speed; | |
newImage(stackname, "8-bit Black", w, h, frames); | |
//**** drawing oval in the stack **** | |
for(i=0; i<frames; i++) { | |
setSlice(i+1); | |
x_position += xspeed; | |
y_position += yspeed; | |
if ((x_position > (w-sizenum)) || (x_position < 0) ) { | |
xspeed*=-1; | |
x_position += xspeed*2; //avoids penetrating boundary | |
} | |
if ((y_position > (h-sizenum)) || (y_position < 0) ) { | |
yspeed*=-1; | |
y_position += yspeed*2; //avoids penetrating boundary | |
} | |
makeOval(x_position, y_position, sizenum, sizenum); | |
run("Fill", "slice"); | |
} | |
run("Select None"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
upgrade from the simple x only movement. Changes are as follows: