我试图使两个矩形相交,但我不知道怎么做。
我上过两门课,点和色,效果很好。现在我正努力完成这个十字路口。这是我写的矩形类class Rectangle:
def __init__(self,Point,width,lenght,Color):
self.x = Point.x
self.y = Point.y
self.x1 = self.x + lenght
self.y1 = self.y + width
self.r = Color.r
self.g = Color.g
self.b = Color.b
self.w = width
self.l = lenght
我试过交集函数,但没用。我试过这样的方法
^{pr2}$
在这里,我在color类中定义了.mix函数。此函数的输入是现有的矩形self和另一个矩形r
我可以举个例子A is the rectangle that starts at (100,40), width 70, lenght 40 and color (200,200,200) and
B is the rectangle that starts at (120,90), width 40, lenght 60 and color (100,100,100)
you will get a rectangle starting at (120,90), width 20, lenght 20 and color (150,150,150)
请记住,我正在处理的轴是这样放置的
0-----X
-在
-在
是的
我必须用标准库做任何事情