OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2005 Nokia. All rights reserved. | 3 * Copyright (C) 2005 Nokia. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 } | 164 } |
165 | 165 |
166 void FloatRect::scale(float sx, float sy) | 166 void FloatRect::scale(float sx, float sy) |
167 { | 167 { |
168 m_location.setX(x() * sx); | 168 m_location.setX(x() * sx); |
169 m_location.setY(y() * sy); | 169 m_location.setY(y() * sy); |
170 m_size.setWidth(width() * sx); | 170 m_size.setWidth(width() * sx); |
171 m_size.setHeight(height() * sy); | 171 m_size.setHeight(height() * sy); |
172 } | 172 } |
173 | 173 |
174 float FloatRect::distanceTo(const FloatPoint& point) | |
175 { | |
176 float distance = 0.f; | |
177 if (point.x() < this->x()) { | |
fs
2016/01/13 10:22:03
I don't see the need for explicit this - here and
| |
178 if (point.y() < this->y()) | |
179 distance = (point - FloatPoint(this->x(), this->y())).diagonalLength Squared(); | |
fs
2016/01/13 10:22:03
FloatRect has minXMinYCorner (etc.) which would ma
| |
180 else if (point.y() > this->maxY()) | |
181 distance = (point - FloatPoint(this->x(), this->maxY())).diagonalLen gthSquared(); | |
fs
2016/01/13 10:22:03
The 'corner' areas compute the squared distance wh
| |
182 else | |
183 distance = this->x() - point.x(); | |
184 } else if (point.x() > this->maxX()) { | |
185 if (point.y() < this->y()) | |
186 distance = (point - FloatPoint(this->maxX(), this->y())).diagonalLen gthSquared(); | |
187 else if (point.y() > this->maxY()) | |
188 distance = (point - FloatPoint(this->maxX(), this->maxY())).diagonal LengthSquared(); | |
189 else | |
190 distance = point.x() - this->maxX(); | |
191 } else { | |
192 if (point.y() < this->y()) | |
193 distance = this->y() - point.y(); | |
194 else if (point.y() > this->maxY()) | |
195 distance = point.y() - this->maxY(); | |
196 else | |
197 distance = 0.f; | |
198 } | |
199 | |
200 return distance; | |
201 } | |
202 | |
174 FloatRect unionRect(const Vector<FloatRect>& rects) | 203 FloatRect unionRect(const Vector<FloatRect>& rects) |
175 { | 204 { |
176 FloatRect result; | 205 FloatRect result; |
177 | 206 |
178 size_t count = rects.size(); | 207 size_t count = rects.size(); |
179 for (size_t i = 0; i < count; ++i) | 208 for (size_t i = 0; i < count; ++i) |
180 result.unite(rects[i]); | 209 result.unite(rects[i]); |
181 | 210 |
182 return result; | 211 return result; |
183 } | 212 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 return FloatRect(); | 247 return FloatRect(); |
219 | 248 |
220 float widthScale = destRect.width() / srcRect.width(); | 249 float widthScale = destRect.width() / srcRect.width(); |
221 float heightScale = destRect.height() / srcRect.height(); | 250 float heightScale = destRect.height() / srcRect.height(); |
222 return FloatRect(destRect.x() + (r.x() - srcRect.x()) * widthScale, | 251 return FloatRect(destRect.x() + (r.x() - srcRect.x()) * widthScale, |
223 destRect.y() + (r.y() - srcRect.y()) * heightScale, | 252 destRect.y() + (r.y() - srcRect.y()) * heightScale, |
224 r.width() * widthScale, r.height() * heightScale); | 253 r.width() * widthScale, r.height() * heightScale); |
225 } | 254 } |
226 | 255 |
227 } | 256 } |
OLD | NEW |