當前位置: 首頁>>代碼示例>>Java>>正文


Java Context2d.setGlobalAlpha方法代碼示例

本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.setGlobalAlpha方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.setGlobalAlpha方法的具體用法?Java Context2d.setGlobalAlpha怎麽用?Java Context2d.setGlobalAlpha使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.canvas.dom.client.Context2d的用法示例。


在下文中一共展示了Context2d.setGlobalAlpha方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: repaint

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void repaint(Tool tool, int x, int y, int tileSize){
	Context2d context = canvasLayer.getContext();
	context.clearRect(0, 0, canvasLayer.getWidth(), canvasLayer.getHeight());
	
	if (tool == Tool.BRUSH) {
		
	} else if (tool == Tool.ERASER) {
		Eraser eraser = ToolBox.getInstance().getEraser();
		int size = eraser.getSize()*tileSize;
		context.save();
		context.setLineWidth(1.0);
		context.setStrokeStyle(CssColors.RED);
		context.setFillStyle(CssColors.LIGHT_GREY);
		
		context.rect(x, y, size, size);
		context.stroke();
		context.setGlobalAlpha(0.25);
		context.fill();
		
		context.restore();
	}
}
 
開發者ID:PsiAmp,項目名稱:punk-toads,代碼行數:23,代碼來源:CursorOverlay.java

示例2: draw

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
    double zoom = area.zoom();
    context.save();

    context.translate(-area.viewportLeft(), -area.viewportTop());
    context.scale(zoom, zoom);

    // outline
    int[][] coords = el.coordinates();

    context.beginPath();
    context.moveTo(coords[0][0], coords[0][1]);

    for (int i = 1; i < coords.length; i++) {
        context.lineTo(coords[i][0], coords[i][1]);
    }

    context.setLineWidth(6);
    context.stroke();
    
    context.setGlobalAlpha(0.3);
    context.setFillStyle("white");
    context.fill();
    context.setGlobalAlpha(1.0);
    
    context.closePath();

    // text
    context.setFillStyle("black");
    context.setFont("bold 60px sans-serif");
    context.setTextBaseline("top");
    context.fillText(el.text(), el.baseLeft(), el.baseTop(), el.baseWidth());

    context.restore();
    
    cb.onDrawn();
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:39,代碼來源:TextDrawable.java

示例3: draw

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
    double zoom = area.zoom();

    context.save();

    context.translate(-area.viewportLeft(), -area.viewportTop());
    context.scale(zoom, zoom);

    context.beginPath();
    context.moveTo(coords[0][0], coords[0][1]);

    for (int i = 1; i < coords.length; i++) {
        context.lineTo(coords[i][0], coords[i][1]);
    }

    context.setLineWidth(6);
    context.stroke();
    
    context.setGlobalAlpha(0.3);
    context.setFillStyle("white");
    context.fill();
    context.setGlobalAlpha(1.0);
    
    context.closePath();

    context.restore();
    
    cb.onDrawn();
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:31,代碼來源:PolygonDrawable.java

示例4: render

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
  g.save();
  g.setGlobalAlpha(0.4);
  g.setFillStyle("#999");
  g.setStrokeStyle("#333");
  g.beginPath();
  GraphicsUtil.drawRoundedRect(g, 0.5, 0.5, width - 1, height - 1, 8);
  g.closePath();
  g.fill();
  g.stroke();
  renderText(g);
  g.restore();
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:15,代碼來源:DefaultDragButtonSkin.java

示例5: parseLine

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
 * rysuje linie
 *
 * @param line
 * @param context2d
 */
private void parseLine(Element line, Context2d context2d) {// NOPMD
    NodeList elements = line.getChildNodes();
    String endPoint = null;
    String startPoint = null;
    boolean isStartSet = false;
    double lastX = 0, lastY = 0, startX = 0, startY = 0;
    double startBegX = 0, startBegY = 0, startEndX = 0, startEndY = 0;

    for (int x = 0; x < elements.getLength(); ++x) {
        Node node = elements.item(x);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element) node;
            if (!"".equals(getAttributeAsString(element, "x"))) {
                startX = lastX;
                startY = lastY;
                lastX = getAttributeAsDouble(element, "x");
                lastY = getAttributeAsDouble(element, "y");

                if (!isStartSet && startPoint != null) {
                    startBegX = lastX;
                    startBegY = lastY;
                    isStartSet = true;
                }
            }
            if (element.getNodeName().equals("startPoint")) {
                context2d.moveTo(lastX, lastY);
                startPoint = getAttributeAsString(element, "type");
                startEndX = lastX;
                startEndY = lastY;
            } else if (element.getNodeName().equals("endPoint")) {
                endPoint = getText(element);
            } else if (element.getNodeName().equals("lineTo")) {
                context2d.lineTo(lastX, lastY);
                context2d.stroke();
            } else if (element.getNodeName().equals("lineStyle")) {
                if (!"".equals(getAttributeAsString(element, "alpha"))) {
                    context2d.setGlobalAlpha(getAttributeAsInt(element, "alpha"));
                }
                // hex itd
                String color = getAttributeAsString(element, "color");
                if (color != null) {
                    context2d.setStrokeStyle(color);
                }
                // liczba
                if (!"".equals(getAttributeAsString(element, "width"))) {
                    getAttributeAsInt(element, "width");
                }
            }
        }
    }
    if (endPoint != null) {
        drawShape(endPoint, context2d, lastX, lastY, startX, startY);
    }

    if (startPoint != null) {
        drawShape(startPoint, context2d, startEndX, startEndY, startBegX, startBegY);
    }
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:65,代碼來源:LabelledImgContent.java

示例6: draw

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
	double zoom = area.zoom();
	context.save();
	
	context.translate(-area.viewportLeft(), -area.viewportTop());
	context.scale(zoom, zoom);
	
	// Draw outline
	int[][] coords = el.coordinates();
	
	context.beginPath();
	context.moveTo(coords[0][0], coords[0][1]);
	
	for (int i = 1; i < coords.length; i++) {
		context.lineTo(coords[i][0], coords[i][1]);
	}
	
	context.setLineWidth(6);
	context.stroke();
	
	context.setGlobalAlpha(0.3);
	context.setFillStyle("white");
	context.fill();
	context.setGlobalAlpha(1.0);
	
	context.closePath();
	
	// Write text
	context.setFillStyle("black");
	context.setFont("bold 60px sans-serif");
	context.setTextBaseline("top");
	
	if (el.text().contains("<") && el.text().contains(">")) {
		context.fillText(el.label() + "...", el.baseLeft(), el.baseTop(), el.baseWidth());
		el.neverShowPopup(false);
	} else {
		String[] words = el.text().split(" ");
		String line = "";
		
		int y = el.baseTop();
		
		for (int i = 0; i < words.length; i++) {
			String test_line = line + words[i] + " ";
			
			if (context.measureText(test_line).getWidth() > el.baseWidth() && i > 0
					|| words[i].contains("\n")) {
				context.fillText(line, el.baseLeft(), y);
				y += step;
				line = words[i] + " ";
				
				if (y + step > el.baseTop() + el.baseHeight()) {
    				context.restore();
    				el.neverShowPopup(false);
    				cb.onDrawn();
    				return;
    			}
			} else {
				line = test_line;
			}
		}
		context.fillText(line, el.baseLeft(), y);
		el.neverShowPopup(true);
	}
	context.restore();
	
	cb.onDrawn();
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:69,代碼來源:MultiLineTextDrawable.java


注:本文中的com.google.gwt.canvas.dom.client.Context2d.setGlobalAlpha方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。