Skip to content

Instantly share code, notes, and snippets.

@nst
Created March 22, 2025 11:34
Show Gist options
  • Save nst/4202d49f8303de4d3cedf96800ad5c14 to your computer and use it in GitHub Desktop.
Save nst/4202d49f8303de4d3cedf96800ad5c14 to your computer and use it in GitHub Desktop.
%!PS
<< /PageSize [320 240] >> setpagedevice
/Courier findfont 12 scalefont setfont
/sleep { 100000 mul {} repeat } def
/x 100 def
/y 50 def
/r 15 def
/x_ 2 def
/y_ 1 def
/f 0 def
{
% x bounce
x r sub 0 lt x r add 320 gt or {
/x_ x_ -1 mul def
} if
% y bounce
y r sub 0 lt y r add 240 gt or {
/y_ y_ -1 mul def
} if
% move circle
/x x x_ add def
/y y y_ add def
% clear page
1 setgray
0 0 320 240 rectfill
% draw circle
newpath
x y r 0 360 arc
1 0 1 setrgbcolor
fill
10 10 moveto
0 setgray
(frame ) dup 6 f 10 string cvs putinterval show
flushpage
10 sleep
/f f 1 add def
} loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment