java会计算矩形,其中一个在另一个内部相交,并且当我调用intersection(Rectangle)时返回一个较小的矩形交叉点?
答案 0 :(得分:1)
<强>返回强>:
指定的Rectangle
和此Rectangle
Rectangle
据我所知,结果将是较小的Rectangle
。
答案 1 :(得分:1)
scala> import java.awt.Rectangle
import java.awt.Rectangle
scala> val big = new Rectangle(0, 0, 10, 10)
big: java.awt.Rectangle = java.awt.Rectangle[x=0,y=0,width=10,height=10]
scala> val small = new Rectangle(2, 2, 3, 3)
small: java.awt.Rectangle = java.awt.Rectangle[x=2,y=2,width=3,height=3]
scala> big.intersection(small)
res0: java.awt.Rectangle = java.awt.Rectangle[x=2,y=2,width=3,height=3]
scala> small.intersection(big)
res1: java.awt.Rectangle = java.awt.Rectangle[x=2,y=2,width=3,height=3]