python创建一个矩形rectangle_创建一个矩形,它是两个矩形相交的结果

我试图使两个矩形相交,但我不知道怎么做。

我上过两门课,点和色,效果很好。现在我正努力完成这个十字路口。这是我写的矩形类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

-在

-在

是的

我必须用标准库做任何事情

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值