我想为我的程序用红色绘制这个4瓣单元:
我需要能够分别绘制每条曲线,以便可以将它们加粗以使粗体白色图案显示在图片中。
我正在考虑将原点坐标放置在中心,并围绕该点绘制8个四分之一圆。
希望我只有1个函数,一个四分之一圆,并且可以重复该函数(例如,在y轴上镜像它),使所有8个都成。
但是,我不能用Tkinter或matlab做到这一点。
使用Tkinter一次只能绘制一个弧线(带有额外的线)。
Tkinter代码:
import tkinter as tk
root = tk.Tk()
canvas = tk.Canvas(root, width=300, height=200, bg='black')
canvas.pack(fill="both", expand=True)
canvas.create_arc(100, 100, 200, 200, start=0, extent=90, outline="white",style="pieslice")
root.mainloop()
使用Matlab,我只能通过最小化图形大小来制作“四分之一圆”,因此它只能显示我想要的窗口:
import math
import matplotlib.pyplot as plt
plt.figure()
xlist = np.linspace(0, 1.0, 100) # only in quadrant I
ylist = np.linspace(0, 1.0, 100)
X,Y = np.meshgrid(xlist, ylist)
F = X**2 + Y**2 - 1 # 'Circle Equation
plt.contour(X, Y, F, [0], colors = 'k', linestyles = 'solid')
plt.axes().set_aspect('equal')
plt.show()
任何帮助将不胜感激。
答案 0 :(得分:1)
我做到了, 使用style =“ arc”代替licelice并绘制4个半圆
import tkinter as tk
root = tk.Tk()
canvas = tk.Canvas(root, width=300, height=200, bg='black')
canvas.pack(fill="both", expand=True)
canvas.create_arc(100, 0, 200, 100, start=0, extent=-180, outline="white", style="arc")
canvas.create_arc(100, 100, 200, 200, start=0, extent=180, outline="white", style="arc")
canvas.create_arc(150, 50, 250, 150, start=90, extent=180, outline="white", style="arc")
canvas.create_arc(50, 50, 150, 150, start=90, extent=-180, outline="white", style="arc")
root.mainloop()
答案 1 :(得分:0)
您显示的图案基本是4个半圆,顺时针旋转90度。 您可以通过为方程x ^ 2 + y ^ 2-1-1设置极限来绘制半圆。