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


Java PGraphics.vertex方法代碼示例

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


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

示例1: displayParticles

import processing.core.PGraphics; //導入方法依賴的package包/類
static public void displayParticles(PGraphics pg, World world) {
  int particle_num = world.getParticleCount();
  if (particle_num != 0) {
    float radius = world.getParticleRadius();
    radius *= PARTICLE_RADIUS_SCALE;
    Vec2[] particle_pos = world.getParticlePositionBuffer();
    pg.beginShape(PConstants.QUADS);
    pg.noFill();
    pg.noStroke();
    pg.textureMode(PConstants.NORMAL);
    pg.texture(PARTICLE_SPRITE);
    for (int i = 0; i < particle_num; i++) {
      Vec2 pos = particle_pos[i];
      pg.vertex(pos.x - radius, pos.y - radius, 0, 0);
      pg.vertex(pos.x + radius, pos.y - radius, 1, 0);
      pg.vertex(pos.x + radius, pos.y + radius, 1, 1);
      pg.vertex(pos.x - radius, pos.y + radius, 0, 1);
    }
    pg.endShape();
  }
}
 
開發者ID:diwi,項目名稱:LiquidFunProcessing,代碼行數:22,代碼來源:DwDebugDraw.java

示例2: drawRoundRect

import processing.core.PGraphics; //導入方法依賴的package包/類
public static void drawRoundRect(PGraphics p, float x, float y, float w, float h, float rx, float ry)
{
	p.beginShape();
	p.vertex(x,y+ry); //top of left side 
	p.bezierVertex(x,y,x,y,x+rx,y); //top left corner
	  
	p.vertex(x+w-rx,y); //right of top side 
	p.bezierVertex(x+w,y,x+w,y,x+w,y+ry); //top right corner
	  
	p.vertex(x+w,y+h-ry); //bottom of right side
	p.bezierVertex(x+w,y+h,x+w,y+h,x+w-rx,y+h); //bottom right corner
	  
	p.vertex(x+rx,y+h); //left of bottom side
	p.bezierVertex(x,y+h,x,y+h,x,y+h-ry); //bottom left corner
	p.endShape(PConstants.CLOSE);
}
 
開發者ID:hyounesy,項目名稱:ChAsE,代碼行數:17,代碼來源:PUtils.java

示例3: apply

import processing.core.PGraphics; //導入方法依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  
  List<Object> params = ProcessingUtil.parseParams(stack, 2, 3, 4, 5);
      
  PGraphics pg = (PGraphics) params.get(0);
  
  if (6 == params.size()) {
    pg.vertex(
        ((Number) params.get(1)).floatValue(),
        ((Number) params.get(2)).floatValue(),
        ((Number) params.get(3)).floatValue(),
        ((Number) params.get(4)).floatValue(),
        ((Number) params.get(5)).floatValue()
    );      
  } else if (5 == params.size()) {
    pg.vertex(
        ((Number) params.get(1)).floatValue(),
        ((Number) params.get(2)).floatValue(),
        ((Number) params.get(3)).floatValue(),
        ((Number) params.get(4)).floatValue()
    );      
  } else if (4 == params.size()) {
    pg.vertex(
        ((Number) params.get(1)).floatValue(),
        ((Number) params.get(2)).floatValue(),
        ((Number) params.get(3)).floatValue()
    );      
  } else if (3 == params.size()) {
    pg.vertex(
        ((Number) params.get(1)).floatValue(),
        ((Number) params.get(2)).floatValue()
    );      
  }
  
  stack.push(pg);
      
  return stack;
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:40,代碼來源:Pvertex.java

示例4: vertex

import processing.core.PGraphics; //導入方法依賴的package包/類
public void vertex(PGraphics pg, float[] v){
  if(pg.is2D()){
    pg.vertex(v[0], v[1]);
  } else {
    pg.vertex(v[0], v[1], v[2]);
  }
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:8,代碼來源:DwIndexedFaceSet.java

示例5: normal

import processing.core.PGraphics; //導入方法依賴的package包/類
static public final void normal(PGraphics pg, DwParticle3D v0, float[] n, float len){
  if(pg.is2D()){
    pg.vertex(v0.cx           , v0.cy           ); 
    pg.vertex(v0.cx + n[0]*len, v0.cy + n[1]*len); 
  } else {
    pg.vertex(v0.cx           , v0.cy           , v0.cz           ); 
    pg.vertex(v0.cx + n[0]*len, v0.cy + n[1]*len, v0.cz + n[2]*len); 
  }
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:10,代碼來源:DwDisplayUtils.java

示例6: vertex

import processing.core.PGraphics; //導入方法依賴的package包/類
static public final void vertex(PGraphics pg, DwParticle3D v0){
  if(pg.is2D()){
    pg.vertex(v0.cx, v0.cy); 
  } else {
    pg.vertex(v0.cx, v0.cy, v0.cz); 
  }
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:8,代碼來源:DwDisplayUtils.java

示例7: line

import processing.core.PGraphics; //導入方法依賴的package包/類
static public void line(PGraphics pg, Vec2 p1, Vec2 p2){
  pg.vertex(p1.x, p1.y);
  pg.vertex(p2.x, p2.y);
}
 
開發者ID:diwi,項目名稱:LiquidFunProcessing,代碼行數:5,代碼來源:DwDebugDraw.java

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

示例9: normal

import processing.core.PGraphics; //導入方法依賴的package包/類
private final void normal(PGraphics pg, DwParticle3D p, float[] n, float nlen){
  if(p.all_springs_deactivated) return;
  pg.vertex(p.cx          , p.cy          , p.cz          );
  pg.vertex(p.cx+n[0]*nlen, p.cy+n[1]*nlen, p.cz+n[2]*nlen);
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:6,代碼來源:DwSoftBall3D.java


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