我想用Tkinter复制加色剂。
我的职能:
def synthese(red,green,blue):
win2 = Tk()
win2.title("ADDITIVE COLOR")
win2.geometry("500x500")
win2.resizable(0,0)
hred = "#%02x%02x%02x" % (red, 0, 0) #RGB to Hexadecimal
hgreen = "#%02x%02x%02x" % (0, green, 0)
hblue = "#%02x%02x%02x" % (0, 0, blue)
r = 50
Width = 450
Height = 450
win3 = Canvas(win2, width = Width, height = Height, bg = 'white')
win3.pack(padx=5,pady=5)
win3.create_oval(10,150,300,440, outline=hred, fill=hred)
win3.create_oval(150,150,440,440, outline=hblue, fill=hblue)
win3.create_oval(75,10,375,300, outline=hgreen, fill=hgreen)
win2.mainloop()
我得到的是:
有可能合并颜色还是我需要找到碰撞区域?
使用PIL,你可以创建三个灰度层,画圆,并使用它们来创建预期的圆,但在黑色背景上。在
如果你使用倒置的图层,你会得到白色的背景,但有错误的圆圈。在
有了PIL,你甚至可以显示它或保存在文件中。在
下面是一种使用Numpy绘制附加RGB圆的方法。它使用PIL(Pill)将Numpy数据转换为Tkinter照片对象,并将结果显示在Tkinter标签中。我用黑色背景是因为我们在做加色混合。在
输出
您可以使用ImageChops添加图像。
所以你可以这样做:
输出:
相关问题 更多 >
编程相关推荐