示例#1
0
def mat_test(steps, fx, fy, mat_func):
    for d in range(steps):
        td.clear_plot(True)
        dx = fx(d, delta)
        dy = fy(d, delta)
        print(f"           by ({dx:2.4f}, {dy:2.4f})")
        m = mat_func(dx, dy)
        td.plot_points(xform_pt_list(m, myface_pt_list()), sizes, colors)
    input("\n<CR> to continue")
def myFunc(x, y):
    tm = trans_mat(x, y)
    a = xform_pt_list(tm, pts)
    td.clear_plot()
    draw_pts(a)
    wave(0, -45, -5, tm)
    wave(-45, 45, 5, tm)
    shrink(1, 11, lambda s: 1 + s / 20, tm)
    shrink(1, 11, lambda s: 1.5 - s / 10, tm)
def funny_face(x, y):
    for r in range(0, -45, -5):
        td.clear_plot(True)
        rm = rotate_mat(r)
        t = trans_mat(x, y)
        cm = mat_mat(t, rm)
        td.plot_points(mat_pt_list(cm, myface_pt_list()), sizes, colors)
        
    for r in range(-45, 45, 5):
        td.clear_plot(True)
        rm = rotate_mat(r)
        t = trans_mat(x, y)
        cm = mat_mat(t, rm)
        td.plot_points(mat_pt_list(cm, myface_pt_list()), sizes, colors)
        
    for s in range(1, 11):
        td.clear_plot(True)
        scale = 1 + s/20
        sm = scale_mat(scale, scale)
        t = trans_mat(x, y)
        cm = mat_mat(t, sm)
        td.plot_points(mat_pt_list(cm, myface_pt_list()), sizes, colors)
        
    for s in range(1, 11):
        td.clear_plot(True)
        scale = 1.5 - s / 10
        sm = scale_mat(scale, scale)
        t = trans_mat(x, y)
        cm = mat_mat(t, sm)
        td.plot_points(mat_pt_list(cm, myface_pt_list()), sizes, colors)
    return [mat_vec(m, v) for v in ptList]

"""
    Begin testing ...
"""

width = 800
height = 600
td.create_plot(width, height, True)
pts, sizes, colors = getMyFace()
td.plot_points(pts, sizes, colors)
input("A: Show the basic plot, <CR> to continue")

input("\nB: Mat_Mat Test: Scale first then rotate in 30 steps")
for i in range(0, 60, 2):
    td.clear_plot(True)
    r = rotate_mat(i)
    sx = 1 + i/2 * 0.01
    sy = 1 - 0.01 * i/2
    s = scale_mat(sx, sy)
    print(f"          scale: ({sx:3.2f}, {sy:3.2f})  then  rotate:{i:2}")
    cm = mat_mat(r, s)
    td.plot_points(mat_pt_list(cm, myface_pt_list()), sizes, colors)

input("\n<CR> to continue")
print("C: Mat_Mat Test: Rotate first then Scale in 30 steps")
for i in range(0, 60, 2):
    td.clear_plot(True)
    r = rotate_mat(i)
    sx = 1 + i/2 * 0.01
    sy = 1 - 0.01 * i/2
示例#5
0
def lmb(x, y):
    print(f'Rotate first: Left mouse click at: {x:4.2f} and {y:4.2f}')
    td.clear_plot(True)
    tm = trans_mat(x, y)
    cm = mat_mat(tm, r)
    td.plot_points(mat_pt_list(cm, myface_pt_list()), sizes, colors)
示例#6
0
def rmb(x, y):
    print(f'Translate first: Right mouse click at: {x:4.2f} and {y:4.2f}')
    td.clear_plot(True)
    tm = trans_mat(x, y)
    cm = mat_mat(r, tm)
    td.plot_points(mat_pt_list(cm, myface_pt_list()), sizes, colors)
def draw_at(x, y):
    print(f'Left mouse click at: {x:4.2f} and {y:4.2f}')
    td.clear_plot()
    t = trans_mat(x, y)
    newpts = mat_pt_list(t, ptList)
    td.plot_points(newpts, sizeList, colorList)
def draw_pts(p):
    td.clear_plot(True)
    td.plot_points(p, sizes, colors)