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


Java PGraphics.beginShape方法代碼示例

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


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

import processing.core.PGraphics; //導入方法依賴的package包/類
static public void displayJoints(PGraphics pg, World world){
  pg.beginShape(PConstants.LINES);
  for (Joint joint = world.getJointList(); joint != null; joint = joint.getNext()) {
    display(pg, joint);
  }
  pg.endShape();
}
 
開發者ID:diwi,項目名稱:LiquidFunProcessing,代碼行數:8,代碼來源:DwDebugDraw.java

示例4: apply

import processing.core.PGraphics; //導入方法依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  
  List<Object> params = ProcessingUtil.parseParams(stack, 1);
      
  PGraphics pg = (PGraphics) params.get(0);
  
  String mode = params.get(1).toString();
  
  if ("POLYGON".equals(mode)) {
    pg.beginShape(PGraphics.POLYGON);      
  } else if ("POINTS".equals(mode)) {
    pg.beginShape(PGraphics.POINTS);
  } else if ("LINES".equals(mode)) {
    pg.beginShape(PGraphics.LINES);
  } else if ("TRIANGLES".equals(mode)) {
    pg.beginShape(PGraphics.TRIANGLES);
  } else if ("TRIANGLE_STRIP".equals(mode)) {
    pg.beginShape(PGraphics.TRIANGLE_STRIP);
  } else if ("TRIANGLE_FAN".equals(mode)) {
    pg.beginShape(PGraphics.TRIANGLE_FAN);
  } else if ("QUADS".equals(mode)) {
    pg.beginShape(PGraphics.QUADS);
  } else if ("QUAD_STRIP".equals(mode)) {
    pg.beginShape(PGraphics.QUAD_STRIP);
  } else {
    throw new WarpScriptException(getName() + ": invalid mode, should be 'POLYGON', 'POINTS', 'LINES', 'TRIANGLES', 'TRIANGLE_STRIP', 'TRIANGLE_FAN', 'QUADS' or 'QUAD_STRIP'.");
  }
  
  stack.push(pg);
      
  return stack;
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:34,代碼來源:PbeginShape.java

示例5: displayNormals

import processing.core.PGraphics; //導入方法依賴的package包/類
@Override
public void displayNormals(PGraphics pg){
  pg.beginShape(PConstants.LINES);
  for(int ia = 0; ia < num_nodes; ia++){
    normal(pg, particles[ia], normals[ia], display_normal_length);
  }
  pg.endShape();
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:9,代碼來源:DwSoftBall3D.java

示例6: displayNormalsXY

import processing.core.PGraphics; //導入方法依賴的package包/類
private void displayNormalsXY(PGraphics pg, float[][] normals, int iz, float nlen){
  pg.beginShape(PConstants.LINES);
  for(int iy = 0; iy < nodes_y; iy++){
    for(int ix = 0; ix < nodes_x; ix++){
      normal(pg, getNode3D(ix, iy, iz), normals[iy * nodes_x + ix], nlen);
    }
  }
  pg.endShape();
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:10,代碼來源:DwSoftGrid3D.java

示例7: displayNormalsYZ

import processing.core.PGraphics; //導入方法依賴的package包/類
private void displayNormalsYZ(PGraphics pg, float[][] normals, int ix, float nlen){
  pg.beginShape(PConstants.LINES);
  for(int iz = 0; iz < nodes_z; iz++){
    for(int iy = 0; iy < nodes_y; iy++){
      normal(pg, getNode3D(ix, iy, iz), normals[iz * nodes_y + iy], nlen);
    }
  }
  pg.endShape();
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:10,代碼來源:DwSoftGrid3D.java

示例8: displayNormalsXZ

import processing.core.PGraphics; //導入方法依賴的package包/類
private void displayNormalsXZ(PGraphics pg, float[][] normals, int iy, float nlen){
  pg.beginShape(PConstants.LINES);
  for(int iz = 0; iz < nodes_z; iz++){
    for(int ix = 0; ix < nodes_x; ix++){
      normal(pg, getNode3D(ix, iy, iz), normals[iz * nodes_x + ix], nlen);
    }
  }
  pg.endShape();
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:10,代碼來源:DwSoftGrid3D.java

示例9: display

import processing.core.PGraphics; //導入方法依賴的package包/類
public void display(PGraphics pg){
  for(int i = 0; i < faces.length; i++){
    int[] face = faces[i];
    pg.beginShape();
    for(int j = 0; j < face.length; j++){
      vertex(pg, verts[face[j]]);
    }
    pg.endShape(PConstants.CLOSE);
  }
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:11,代碼來源:DwIndexedFaceSet.java

示例10: displayNormals

import processing.core.PGraphics; //導入方法依賴的package包/類
@Override
public void displayNormals(PGraphics pg){
  pg.beginShape(PConstants.LINES);
  int     faces_count = foldingmodel.ifs.getFacesCount();
  int[][] faces       = foldingmodel.ifs.getFaces();
  for(int i = 0; i < faces_count; i++){
    int ia = faces[i][0];
    DwDisplayUtils.normal(pg, particles[ia], normals_face[i], display_normal_length);
  }
  pg.endShape();
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:12,代碼來源:DwFoldingSoftBody.java

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


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