Write a program that enables the user to add and remove points in a two-dimensional plane dynamically, as shown in Figure 15.31a. A minimum bounding rectangle is updated as the points are added and removed. Assume the radius of each point is 10 pixels.在一个画布中,左键添加圆圈,如果圆圈不在画布内则扩大画布(rectangle)的范围;右键删除圆圈,如果删除的是边界上的则缩小画布范围。问题是,如果要缩小,边界该怎么检测的?需要什么复杂的数据结构吗?
2 回答
慕田峪9158850
TA贡献1794条经验 获得超7个赞
把里边圆圈的位置 存储为一个有序数组(递增为例),删除添加都操作数组并重新排序
data = [ { top:10, left:100 } ...]
添加回答
举报
0/150
提交
取消