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


Java PGraphics.popMatrix方法代碼示例

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


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

示例1: drawRotatedText

import processing.core.PGraphics; //導入方法依賴的package包/類
public static void drawRotatedText(PGraphics p, String txt, float x, float y, float r)
{
	p.pushMatrix();
	p.translate(x, y);
	p.rotate(r); // draw the text vertically
	p.text(txt, 0, 0);
	p.popMatrix();
}
 
開發者ID:hyounesy,項目名稱:ChAsE,代碼行數:9,代碼來源:PUtils.java

示例2: drawArrow

import processing.core.PGraphics; //導入方法依賴的package包/類
public static void drawArrow(PGraphics p, float x1, float y1, float x2, float y2, float dx, float dy, boolean bDrawArrowLine)
{
	if (bDrawArrowLine) {
		p.line(x1, y1, x2, y2);
	}
	p.pushMatrix();
	p.translate(x2, y2);
	float a = (float)Math.atan2(x1-x2, (y2-y1)*0.1f);
	p.rotate(a);
	p.line(0, 0, -dy, -dx);
	p.line(0, 0, dy, -dx);
	p.popMatrix();
}
 
開發者ID:hyounesy,項目名稱:ChAsE,代碼行數:14,代碼來源:PUtils.java

示例3: endScreen2D

import processing.core.PGraphics; //導入方法依賴的package包/類
static public void endScreen2D(PGraphics pg){
  if(pg.isGL() && pg.is3D()){
    PGraphicsOpenGL pgl = (PGraphicsOpenGL)pg;
    pgl.popProjection();
    pgl.lights = pushed_lights;
  }
  pg.popMatrix();
  pg.hint(PConstants.ENABLE_DEPTH_TEST);
  pg.popStyle();
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:11,代碼來源:DwUtils.java

示例4: finishDraw

import processing.core.PGraphics; //導入方法依賴的package包/類
private void finishDraw(PGraphics pg){
  pg.popStyle();
  pg.popMatrix();
  if(pg != parent.g) pg.endDraw();
}
 
開發者ID:linux-man,項目名稱:ptmx,代碼行數:6,代碼來源:Ptmx.java

示例5: drawLayer

import processing.core.PGraphics; //導入方法依賴的package包/類
private void drawLayer(PGraphics pg, int m){
  int tileoffsetx, tileoffsety, n, dif;
  float x = 0, y = 0;
  Layer l = this.layer[m];
  switch(l.type){
    case "layer":
      map.drawTileLayer(pg, m);
      break;
    case "imagelayer":
      pg.image(l.image, -this.camleft + l.offsetx, -this.camtop + l.offsety);
      break;
    case "objectgroup":
      pg.fill(l.objcolor);pg.stroke(l.objcolor); pg.strokeWeight(1);
      for(StringDict o: l.objects){
        if(!o.hasKey("visible")){
          pg.pushMatrix();
          pg.resetMatrix();
          pg.pushStyle();
          pg.ellipseMode(parent.CORNER);
          pg.translate(parent.parseFloat(o.get("x")) - l.offsetx - this.camleft, parent.parseFloat(o.get("y"))- l.offsety - this.camtop);
          if(o.hasKey("rotation")) pg.rotate(parent.parseFloat(o.get("rotation")) * parent.PI / 180);
          switch(o.get("object")){
            case "rectangle":
              pg.rect(0, 0, parent.parseFloat(o.get("width")), parent.parseFloat(o.get("height")));
              break;
            case "ellipse":
              pg.ellipse(0, 0, parent.parseFloat(o.get("width")), parent.parseFloat(o.get("height")));
              break;
            case "tile":
              if(o.hasKey("rotation")) pg.rotate(-parent.parseFloat(o.get("rotation")) * parent.PI / 180);
              pg.translate(0, -this.tile[parent.parseInt(o.get("gid")) - 1].image.height);
              if(o.hasKey("rotation")) pg.rotate(parent.parseFloat(o.get("rotation")) * parent.PI / 180);
              pg.image(this.tile[parent.parseInt(o.get("gid")) - 1].image, this.tile[parent.parseInt(o.get("gid")) - 1].offsetx, this.tile[parent.parseInt(o.get("gid")) - 1].offsety, parent.parseFloat(o.get("width")), parent.parseFloat(o.get("height")));
              break;
            case "polygon":
            case "polyline":
              if(o.get("object").equals("polyline")) pg.noFill();
              pg.beginShape();
              for(String s: parent.split(o.get("points"), " ")){
                float [] p = parent.parseFloat(parent.split(s, ","));
                pg.vertex(p[0], p[1]);
              }
              if(o.get("object").equals("polyline")) pg.endShape(); else pg.endShape(parent.CLOSE);
              break;
          }
          pg.popStyle();
          pg.popMatrix();
        }
      }
      break;
  }
  if(pg != parent.g && l.opacity < 1){//applyOpacity
    pg.loadPixels();
    int a = parent.parseInt(parent.map(l.opacity, 0, 1, 1, 255));
    for (int p = 0; p < pg.pixels.length; p++) if(parent.alpha(pg.pixels[p]) > a) pg.pixels[p] = parent.color(parent.red(pg.pixels[p]), parent.green(pg.pixels[p]), parent.blue(pg.pixels[p]), a);
    pg.updatePixels();
  }
}
 
開發者ID:linux-man,項目名稱:ptmx,代碼行數:59,代碼來源:Ptmx.java

示例6: drawHistogram

import processing.core.PGraphics; //導入方法依賴的package包/類
public static void drawHistogram(PGraphics p, double[] values, int iNumBins, float fLeft, float fTop, float fWidth, float fHeight, double dMaxBinValue, String xLabel, String yLabel, String[] xTicks)
{
	if (values == null || values.length == 0)
		return;
	
	double[] dBinVal = new double[iNumBins];
	double dMaxBinVal = dMaxBinValue;
	double dSum = 0;
	int ival = 0;
	for (int ibin = 0; ibin < iNumBins; ibin++)
	{
		while (ival < (ibin + 1) * values.length/iNumBins && ival < values.length)
		{
			dBinVal[ibin] += values[ival];
			ival++;
		}
		if (dMaxBinValue == -1)
		{
			dMaxBinVal = Math.max(dMaxBinVal, dBinVal[ibin]);
		}
		dSum += dBinVal[ibin];
	}

	float fBottom = fTop + fHeight;
	for (int ibin = 0; ibin < iNumBins; ibin++)
	{
		float h = -Math.min(fHeight, (float)(fHeight*dBinVal[ibin]/dMaxBinVal));
		p.rect(fLeft + ibin * fWidth / iNumBins, fBottom, fWidth / iNumBins, h);
	}
	
	// draw labels for the y axis
	NumberFormat nf = NumberFormat.getInstance();
	nf.setMaximumFractionDigits(1);
	
	//p.textAlign(PConstants.RIGHT, PConstants.TOP);
	//p.text(nf.format(100 * dMaxBinVal / dSum)+"%", fLeft - 5, fTop);
	
	// draw labels for the x axis
	if (xTicks != null)
	{
		p.textAlign(PConstants.CENTER, PConstants.TOP);
		for (int i = 0; i < xTicks.length; i++)
		{
			p.text(xTicks[i], fLeft + i * fWidth / (xTicks.length - 1), fBottom + 5);
		}
	}
	
	p.textAlign(PConstants.CENTER, PConstants.BOTTOM);
	p.text(xLabel, fLeft + fWidth / 2, fTop);

	p.textAlign(PConstants.CENTER, PConstants.TOP);
	p.pushMatrix();
	p.translate(fLeft + fWidth, fTop + fHeight / 2);
	p.rotate(-PConstants.PI/2);
	p.text(yLabel, 0, 0);
	p.popMatrix();

}
 
開發者ID:hyounesy,項目名稱:ChAsE,代碼行數:59,代碼來源:PUtils.java

示例7: apply

import processing.core.PGraphics; //導入方法依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  
  List<Object> params = ProcessingUtil.parseParams(stack, 0);
      
  PGraphics pg = (PGraphics) params.get(0);
  
  pg.popMatrix();
  
  stack.push(pg);
      
  return stack;
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:14,代碼來源:PpopMatrix.java


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