• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CanvasElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.gwt.dom.client.CanvasElement的典型用法代码示例。如果您正苦于以下问题:Java CanvasElement类的具体用法?Java CanvasElement怎么用?Java CanvasElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CanvasElement类属于com.google.gwt.dom.client包,在下文中一共展示了CanvasElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setFullscreenJSNI

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
private native boolean setFullscreenJSNI(GwtGraphics graphics, CanvasElement element) /*-{
	if (element.webkitRequestFullScreen) {
		element.width = $wnd.screen.width;
		element.height = $wnd.screen.height;
		element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
		$doc
				.addEventListener(
						"webkitfullscreenchange",
						function() {
							[email protected]::fullscreenChanged()();
						}, false);
		return true;
	}
	if (element.mozRequestFullScreen) {
		element.width = $wnd.screen.width;
		element.height = $wnd.screen.height;
		element.mozRequestFullScreen();
		$doc
				.addEventListener(
						"mozfullscreenchange",
						function() {
							[email protected]::fullscreenChanged()();
						}, false);
		return true;
	}
	return false;
}-*/;
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:28,代码来源:GwtGraphics.java


示例2: getContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/**
 * Returns a WebGL context for the given canvas element. Returns null if no 3d
 * context is available.
 */
public static native WebGLRenderingContext getContext(CanvasElement canvas, WebGLContextAttributes attributes) /*-{
  var names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-webgl", "webkit-3d"];
  for (var i = 0; i < names.length; i++) {
    try {
      var ctx = canvas.getContext(names[i], attributes);
      if (ctx != null) {
        // Hook for the semi-standard WebGLDebugUtils script.
        if ($wnd.WebGLDebugUtils) {
          if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled');
          return $wnd.WebGLDebugUtils.makeDebugContext(ctx);
        }
        return ctx;
      }
    } catch(e) {
    }
  }
  return null;
}-*/;
 
开发者ID:playn,项目名称:playn,代码行数:23,代码来源:WebGLRenderingContext.java


示例3: createContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/**
 * Creates a WebGL 1.0 context upon a canvas element using the specified context attributes. This method alerts the
 * user if there is no WebGL support and also redirects the browser to <a href="http://get.webgl.org/">get.webgl.org
 * </a>.
 *
 * @param canvas     The canvas element to creeate the context upon.
 * @param attributes The context attributes to request the context with.
 *
 * @return The created WebGL context object.
 */
public static native WebGLContext createContext(CanvasElement canvas, WebGLContext.Attributes attributes) /*-{
    try
    {
        if (attributes)
            $wnd.gl = canvas.getContext("webgl", attributes) || canvas.getContext("experimental-webgl", attributes);
        else
            $wnd.gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");

        $wnd.attribs = $wnd.gl.getContextAttributes();
        $wnd.glv = 1.0;
    }
    catch (e)
    {
        alert(e);

        $wnd.alert("Your browser doesn't appear to support WebGL. Try upgrading your browser.");
        $wnd.location.href = 'http://get.webgl.org/';
    }

    return $wnd.context = {
        gl: $wnd.gl,
        attribs: $wnd.attribs,
        glv: $wnd.glv
    };
}-*/;
 
开发者ID:sriharshachilakapati,项目名称:WebGL4J,代码行数:36,代码来源:WebGL10.java


示例4: createContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
public static native WebGLContext createContext(CanvasElement canvas, WebGLContext.Attributes attributes) /*-{
    try
    {
        if (attributes)
            $wnd.gl = canvas.getContext("webgl2", attributes) || canvas.getContext("experimental-webgl2", attributes);
        else
            $wnd.gl = canvas.getContext("webgl2") || canvas.getContext("experimental-webgl2");

        $wnd.attribs = $wnd.gl.getContextAttributes();
        $wnd.glv = 2.0;
    }
    catch (e)
    {
        alert(e);

        $wnd.alert("Your browser doesn't appear to support WebGL 2. Try upgrading your browser.");
        $wnd.location.href = 'http://get.webgl.org/';
    }

    return $wnd.context = {
        gl: $wnd.gl,
        attribs: $wnd.attribs,
        glv: $wnd.glv
    };
}-*/;
 
开发者ID:sriharshachilakapati,项目名称:WebGL4J,代码行数:26,代码来源:WebGL20.java


示例5: getContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/**
 * Returns a WebGL context for the given canvas element. Returns null if no 3d
 * context is available.
 */
public static native WebGLRenderingContext getContext(CanvasElement canvas, WebGLContextAttributes attributes) /*-{
  var names = ["experimental-webgl", "webgl", "moz-webgl", "webkit-webgl", "webkit-3d"];
  for (var i = 0; i < names.length; i++) {
    try {
      var ctx = canvas.getContext(names[i], attributes);
      if (ctx != null) {
        // Hook for the semi-standard WebGLDebugUtils script.
        if ($wnd.WebGLDebugUtils) {
          if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled');
          return $wnd.WebGLDebugUtils.makeDebugContext(ctx);
        }
        return ctx;
      }
    } catch(e) {
    }
  }
  return null;
}-*/;
 
开发者ID:fredsa,项目名称:forplay,代码行数:23,代码来源:WebGLRenderingContext.java


示例6: prepareMissingTileImage

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
private CanvasElement prepareMissingTileImage() {
	int tileSize = DjvuContext.getTileSize();
	CanvasElement canvas = createImage(tileSize, tileSize);
	Context2d context2d = canvas.getContext2d();
	context2d.setFillStyle("white");
	context2d.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
	Image image = new Image();
	final ImageElement imageElement = image.getElement().cast();
	imageElement.getStyle().setProperty("visibility", "hidden");
	Event.setEventListener(imageElement, event -> {
		if (Event.ONLOAD == event.getTypeInt()) {
			missingTileImage.getContext2d().drawImage(imageElement, 0, 0);
			RootPanel.get().getElement().removeChild(imageElement);
		}
	});
	RootPanel.get().getElement().appendChild(imageElement);
	image.setUrl(getBlankImageUrl());
	return canvas;
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:20,代码来源:DataStore.java


示例7: setTile

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
public void setTile(TileInfo tileInfo, GMap bufferGMap) {
	if (bufferImageData == null || bufferImageData.getWidth() != bufferGMap.getDataWidth()
			|| bufferImageData.getHeight() != bufferGMap.getDataHeight()) {
		bufferImageData = bufferCanvas.getContext2d()
				.createImageData(bufferGMap.getDataWidth(), bufferGMap.getDataHeight());
	}
	Uint8Array imageArray = bufferImageData.getData().cast();
	imageArray.set(bufferGMap.getImageData());
	bufferCanvas.getContext2d().putImageData(bufferImageData, -bufferGMap.getBorder(), 0);

	CanvasElement tile = tiles.get(tileInfo);
	if (tile == null) {
		tile = createImage(bufferGMap.getDataWidth() - bufferGMap.getBorder(), bufferGMap.getDataHeight());
		tiles.put(new TileInfo(tileInfo), tile);
	}
	Context2d c = tile.getContext2d();
	c.setFillStyle("white");
	c.fillRect(0, 0, tileSize, tileSize);
	c.drawImage(bufferCanvas, 0, 0);
	for (Consumer<Integer> listener : tileListeners)
		listener.accept(tileInfo.page);
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:23,代码来源:DataStore.java


示例8: createImage

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
public static CanvasElement createImage(int width, int height) {
	Canvas canvas = Canvas.createIfSupported();
	canvas.setWidth(width + "px");
	canvas.setCoordinateSpaceWidth(width);
	canvas.setHeight(height + "px");
	canvas.setCoordinateSpaceHeight(height);
	return canvas.getCanvasElement();
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:9,代码来源:DataStore.java


示例9: setFullscreenJSNI

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
private native boolean setFullscreenJSNI (GwtGraphics graphics, CanvasElement element) /*-{
if(element.webkitRequestFullScreen) {
element.width = $wnd.screen.width;
element.height = $wnd.screen.height;
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
$doc.addEventListener("webkitfullscreenchange", function() {
[email protected]::fullscreenChanged()();
}, false);
return true;
}
if(element.mozRequestFullScreen) {
element.width = $wnd.screen.width;
element.height = $wnd.screen.height;
element.mozRequestFullScreen();
$doc.addEventListener("mozfullscreenchange", function() {
[email protected]::fullscreenChanged()();
}, false);
return true;
}
return false;
}-*/;
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:GwtGraphics.java


示例10: setCursorCatchedJSNI

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/** from https://github.com/toji/game-shim/blob/master/game-shim.js
 * @param element Canvas */
private native void setCursorCatchedJSNI (CanvasElement element) /*-{
	// Navigator pointer is not the right interface according to spec.
	// Here for backwards compatibility only
	if (!navigator.pointer) {
		navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
	}
	// element.requestPointerLock
	if (!element.requestPointerLock) {
		element.requestPointerLock = (function() {
			return element.webkitRequestPointerLock
					|| element.mozRequestPointerLock || function() {
						if (navigator.pointer) {
							navigator.pointer.lock(element);
						}
					};
		})();
	}
	element.requestPointerLock();
}-*/;
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:GwtInput.java


示例11: getContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/** Returns a WebGL context for the given canvas element. Returns null if no 3d context is available. */
public static native WebGLRenderingContext getContext (CanvasElement canvas, WebGLContextAttributes attributes) /*-{
																																						var names = ["experimental-webgl", "webgl", "moz-webgl", "webkit-webgl", "webkit-3d"];
																																						for (var i = 0; i < names.length; i++) {
																																						try {
																																						var ctx = canvas.getContext(names[i], attributes);
																																						if (ctx != null) {
																																						// Hook for the semi-standard WebGLDebugUtils script.
																																						if ($wnd.WebGLDebugUtils) {
																																						if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled');
																																						return $wnd.WebGLDebugUtils.makeDebugContext(ctx);
																																						}
																																						return ctx;
																																						}
																																						} catch(e) {
																																						}
																																						}
																																						return null;
																																						}-*/;
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:WebGLRenderingContext.java


示例12: setCursorCatchedJSNI

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/**
 * from https://github.com/toji/game-shim/blob/master/game-shim.js
 * 
 * @param element Canvas
 */
private native void setCursorCatchedJSNI(CanvasElement element) /*-{
	// Navigator pointer is not the right interface according to spec.
	// Here for backwards compatibility only
	if (!navigator.pointer) {
		navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
	}
	// element.requestPointerLock
	if (!element.requestPointerLock) {
		element.requestPointerLock = (function() {
			return element.webkitRequestPointerLock
					|| element.mozRequestPointerLock || function() {
						if (navigator.pointer) {
							navigator.pointer.lock(element);
						}
					};
		})();
	}
	element.requestPointerLock();
}-*/;
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:25,代码来源:GwtInput.java


示例13: 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;
}
 
开发者ID:jhu-digital-manuscripts,项目名称:rosa,代码行数:48,代码来源:ZoomAnimation.java


示例14: addAreaClickListener

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
private void addAreaClickListener(final ColorfillAreaClickListener listener) {
    interactionHandlerFactory.applyUserClickHandler(new Command() {

        @Override
        public void execute(NativeEvent event) {
            event.preventDefault();
            CanvasElement canvasElement = canvasStubView.getCanvas().getCanvasElement();
            Area area = new Area(positionHelper.getXPositionRelativeToTarget(event, canvasElement), positionHelper.getYPositionRelativeToTarget(event,
                    canvasElement));
            if (area.getX() >= 0 && area.getY() >= 0) {
                listener.onAreaClick(area);
            }
        }
    }, canvasStubView.getCanvas());
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:16,代码来源:ColorfillCanvasImpl.java


示例15: onModuleLoad

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
public void onModuleLoad() {
    canvas = Canvas.createIfSupported();
    if (canvas == null) {
        Window.alert("Canvas not supported");
        return;
    }
    RootPanel.get("screen").add(canvas);

    CanvasElement el = canvas.getCanvasElement();
    el.setWidth(960);
    el.setHeight(540);

    Context2d ctx = canvas.getContext2d();
    setupContext(ctx);
    ctx.scale(3, 3);

    RootPanel.get().addDomHandler(this, KeyDownEvent.getType());

    font = new Image("images/font.png");
    fontElement = ImageElement.as(font.getElement());

    audio = Audio.createIfSupported();

    game = new Game(this);
    game.pushState(new WelcomeState(game));

    new Timer() {
        @Override
        public void run() {
            game.handleEvent();
            game.update();
            game.draw();
        }
    }.scheduleRepeating(50);
}
 
开发者ID:czak,项目名称:retronix,代码行数:36,代码来源:Application.java


示例16: getImage

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
private CanvasElement getImage() {
    if (!Cesium.defined(particleCanvas)) {
        particleCanvas = RootPanel.get().getElement().getOwnerDocument().createCanvasElement();
        particleCanvas.setWidth(20);
        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;
}
 
开发者ID:iSergio,项目名称:gwt-cs,代码行数:16,代码来源:ParticleSystemFireworks.java


示例17: HtmlCanvas

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
HtmlCanvas(CanvasElement canvas, int width, int height) {
  this.canvas = canvas;
  this.width = width;
  this.height = height;
  canvas.setWidth(width);
  canvas.setHeight(height);
  ctx = canvas.getContext2d();
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:9,代码来源:HtmlCanvas.java


示例18: HtmlCanvasLayerDom

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
HtmlCanvasLayerDom(int width, int height) {
  super(Document.get().createCanvasElement());

  CanvasElement canvas = element().cast();
  canvas.setWidth(width);
  canvas.setHeight(height);

  this.canvas = new HtmlCanvas(canvas, width, height);
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:10,代码来源:HtmlCanvasLayerDom.java


示例19: HtmlCanvasLayerGL

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
HtmlCanvasLayerGL(HtmlGraphicsGL gfx, int width, int height) {
  super(gfx);

  this.width = width;
  this.height = height;

  CanvasElement canvas = Document.get().createCanvasElement();
  canvas.setWidth(width);
  canvas.setHeight(height);

  this.canvas = new HtmlCanvas(canvas, width, height);
  tex = gfx.createTexture(false, false);
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:14,代码来源:HtmlCanvasLayerGL.java


示例20: screenshot

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
public void screenshot(String filename) {
	CanvasElement canvas = ((GwtApplication) Gdx.app).getCanvasElement();
	// base64 encoded PNG file using data URL encoding! send this to your server
	String dataUrl = canvas.toDataUrl("image/png");
	// just opening it in a new window, replace this with whatever you want to do with the data
	Window.open(dataUrl, "_blank", "");
}
 
开发者ID:DaanVanYperen,项目名称:ns2-scc-profiler,代码行数:8,代码来源:ScreenshotHelper.java



注:本文中的com.google.gwt.dom.client.CanvasElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TribbleException类代码示例发布时间:2022-05-21
下一篇:
Java NodeDiscoveryType类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap