Example usage for com.google.gwt.canvas.dom.client Context2d arcTo

List of usage examples for com.google.gwt.canvas.dom.client Context2d arcTo

Introduction

In this page you can find the example usage for com.google.gwt.canvas.dom.client Context2d arcTo.

Prototype

public final native void arcTo(double x1, double y1, double x2, double y2, double radius) ;

Source Link

Document

Adds an arc to the current subpath, connecting it to the current point with a line segment.

Usage

From source file:forplay.html.HtmlPath.java

License:Apache License

void replay(Context2d ctx) {
    ctx.beginPath();/*from w w  w .j a va 2  s  .c om*/

    int len = list.length(), i = 0;
    double x = 0, y = 0;
    while (i < len) {
        switch ((int) list.get(i++)) {
        case CMD_MOVE: {
            x = list.get(i++);
            y = list.get(i++);
            ctx.moveTo(x, y);
            break;
        }
        case CMD_LINE: {
            x = list.get(i++);
            y = list.get(i++);
            ctx.lineTo(x, y);
            break;
        }
        case CMD_QUAD: {
            double cpx = list.get(i++);
            double cpy = list.get(i++);
            x = list.get(i++);
            y = list.get(i++);
            ctx.quadraticCurveTo(cpx, cpy, x, y);
            break;
        }
        case CMD_ARC: {
            double curX = x, curY = 0;
            double radius = list.get(i++);
            x = list.get(i++);
            y = list.get(i++);
            ctx.arcTo(curX, curY, x, y, radius);
            break;
        }
        case CMD_CLOSE: {
            ctx.closePath();
            break;
        }

        default:
            throw new AssertionError("Corrupt command list");
        }
    }
}