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

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

Introduction

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

Prototype

public final native void save() ;

Source Link

Document

Saves the context's state.

Usage

From source file:playn.html.HtmlImageLayerCanvas.java

License:Apache License

@Override
public void paint(Context2d ctx, float parentAlpha) {
    if (!visible() || !img.isReady())
        return;/* w w  w.  j  av a  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:playn.html.HtmlImmediateLayerCanvas.java

License:Apache License

@Override
void paint(Context2d ctx, float parentAlpha) {
    if (!visible())
        return;//from w w w .j  av  a2s  .  co m

    ctx.save();
    transform(ctx);
    ctx.setGlobalAlpha(parentAlpha * alpha);
    render(ctx);
    ctx.restore();
}

From source file:playn.html.HtmlSurfaceLayerCanvas.java

License:Apache License

@Override
void paint(Context2d ctx, float parentAlpha) {
    if (!visible())
        return;// w w w .  ja v  a 2  s .  com

    ctx.save();
    transform(ctx);

    ctx.setGlobalAlpha(parentAlpha * alpha);
    ctx.drawImage(canvas.canvas(), 0, 0);

    ctx.restore();
}