OLD | NEW |
(Empty) | |
| 1 function rad2deg(x) { |
| 2 return x * 180 / Math.PI; |
| 3 } |
| 4 |
| 5 function ellipseUsingArc(context, x, y, radiusX, radiusY, rotation, startAngle,
endAngle, anticlockwise) |
| 6 { |
| 7 var transform = new WebKitCSSMatrix(); |
| 8 transform = transform.translate(x, y); |
| 9 transform = transform.rotate(rad2deg(rotation)); |
| 10 transform = transform.scale(radiusX, radiusY); |
| 11 |
| 12 /* |
| 13 Use WebKitCSSMatrix instead of as follows, because using WebKitCSSMatrix com
putes float values more precisely. |
| 14 It is because we don't want to fail pixel comparison due to float precision. |
| 15 context.translate(x, y); |
| 16 context.rotate(rotation); |
| 17 context.scale(radiusX, radiusY); |
| 18 */ |
| 19 context.save(); |
| 20 context.transform(transform.a, transform.b, transform.c, transform.d, transf
orm.e, transform.f); |
| 21 context.arc(0, 0, 1, startAngle, endAngle, anticlockwise); |
| 22 context.restore(); |
| 23 } |
| 24 |
OLD | NEW |