#!/usr/bin/ruby include Math def clock(h, m) name = sprintf("%02d%02d.ps", h, m) open(name, "w") do |fp| fp.print "%!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 90 90 /CenterString { gsave newpath 0 0 moveto false charpath flattenpath pathbbox 3 2 roll sub -0.5 mul 3 1 roll sub 0.5 mul exch grestore rmoveto } def /Helvetica findfont 8 scalefont setfont 0.5 setgray 0.5 setlinewidth 45 45 42 0 360 arc closepath stroke 0.9 0.9 1 setrgbcolor 45 45 42 0 360 arc closepath fill 1 setlinewidth 0 setgray " xb = yb = 45.0 (0..59).each do |n| sn = sin(PI / 30 * (15 - n)) cs = cos(PI / 30 * (15 - n)) if n % 5 == 0 xs = xb + 28.0 * cs ys = xb + 28.0 * sn xe = xb + 32.0 * cs ye = xb + 32.0 * sn xt = xb + 38.0 * cs yt = xb + 38.0 * sn nn = (n == 0 ? 12 : (n / 5)) fp.printf("%.3f %.3f moveto (%d) dup CenterString show\n", xt, yt, nn) else xs = xb + 29.0 * cs ys = xb + 29.0 * sn xe = xb + 31.0 * cs ye = xb + 31.0 * sn end fp.printf("%.3f %.3f moveto %.3f %.3f lineto stroke\n", xs, ys, xe, ye) end rot_h = sprintf("%.3f", -((h % 12) * 30.0 + 0.5 * m)) rot_m = sprintf("%.3f", -6.0 * m) fp.print "0.6 0 0 setrgbcolor gsave #{xb} #{yb} translate #{rot_h} rotate 2 0 moveto 0.5 26 lineto -0.5 26 lineto -2 0 lineto closepath fill grestore gsave #{xb} #{yb} translate #{rot_m} rotate 2 0 moveto 0.5 35 lineto -0.5 35 lineto -2 0 lineto closepath fill grestore newpath 0.5 setgray 45 45 3 0 360 arc closepath stroke 45 45 3 0 360 arc closepath 1 1 0 setrgbcolor fill showpage %%EOF " end end (0..11).each do |h| (0..3).each do |i| m = i * 15 clock(h, m) end end