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

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

Introduction

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

Prototype

public final void setFillStyle(String fillStyleColor) 

Source Link

Document

Convenience method to set the context's fillStyle to a CssColor , specified in String form.

Usage

From source file:playn.html.HtmlImageLayerCanvas.java

License:Apache License

@Override
public void paint(Context2d ctx, float parentAlpha) {
    if (!visible() || !img.isReady())
        return;/* www  . j ava  2s .  co m*/

    ctx.save();
    transform(ctx);
    ctx.setGlobalAlpha(parentAlpha * alpha);

    float width = width();
    float height = height();
    if (repeatX || repeatY) {
        updatePattern(ctx);
        ctx.setFillStyle(pattern);
        ctx.beginPath();
        ctx.rect(0, 0, width, height);
        ctx.scale(repeatX ? 1 : width / img.width(), repeatY ? 1 : height / img.height());
        ctx.fill();
    } else {
        ((HtmlCanvas.Drawable) img).draw(ctx, 0, 0, width, height);
    }

    ctx.restore();
}

From source file:stroom.pipeline.structure.client.view.PipelineElementRenderer.java

License:Apache License

private void drawText(final Context2d ctx, final double x, final double y, final PipelineElement element) {
    final CssColor fill = CssColor.make(textColor);

    ctx.setFont(font);// w ww . jav  a 2s.c o m
    ctx.setTextAlign(TextAlign.LEFT);
    ctx.setFillStyle(fill);
    ctx.fillText(element.getId(), x, y);
}

From source file:stroom.widget.htree.client.RoundedRectangle.java

License:Apache License

public void draw(final Context2d ctx, final double x, final double y, final double width, final double height,
        final double radius, final FillStrokeStyle fill, final FillStrokeStyle stroke) {
    ctx.beginPath();/*from  w w w. j  a v a  2  s .  c om*/
    ctx.moveTo(x + radius, y);
    ctx.lineTo(x + width - radius, y);
    ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
    ctx.lineTo(x + width, y + height - radius);
    ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
    ctx.lineTo(x + radius, y + height);
    ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
    ctx.lineTo(x, y + radius);
    ctx.quadraticCurveTo(x, y, x + radius, y);
    ctx.closePath();

    if (fill != null) {
        ctx.setFillStyle(fill);
        ctx.fill();
    }

    if (stroke != null) {
        ctx.setStrokeStyle(stroke);
        ctx.stroke();
    }
}

From source file:stroom.widget.htree.client.TextCellRenderer.java

License:Apache License

private void drawText(final Context2d ctx, final Bounds bounds, final String text) {
    final CssColor fill = CssColor.make(textColor);

    ctx.setFont(font);//from  w  w  w.j  a  v  a  2s. c  om
    ctx.setTextAlign(TextAlign.LEFT);
    ctx.setFillStyle(fill);
    ctx.fillText(text, bounds.getX() + textPadding, bounds.getY() + textPadding + textSize - 1);
}

From source file:uk.co.threeonefour.ifictionary.engine.client.pages.level9game.Level9GameActivity.java

License:Apache License

protected void startGame() {

    Context2d context = view.getCanvas().getContext2d();
    int w = context.getCanvas().getWidth();
    int h = context.getCanvas().getHeight();
    context.setFillStyle("#" + Colour.WHITE.toHexString());
    context.fillRect(0, 0, w, h);//from  w w  w .j  av  a 2  s . c  o m

    icyVm.startGame();
    processVmOutput();

    view.getTextBox().setFocus(true);
}