summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/script-tests/js-ellipse-implementation.js
blob: 7409a75839bca5a38fb4d6106dc5214567452594 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function rad2deg(x) {
  return x * 180 / Math.PI;
}

function ellipseUsingArc(context, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise)
{
    var transform = new WebKitCSSMatrix();
    transform = transform.translate(x, y);
    transform = transform.rotate(rad2deg(rotation));
    transform = transform.scale(radiusX, radiusY);

    /*
    Use WebKitCSSMatrix instead of as follows, because using WebKitCSSMatrix computes float values more precisely.
    It is because we don't want to fail pixel comparison due to float precision.
      context.translate(x, y);
      context.rotate(rotation);
      context.scale(radiusX, radiusY);
    */
    context.save();
    context.transform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);
    context.arc(0, 0, 1, startAngle, endAngle, anticlockwise);
    context.restore();
}