python - 使用 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()
解决方案
推荐阅读
- hadoop - 运行命令“hbase 类路径”时出错
- c++ - 在 sdl 中使用不同的 alpha 值绘图
- python - 我想使用 Cognito 的“子”值通过 lambda 触发器创建一个 Dynamodb 条目
- asp.net-mvc - openpgp.initWorker 不是函数
- html - 如何添加 100% 宽度和位置的按钮:固定
- node.js - 当文件路径具有带时间戳的文件夹时,fs.writeFile 不起作用
- r - 如何使用 RMongo 包将日期从 R 存储到 MongoDB?
- python - Anaconda Navigator:无法管理频道
- typescript - 在 react-scripts 中导入 react-app-env.d.ts 会破坏 tsc 构建
- c# - 调整窗口大小时裁剪图像