当前位置: 首页>>代码示例>>Java>>正文


Java CanvasElement.getContext2d方法代码示例

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


在下文中一共展示了CanvasElement.getContext2d方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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


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