首页 > 解决方案 > 使用 pyautogui 和数学在油漆中绘制棕褐色波

问题描述

我在 python 中实现绘制 tan 函数时遇到了困难,因为它看起来不平滑,当达到 90/180 时,它看起来不太好,所以我正在寻找这部分的一些改进。

def tan_wave():
    pyautogui.click()
    theta = 0
    step = 10
    length = 10
    curr_x, curr_y = pyautogui.position()
    prev = (curr_x, curr_y)
    decrease_flag = False
    while theta <= 180:
        if (theta % 90) == 0:
            theta -= 0.99999
            decrease_flag = True
        x = curr_x + theta
        y = curr_y - math.tan(math.radians(theta))*length
        print(x, y, theta)
        pyautogui.click(*prev)
        pyautogui.dragTo(x, y)
        pyautogui.click(x, y)
        prev = (x, y)
        if decrease_flag:
            theta += 0.99999
            decrease_flag = False
        theta += step
    print('Done')

tan_wave()

标签: pythonpython-3.xwindowstrigonometrypyautogui

解决方案


推荐阅读