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

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

Introduction

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

Prototype

public final native void arc(double x, double y, double radius, double startAngle, double endAngle,
        boolean anticlockwise) ;

Source Link

Document

Draws an arc.

Usage

From source file:anagram.client.Ball.java

License:Apache License

public void draw(Context2d context) {
    context.setFillStyle(color);/*from w  ww . j ava2s . co m*/
    context.beginPath();
    context.arc(pos.x, pos.y, radius, 0, Math.PI * 2.0, true);
    context.closePath();
    context.fill();
}

From source file:anagram.client.Lens.java

License:Apache License

public void draw(Context2d back, Context2d front) {
    front.drawImage(back.getCanvas(), 0, 0);

    if (!GWT.isScript()) {
        // in devmode this effect is slow so we disable it here
    } else {//www.j a  v a2s . c  o  m
        ImageData frontData = front.getImageData((int) (pos.x - radius), (int) (pos.y - radius), 2 * radius,
                2 * radius);
        CanvasPixelArray frontPixels = frontData.getData();
        ImageData backData = back.getImageData((int) (pos.x - radius), (int) (pos.y - radius), 2 * radius,
                2 * radius);
        CanvasPixelArray backPixels = backData.getData();
        int srcIdx, dstIdx;
        for (int i = lensArray.length - 1; i >= 0; i--) {
            dstIdx = 4 * lensArray[i][0];
            srcIdx = 4 * lensArray[i][1];
            frontPixels.set(dstIdx + 0, backPixels.get(srcIdx + 0));
            frontPixels.set(dstIdx + 1, backPixels.get(srcIdx + 1));
            frontPixels.set(dstIdx + 2, backPixels.get(srcIdx + 2));
        }
        front.putImageData(frontData, (int) (pos.x - radius), (int) (pos.y - radius));
    }

    front.setStrokeStyle(strokeStyle);
    front.beginPath();
    front.arc(pos.x, pos.y, radius, 0, Math.PI * 2, true);
    front.closePath();
    front.stroke();
}

From source file:gwt.g2d.client.graphics.visitor.CircleVisitor.java

License:Apache License

@Override
public void visit(Surface surface) {
    Context2d context = surface.getContext();
    context.arc(x, y, radius, 0, MathHelper.TWO_PI, true);
}

From source file:gwt.g2d.client.graphics.visitor.EllipseVisitor.java

License:Apache License

@Override
public void visit(Surface surface) {
    Context2d context = surface.getContext();
    context.save();//from  ww w  .  j a  va  2  s .  c om
    context.translate(x + width / 2, y + height / 2);
    context.scale(width / 2, height / 2);
    context.arc(0, 0, 1, 0, MathHelper.TWO_PI, true);
    context.restore();
}

From source file:org.cesiumjs.cs.scene.interaction.MarkerGroup.java

License:Apache License

public static BillboardOptions createBillboard(DrawInteractionOptions options) {
    Canvas canvas = Canvas.createIfSupported();
    Context2d context = canvas.getContext2d();

    context.setFillStyle(options.color.toCssColorString());
    context.setStrokeStyle(options.outlineColor.toCssColorString());
    context.setLineWidth(options.outlineWidth);

    context.translate(canvas.getCoordinateSpaceWidth() / 2, canvas.getCoordinateSpaceHeight() / 2);
    context.beginPath();/*  w  w  w. j  av a2s  .  co  m*/
    context.arc(0, 0, options.pixelSize, 0, Math.PI * 2, true);
    context.closePath();
    context.stroke();
    context.fill();

    BillboardOptions billboard = new BillboardOptions();
    billboard.horizontalOrigin = HorizontalOrigin.CENTER();
    billboard.verticalOrigin = VerticalOrigin.CENTER();
    billboard.imageCanvas = canvas.getCanvasElement();
    return billboard;
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.ParticleSystemFireworks.java

License:Apache License

private CanvasElement getImage() {
    if (!Cesium.defined(particleCanvas)) {
        particleCanvas = RootPanel.get().getElement().getOwnerDocument().createCanvasElement();
        particleCanvas.setWidth(20);/*w ww  .  ja va2 s  .com*/
        particleCanvas.setHeight(20);
        Context2d context2d = particleCanvas.getContext2d();
        context2d.beginPath();
        context2d.arc(8, 8, 8, 0, Math.TWO_PI(), true);
        context2d.closePath();
        context2d.setFillStyle("rgb(255, 255, 255)");
        context2d.fill();
        Cesium.log(particleCanvas);
    }
    return particleCanvas;
}

From source file:org.cruxframework.crux.widgets.client.colorpicker.SaturationLightnessPicker.java

License:Apache License

private void drawGradient(boolean drawHandle) {
    Context2d ctx = canvas.getContext2d();

    // draw gradient
    for (int x = 0; x <= 179; x++) {
        CanvasGradient grad = ctx.createLinearGradient(x, 0, x, 179);
        int s = Math.round(x * 100 / 179);
        String hex = ColorUtils.hsl2hex(hue, s, 0);
        grad.addColorStop(0, "#" + hex);
        hex = ColorUtils.hsl2hex(hue, s, 100);
        grad.addColorStop(1, "#" + hex);
        ctx.setFillStyle(grad);/*ww w.ja v a2 s.c o  m*/
        ctx.fillRect(x, 0, 1, 180);
    }

    // draw handle
    if (drawHandle) {
        ctx.beginPath();
        ctx.arc(handleX, handleY, 3, 0, Math.PI * 2, false);
        ctx.closePath();
        ctx.setFillStyle("#ffffff");
        ctx.fill();

        ctx.beginPath();
        ctx.arc(handleX, handleY, 2, 0, Math.PI * 2, false);
        ctx.closePath();
        ctx.setFillStyle("#000000");
        ctx.fill();
    }
}

From source file:org.teavm.samples.benchmark.gwt.BenchmarkStarter.java

License:Apache License

private void render() {
    Context2d context = canvas.getContext2d();
    context.setFillStyle("white");
    context.setStrokeStyle("grey");
    context.fillRect(0, 0, 600, 600);//from  w  w w . j  ava2 s . c o m
    context.save();
    context.translate(0, 600);
    context.scale(1, -1);
    context.scale(100, 100);
    context.setLineWidth(0.01);
    for (Body body = scene.getWorld().getBodyList(); body != null; body = body.getNext()) {
        Vec2 center = body.getPosition();
        context.save();
        context.translate(center.x, center.y);
        context.rotate(body.getAngle());
        for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
            Shape shape = fixture.getShape();
            if (shape.getType() == ShapeType.CIRCLE) {
                CircleShape circle = (CircleShape) shape;
                context.beginPath();
                context.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
                context.closePath();
                context.stroke();
            } else if (shape.getType() == ShapeType.POLYGON) {
                PolygonShape poly = (PolygonShape) shape;
                Vec2[] vertices = poly.getVertices();
                context.beginPath();
                context.moveTo(vertices[0].x, vertices[0].y);
                for (int i = 1; i < poly.getVertexCount(); ++i) {
                    context.lineTo(vertices[i].x, vertices[i].y);
                }
                context.closePath();
                context.stroke();
            }
        }
        context.restore();
    }
    context.restore();
}