本文整理汇总了Java中com.google.gwt.dom.client.CanvasElement.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java CanvasElement.getWidth方法的具体用法?Java CanvasElement.getWidth怎么用?Java CanvasElement.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.dom.client.CanvasElement
的用法示例。
在下文中一共展示了CanvasElement.getWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ZoomAnimation
import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
/**
* Animate zoom and tranlate on the HTML5 canvas, after the DisplayArea has zoomed in.
*
* @param context
* @param canvas_img
* the CanvasElement of the canvas to be animated
* @param cb
* callback for when the animation completes
* @param old_width
* the width of the viewport before zoom
* @param new_width
* the width of the viewport after zoom, in the same coordinates as old_width
* @param new_x
* x coordinate of the new viewport center, relative to the HTML5 canvas
* in the browser
* @param new_y
* y coordinate of the new viewport center, relative to the HTML5 canvas
* in the browser
*/
public ZoomAnimation(Context2d context, CanvasElement canvas_img,
AnimationCallback cb, int old_width, int new_width, int new_x, int new_y) {
this.context = context;
Canvas buffer = Canvas.createIfSupported();
Context2d buff_context = buffer.getContext2d();
buffer.setPixelSize(canvas_img.getWidth(), canvas_img.getHeight());
buffer.setCoordinateSpaceWidth(canvas_img.getWidth());
buffer.setCoordinateSpaceHeight(canvas_img.getHeight());
buff_context.drawImage(canvas_img, 0, 0);
this.canvas_img = buff_context.getCanvas();
scale = (double) old_width / new_width;
this.width_from = canvas_img.getWidth();
this.height_from = canvas_img.getHeight();
this.x_from = width_from / 2;
this.y_from = height_from / 2;
this.x_to = new_x;
this.y_to = new_y;
this.cb = cb;
}
示例2: animatedRedraw
import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
/**
* Redraw the canvas with HTML5 animation
*
* @param old_width
* width of viewport in base coordinates before any zoom
* operations
* @param center
* optional (x, y) center coordinates. Coordinates are relative
* to the HTML5 canvas in the broswer.
*/
public void animatedRedraw(int old_width, int... center) {
CanvasElement canv = viewport_context.getCanvas();
int x = center.length == 2 ? center[0] : canv.getWidth() / 2;
int y = center.length == 2 ? center[1] : canv.getHeight() / 2;
Animation anim = new ZoomAnimation(viewport_context, canv, cb,
old_width, area.viewportBaseWidth(), x, y);
anim.run(400);
}
示例3: HtmlImage
import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
public HtmlImage (Graphics gfx, Scale scale, CanvasElement elem, String source) {
super(gfx, scale, elem.getWidth(), elem.getHeight(), source, elem);
this.canvas = elem;
}
示例4: getRelativeX
import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
/** 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()));
}