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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 } | 155 } |
156 | 156 |
157 void FloatRect::scale(float sx, float sy) | 157 void FloatRect::scale(float sx, float sy) |
158 { | 158 { |
159 m_location.setX(x() * sx); | 159 m_location.setX(x() * sx); |
160 m_location.setY(y() * sy); | 160 m_location.setY(y() * sy); |
161 m_size.setWidth(width() * sx); | 161 m_size.setWidth(width() * sx); |
162 m_size.setHeight(height() * sy); | 162 m_size.setHeight(height() * sy); |
163 } | 163 } |
164 | 164 |
165 float FloatRect::distanceFromPoint(const FloatPoint& p) | |
fs
2015/04/27 13:02:17
squaredDistance...
This is probably a bit to spec
| |
166 { | |
167 float closestX, closestY; | |
fs
2015/04/27 13:02:17
If you made this a FloatPoint, you wouldn't need t
| |
168 closestX = std::max(std::min(p.x(), maxX()), x()); | |
169 closestY = std::max(std::min(p.y(), maxY()), y()); | |
170 return powf(p.x() - closestX, 2) + powf(p.y() - closestY, 2); | |
171 } | |
172 | |
165 FloatRect unionRect(const Vector<FloatRect>& rects) | 173 FloatRect unionRect(const Vector<FloatRect>& rects) |
166 { | 174 { |
167 FloatRect result; | 175 FloatRect result; |
168 | 176 |
169 size_t count = rects.size(); | 177 size_t count = rects.size(); |
170 for (size_t i = 0; i < count; ++i) | 178 for (size_t i = 0; i < count; ++i) |
171 result.unite(rects[i]); | 179 result.unite(rects[i]); |
172 | 180 |
173 return result; | 181 return result; |
174 } | 182 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 return FloatRect(); | 217 return FloatRect(); |
210 | 218 |
211 float widthScale = destRect.width() / srcRect.width(); | 219 float widthScale = destRect.width() / srcRect.width(); |
212 float heightScale = destRect.height() / srcRect.height(); | 220 float heightScale = destRect.height() / srcRect.height(); |
213 return FloatRect(destRect.x() + (r.x() - srcRect.x()) * widthScale, | 221 return FloatRect(destRect.x() + (r.x() - srcRect.x()) * widthScale, |
214 destRect.y() + (r.y() - srcRect.y()) * heightScale, | 222 destRect.y() + (r.y() - srcRect.y()) * heightScale, |
215 r.width() * widthScale, r.height() * heightScale); | 223 r.width() * widthScale, r.height() * heightScale); |
216 } | 224 } |
217 | 225 |
218 } | 226 } |
OLD | NEW |