OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad ius == other.m_radius; | 73 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad ius == other.m_radius; |
74 } | 74 } |
75 | 75 |
76 float BasicShapeCircle::floatValueForRadiusInBox(FloatSize boxSize) const | 76 float BasicShapeCircle::floatValueForRadiusInBox(FloatSize boxSize) const |
77 { | 77 { |
78 if (m_radius.type() == BasicShapeRadius::Value) | 78 if (m_radius.type() == BasicShapeRadius::Value) |
79 return floatValueForLength(m_radius.value(), hypotf(boxSize.width(), box Size.height()) / sqrtf(2)); | 79 return floatValueForLength(m_radius.value(), hypotf(boxSize.width(), box Size.height()) / sqrtf(2)); |
80 | 80 |
81 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boxS ize); | 81 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boxS ize); |
82 | 82 |
83 float widthDelta = std::abs(boxSize.width() - center.x()); | |
84 float heightDelta = std::abs(boxSize.height() - center.y()); | |
Bem Jones-Bey (adobe)
2015/02/19 23:06:29
I don't seem to me that these variables make anyth
| |
83 if (m_radius.type() == BasicShapeRadius::ClosestSide) | 85 if (m_radius.type() == BasicShapeRadius::ClosestSide) |
84 return std::min(std::min(center.x(), boxSize.width() - center.x()), std: :min(center.y(), boxSize.height() - center.y())); | 86 return std::min(std::min(std::abs(center.x()), widthDelta), std::min(std ::abs(center.y()), heightDelta)); |
85 | 87 |
86 // If radius.type() == BasicShapeRadius::FarthestSide. | 88 // If radius.type() == BasicShapeRadius::FarthestSide. |
87 return std::max(std::max(center.x(), boxSize.width() - center.x()), std::max (center.y(), boxSize.height() - center.y())); | 89 return std::max(std::max(center.x(), widthDelta), std::max(center.y(), heigh tDelta)); |
88 } | 90 } |
89 | 91 |
90 void BasicShapeCircle::path(Path& path, const FloatRect& boundingBox) | 92 void BasicShapeCircle::path(Path& path, const FloatRect& boundingBox) |
91 { | 93 { |
92 ASSERT(path.isEmpty()); | 94 ASSERT(path.isEmpty()); |
93 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun dingBox.size()); | 95 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun dingBox.size()); |
94 float radius = floatValueForRadiusInBox(boundingBox.size()); | 96 float radius = floatValueForRadiusInBox(boundingBox.size()); |
95 path.addEllipse(FloatRect( | 97 path.addEllipse(FloatRect( |
96 center.x() - radius + boundingBox.x(), | 98 center.x() - radius + boundingBox.x(), |
97 center.y() - radius + boundingBox.y(), | 99 center.y() - radius + boundingBox.y(), |
(...skipping 21 matching lines...) Expand all Loading... | |
119 const BasicShapeEllipse& other = toBasicShapeEllipse(o); | 121 const BasicShapeEllipse& other = toBasicShapeEllipse(o); |
120 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad iusX == other.m_radiusX && m_radiusY == other.m_radiusY; | 122 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad iusX == other.m_radiusX && m_radiusY == other.m_radiusY; |
121 } | 123 } |
122 | 124 |
123 float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius , float center, float boxWidthOrHeight) const | 125 float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius , float center, float boxWidthOrHeight) const |
124 { | 126 { |
125 if (radius.type() == BasicShapeRadius::Value) | 127 if (radius.type() == BasicShapeRadius::Value) |
126 return floatValueForLength(radius.value(), boxWidthOrHeight); | 128 return floatValueForLength(radius.value(), boxWidthOrHeight); |
127 | 129 |
128 if (radius.type() == BasicShapeRadius::ClosestSide) | 130 if (radius.type() == BasicShapeRadius::ClosestSide) |
129 return std::min(center, boxWidthOrHeight - center); | 131 return std::min(std::abs(center), boxWidthOrHeight > center ? boxWidthOr Height - center : center - boxWidthOrHeight); |
leviw_travelin_and_unemployed
2015/02/19 22:56:53
Same applies here?
| |
130 | 132 |
131 ASSERT(radius.type() == BasicShapeRadius::FarthestSide); | 133 ASSERT(radius.type() == BasicShapeRadius::FarthestSide); |
132 return std::max(center, boxWidthOrHeight - center); | 134 return std::max(center, boxWidthOrHeight > center ? boxWidthOrHeight - cente r : center - boxWidthOrHeight); |
leviw_travelin_and_unemployed
2015/02/19 22:56:53
Ditto?
| |
133 } | 135 } |
134 | 136 |
135 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) | 137 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) |
136 { | 138 { |
137 ASSERT(path.isEmpty()); | 139 ASSERT(path.isEmpty()); |
138 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun dingBox.size()); | 140 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun dingBox.size()); |
139 float radiusX = floatValueForRadiusInBox(m_radiusX, center.x(), boundingBox. width()); | 141 float radiusX = floatValueForRadiusInBox(m_radiusX, center.x(), boundingBox. width()); |
140 float radiusY = floatValueForRadiusInBox(m_radiusY, center.y(), boundingBox. height()); | 142 float radiusY = floatValueForRadiusInBox(m_radiusY, center.y(), boundingBox. height()); |
141 path.addEllipse(FloatRect( | 143 path.addEllipse(FloatRect( |
142 center.x() - radiusX + boundingBox.x(), | 144 center.x() - radiusX + boundingBox.x(), |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 && m_top == other.m_top | 277 && m_top == other.m_top |
276 && m_bottom == other.m_bottom | 278 && m_bottom == other.m_bottom |
277 && m_left == other.m_left | 279 && m_left == other.m_left |
278 && m_topLeftRadius == other.m_topLeftRadius | 280 && m_topLeftRadius == other.m_topLeftRadius |
279 && m_topRightRadius == other.m_topRightRadius | 281 && m_topRightRadius == other.m_topRightRadius |
280 && m_bottomRightRadius == other.m_bottomRightRadius | 282 && m_bottomRightRadius == other.m_bottomRightRadius |
281 && m_bottomLeftRadius == other.m_bottomLeftRadius; | 283 && m_bottomLeftRadius == other.m_bottomLeftRadius; |
282 } | 284 } |
283 | 285 |
284 } | 286 } |
OLD | NEW |