* @param {Array. >} points Like: [[23, 44], [53, 66], ...] * @param {Object} rect {x, y, width, height} * @return {Array. >} A new clipped points.
(points, rect)
| 18093 | * @return {Array.<Array.<number>>} A new clipped points. |
| 18094 | */ |
| 18095 | function clipPointsByRect(points, rect) { |
| 18096 | // FIXME: this way migth be incorrect when grpahic clipped by a corner. |
| 18097 | // and when element have border. |
| 18098 | return map(points, function (point) { |
| 18099 | var x = point[0]; |
| 18100 | x = mathMax$1(x, rect.x); |
| 18101 | x = mathMin$1(x, rect.x + rect.width); |
| 18102 | var y = point[1]; |
| 18103 | y = mathMax$1(y, rect.y); |
| 18104 | y = mathMin$1(y, rect.y + rect.height); |
| 18105 | return [x, y]; |
| 18106 | }); |
| 18107 | } |
| 18108 | |
| 18109 | /** |
| 18110 | * @param {Object} targetRect {x, y, width, height} |