#! /bin/usr/python3 # Test program for module {timing_path} # Last edited on 2021-05-30 01:45:04 by jstolfi import timing_path import move import move_parms import path import hacks import job_parms import rn import pyx import sys from math import sqrt, sin, cos, floor, ceil, pi, nan, inf parms = job_parms.typical_js() parms['solid_raster_width'] = 1.00 parms['contour_trace_width'] = 0.50 mp_jump = move_parms.make_for_jumps(parms) mp_cont = move_parms.make_for_contours(parms) mp_fill = move_parms.make_for_fillings(parms) wd_fill = move_parms.width(mp_fill) def do_plot(OPHS, tag): # Plots the path {oph} to "tests/out/timing_path_TST_{tag}.{ext}". nph = len(OPHS) # Find bbox B = path.bbox(OPHS) c, szx, szy = hacks.make_canvas(B, dp, True, True, 1, 1) ystep = szy ctraces = pyx.color.rgb(0.050, 0.850, 0.000) # Nominal trace area color. rwd = 0.80 wd_axes = 0.05*wd_fill axes = True dots = True arrows = False matter = False for k in range(nph): dp = (0, k*ystep) path.plot_standard(c, [OPHS[k],], dp, None, [ctraces,], rwd, wd_axes, axes, dots, arrows, matter) hacks.write_plot(c, ("tests/out/timing_path_TST_" + tag)) return # ---------------------------------------------------------------------- def test_stair(m, nx, ny, ang): wd = wd_fill xd = 5*wd yd = 3*wd pt = (1,1) OPHS = [] for jmp, udnoz in (True, False), (True, True), (False,False),: oph = timing_path.stair(pt, m, nx, xd, ny, yd, ang, jmp, udnoz, mp_fill, mp_jump) OPHS.append(oph) tag = "stair_m%02d_nx%02d_ny%02d_ang%03d" % (m,nx,ny,int(floor(ang+0.5))) do_plot(OPHS, tag) return # ---------------------------------------------------------------------- def test_zigzag(n, ang): wd = wd_fill d = 4*wd pt = (1,1) OPHS = [] for jmp, udnoz in (True, False), (True, True), (False,False),: oph = timing_path.zigzag(pt, n, d, ang, jmp, udnoz, mp_fill, mp_jump) OPHS.append(oph) tag = "zigzag_n%02d_ang%03d" % (n,int(floor(ang+0.5))) do_plot(OPHS, tag) return # ---------------------------------------------------------------------- def test_greek(n, ang): wd = wd_fill xd = 4*wd yd = 3*wd pt = (1,1) OPHS = [] for jmp, udnoz in (True, False), (True, True), (False,False),: oph = timing_path.greek(pt, n, xd, yd, ang, jmp, udnoz, mp_fill, mp_jump) OPHS.append(oph) tag = "greek_n%02d_ang%03d" % (n,int(floor(ang+0.5))) do_plot(OPHS, tag) return # ---------------------------------------------------------------------- def test_starry(n, bend): wd = wd_fill d = 3*wd ctr = (0,0) OPHS = [] for jmp, udnoz in (True, False), (True, True), (False,False),: oph = timing_path.starry(ctr, n, d, bend, jmp, udnoz, mp_fill, mp_jump) OPHS.append(oph) tag = "starry_n%02d_ang%03d" % (n,int(floor(bend+0.5))) do_plot(OPHS, tag) return # ---------------------------------------------------------------------- test_starry(17, 0) test_starry(27, 120) test_greek(9, 0) test_greek(9, 30) test_zigzag(5, 0) test_zigzag(5, 30) test_stair(2, 3,2, 0, True, False) test_stair(2, 3,2, 0, True, True ) test_stair(2, 3,2, 0, False, False) test_stair(2, 3,2, 30, False, False) test_stair(0, 3,0, 0, True, False) test_stair_pair(2, 3,2, 0, True, False)