Example usage for com.google.gwt.dom.client CanvasElement getWidth

List of usage examples for com.google.gwt.dom.client CanvasElement getWidth

Introduction

In this page you can find the example usage for com.google.gwt.dom.client CanvasElement getWidth.

Prototype

public final native int getWidth() ;

Source Link

Document

Gets the width of the canvas.

Usage

From source file:com.badlogic.gdx.backends.gwt.GwtInput.java

License:Apache License

/** Kindly borrowed from PlayN. **/
protected int getRelativeX(NativeEvent e, CanvasElement target) {
    float xScaleRatio = target.getWidth() * 1f / target.getClientWidth(); // Correct for canvas CSS scaling
    return Math.round(xScaleRatio * (e.getClientX() - target.getAbsoluteLeft() + target.getScrollLeft()
            + target.getOwnerDocument().getScrollLeft()));
}

From source file:com.badlogic.gdx.backends.gwt.GwtInput.java

License:Apache License

protected int getRelativeX(Touch touch, CanvasElement target) {
    float xScaleRatio = target.getWidth() * 1f / target.getClientWidth(); // Correct for canvas CSS scaling
    return Math.round(xScaleRatio * touch.getRelativeX(target));
}

From source file:com.badlogic.gdx.graphics.Pixmap.java

License:Apache License

/** Draws an area form another Pixmap to this Pixmap.
 * /*from  w w  w . j  a  v  a2  s.  co  m*/
 * @param pixmap The other Pixmap
 * @param x The target x-coordinate (top left corner)
 * @param y The target y-coordinate (top left corner) */
public void drawPixmap(Pixmap pixmap, int x, int y) {
    CanvasElement image = pixmap.getCanvasElement();
    image(image, 0, 0, image.getWidth(), image.getHeight(), x, y, image.getWidth(), image.getHeight());
}

From source file:playn.html.HtmlGLContext.java

License:Apache License

HtmlGLContext(HtmlPlatform platform, WebGLRenderingContext gl, CanvasElement canvas) {
    super(platform, new HtmlGL20(gl), 1, canvas.getWidth(), canvas.getHeight(),
            HtmlUrlParameters.checkGLErrors);
    this.glc = gl;
    // try basic GL operations to detect failure cases early
    tryBasicGLCalls();/*from   w  ww  . j  av a2  s .c o m*/
    init();
    glc.pixelStorei(UNPACK_PREMULTIPLY_ALPHA_WEBGL, ONE);
}