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


Java PConstants類代碼示例

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


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

示例1: showTitle

import processing.core.PConstants; //導入依賴的package包/類
/** 顯示選中的標記對應的城市名稱 */
public void showTitle(PGraphics pg, float x, float y)
{
	String name = getCity() + " " + getCountry() + " ";
	String pop = "Pop: " + getPopulation() + " Million";
	
	pg.pushStyle();
	
	pg.fill(255, 255, 255);
	pg.textSize(12);
	pg.rectMode(PConstants.CORNER);
	pg.rect(x, y-TRI_SIZE-39, Math.max(pg.textWidth(name), pg.textWidth(pop)) + 6, 39);
	pg.fill(0, 0, 0);
	pg.textAlign(PConstants.LEFT, PConstants.TOP);
	pg.text(name, x+3, y-TRI_SIZE-33);
	pg.text(pop, x+3, y - TRI_SIZE -18);
	
	pg.popStyle();
}
 
開發者ID:simontangbit,項目名稱:CourseCode,代碼行數:20,代碼來源:CityMarker.java

示例2: createSprite

import processing.core.PConstants; //導入依賴的package包/類
static public PImage createSprite(PApplet papplet, int size, float exp1, float exp2, float mult){
  size = Math.max(32, size);
  
  PImage pimg = papplet.createImage(size, size, PConstants.ARGB);
  pimg.loadPixels();
  for(int y = 0; y < size; y++){
    for(int x = 0; x < size; x++){
      int pid = y * size + x;
      
      float xn = ((x+0.5f) / (float)size) * 2f - 1f;
      float yn = ((y+0.5f) / (float)size) * 2f - 1f;
      float dd = (float) Math.sqrt(xn*xn + yn*yn);
      
      dd = DwUtils.clamp(dd, 0, 1);
      dd = (float) Math.pow(dd, exp1);
      dd = 1.0f - dd;
      dd = (float) Math.pow(dd, exp2);
      dd *= mult;
      dd = DwUtils.clamp(dd, 0, 1);
      pimg.pixels[pid] = ((int)(dd * 255)) << 24 | 0x00FFFFFF;
    }
  }
  pimg.updatePixels();
  return pimg;
}
 
開發者ID:diwi,項目名稱:LiquidFunProcessing,代碼行數:26,代碼來源:DwUtils.java

示例3: drawParticles

import processing.core.PConstants; //導入依賴的package包/類
@Override
public void drawParticles(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
  
  radius *= PARTICLE_RADIUS_SCALE;
  
  canvas.noStroke();
  canvas.noFill();
  canvas.beginShape(PConstants.QUADS);
  canvas.textureMode(PConstants.NORMAL);
  canvas.texture(PARTICLE_SPRITE);
  for(int i = 0; i < count; i++){
    Vec2 pos = centers[i];
    if(colors != null){
      ParticleColor col = colors[i];
      canvas.tint(col.r & 0xFF, col.g & 0xFF, col.b & 0xFF, col.a & 0xFF);
    }
    canvas.vertex(pos.x - radius, pos.y - radius, 0, 0);
    canvas.vertex(pos.x + radius, pos.y - radius, 1, 0);
    canvas.vertex(pos.x + radius, pos.y + radius, 1, 1);
    canvas.vertex(pos.x - radius, pos.y + radius, 0, 1);
    
  }
  canvas.endShape();
  canvas.tint(255);
}
 
開發者ID:diwi,項目名稱:LiquidFunProcessing,代碼行數:26,代碼來源:DwDebugDraw.java

示例4: displayParticles

import processing.core.PConstants; //導入依賴的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

示例5: DwBody

import processing.core.PConstants; //導入依賴的package包/類
public DwBody(DwBodyGroup parent, Body body){
  this.parent = parent;
  this.body = body;
  
  // create PShape
  this.shape = parent.papplet.createShape(PConstants.GROUP);
  // link PShapes
  parent.shape.addChild(shape);
  
  body.setUserData(this);
  
  // create children
  for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
    add(fixture);
  }
}
 
開發者ID:diwi,項目名稱:LiquidFunProcessing,代碼行數:17,代碼來源:DwBody.java

示例6: showTitle

import processing.core.PConstants; //導入依賴的package包/類
/** Show the title of the earthquake if this marker is selected */
public void showTitle(PGraphics pg, float x, float y)
{
	String title = getTitle();
	pg.pushStyle();
	
	pg.rectMode(PConstants.CORNER);
	
	pg.stroke(110);
	pg.fill(255,255,255);
	pg.rect(x, y + 15, pg.textWidth(title) +6, 18, 5);
	
	pg.textAlign(PConstants.LEFT, PConstants.TOP);
	pg.fill(0);
	pg.text(title, x + 3 , y +18);
	
	
	pg.popStyle();
	
}
 
開發者ID:snavjivan,項目名稱:Earthquake-Tracker,代碼行數:21,代碼來源:EarthquakeMarker.java

示例7: showTitle

import processing.core.PConstants; //導入依賴的package包/類
public void showTitle(PGraphics pg, float x, float y)
{
	String name = getCity() + " " + getCountry() + " ";
	String pop = "Pop: " + getPopulation() + " Million";
	
	pg.pushStyle();
	
	pg.fill(255, 255, 255);
	pg.textSize(12);
	pg.rectMode(PConstants.CORNER);
	pg.rect(x, y-TRI_SIZE-39, Math.max(pg.textWidth(name), pg.textWidth(pop)) + 6, 39);
	pg.fill(0, 0, 0);
	pg.textAlign(PConstants.LEFT, PConstants.TOP);
	pg.text(name, x+3, y-TRI_SIZE-33);
	pg.text(pop, x+3, y - TRI_SIZE -18);
	
	pg.popStyle();
}
 
開發者ID:snavjivan,項目名稱:Earthquake-Tracker,代碼行數:19,代碼來源:CityMarker.java

示例8: keyPressed

import processing.core.PConstants; //導入依賴的package包/類
@Override
public synchronized void keyPressed()
{
	if (keyCode < m_Keys.length) {
		m_Keys[keyCode] = true;
	}
	
	if (key == PConstants.ESC) {
		key = 0; // to prevent from ESC terminating the entire app
	}
	
	if (key == CODED)
	{
		if (keyCode == ALT) {
			m_bKeyAltPressed = true;
		} else if (keyCode == SHIFT) {
			m_bKeyShiftPressed = true;
		} else if (keyCode == CONTROL) {
			m_bKeyControlPressed = true;
		}
	}
}
 
開發者ID:hyounesy,項目名稱:ChAsE,代碼行數:23,代碼來源:PBasicPainter.java

示例9: drawRoundRect

import processing.core.PConstants; //導入依賴的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

示例10: setRenderSize

import processing.core.PConstants; //導入依賴的package包/類
void setRenderSize(float px, float py, int theWidth, int theHeight)
{
	m_TitleH = paneTitleH;
	m_TitleRect = new Rect(px, py, theWidth, m_TitleH);
	m_LargeRect = new Rect(px + m_AxisLabelH + m_FontSize, py + m_TitleRect.height() + 10,
			               theWidth - 40 - m_AxisLabelH - m_FontSize, theHeight - m_TitleRect.height() - 40 - m_AxisLabelH);
	m_CuttOffRect = new Rect(m_LargeRect.left() - m_CuttOffW, m_LargeRect.top(), m_CuttOffW, m_LargeRect.height());
	try
	{
		if ((m_Gx == null || m_LargeRect.width() != m_Gx.width || m_LargeRect.height() != m_Gx.height) && m_LargeRect.width() > 0 && m_LargeRect.height() > 0)
		{
			// using PConstants.P2D results in problems drawing concave filled polygons
			m_Gx = ControlP5.papplet.createGraphics((int)m_LargeRect.width(), (int)m_LargeRect.height(), PConstants.JAVA2D); 
		}
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
}
 
開發者ID:hyounesy,項目名稱:ChAsE,代碼行數:21,代碼來源:ControlPanelDetailPlot.java

示例11: showTitle

import processing.core.PConstants; //導入依賴的package包/類
/** Show the title of the city if this marker is selected */
public void showTitle(PGraphics pg, float x, float y)
{
	String name = getCity() + " " + getCountry() + " ";
	String pop = "Pop: " + getPopulation() + " Million";
	
	pg.pushStyle();
	
	pg.fill(255, 255, 255);
	pg.textSize(12);
	pg.rectMode(PConstants.CORNER);
	pg.rect(x, y-TRI_SIZE-39, Math.max(pg.textWidth(name), pg.textWidth(pop)) + 6, 39);
	pg.fill(0, 0, 0);
	pg.textAlign(PConstants.LEFT, PConstants.TOP);
	pg.text(name, x+3, y-TRI_SIZE-33);
	pg.text(pop, x+3, y - TRI_SIZE -18);
	
	pg.popStyle();
}
 
開發者ID:imranalidigi,項目名稱:UCSDUnfoldingMapsMaven,代碼行數:20,代碼來源:CityMarker.java

示例12: drawTileLevelBuffer

import processing.core.PConstants; //導入依賴的package包/類
/**
 * Draw tile on the foreground buffer.
 * @param x
 * @param y
 * @param gid
 * @param tileSet
 */
private void drawTileLevelBuffer (int x, int y, int gid, TileSet tileSet) {
	gid -= tileSet.firstGID;		
	pie.levelBuffer.blend(
			tileSet.tileSet,
			(gid % tileSet.tileColumns) * tileSet.tileWidth,
			(gid / tileSet.tileColumns) * tileSet.tileHeight,
			tileSet.tileWidth,
			tileSet.tileHeight,
			x,
			y,
			tileSet.tileWidth,
			tileSet.tileHeight,
			PConstants.BLEND
			);
}
 
開發者ID:AliasBlack,項目名稱:pixelpie,代碼行數:23,代碼來源:levelLoader.java

示例13: drawTileBGBuffer

import processing.core.PConstants; //導入依賴的package包/類
/**
 * Draw tile on the background buffer.
 * @param layer
 * @param x
 * @param y
 * @param gid
 * @param tileSet
 */
private void drawTileBGBuffer (int layer, int x, int y, int gid, TileSet tileSet) {
	gid -= tileSet.firstGID;		
	pie.backgroundBuffer[layer].blend(
			tileSet.tileSet,
			(gid % tileSet.tileColumns) * tileSet.tileWidth,
			(gid / tileSet.tileColumns) * tileSet.tileHeight,
			tileSet.tileWidth,
			tileSet.tileHeight,
			x,
			y,
			tileSet.tileWidth,
			tileSet.tileHeight,
			PConstants.BLEND
			);
}
 
開發者ID:AliasBlack,項目名稱:pixelpie,代碼行數:24,代碼來源:levelLoader.java

示例14: GameObject

import processing.core.PConstants; //導入依賴的package包/類
/**
 * Constructor.
 * @param pie
 */
public GameObject(PixelPie pie) {
	
	// Grab PixelPie.
	this.pie = pie;
	
	// Set some parameters.
	visible = false;
	lockBBox = false;
	type = "Object";
	sprite = null;
	alpha = 255;
	lightTemp = pie.app.createImage(1, 1, PConstants.ARGB);

	// Add object to collide detect array.
	pie.objectArray.add(this);

	// Grab index.
	index = pie.index;
	pie.index++;
}
 
開發者ID:AliasBlack,項目名稱:pixelpie,代碼行數:25,代碼來源:gameObject.java

示例15: render

import processing.core.PConstants; //導入依賴的package包/類
public void render(PGraphics2D dst, int background){
  // no need to run the vertex shader for particles that haven't spawned yet
  int num_points_to_render = ALIVE_PARTICLES;
  int w = dst.width;
  int h = dst.height;
  
  dst.beginDraw();
  dst.blendMode(PConstants.BLEND);
  if(background == 0) dst.blendMode(PConstants.ADD); // works nicely on black background
  
  context.begin();
  shader_particleRender.begin();
  shader_particleRender.uniform2f     ("wh_viewport", w, h);
  shader_particleRender.uniform2i     ("num_particles", particles_x, particles_y);
  shader_particleRender.uniform1f     ("point_size"   , point_size);
  shader_particleRender.uniformTexture("tex_particles", tex_particles.src);
  shader_particleRender.drawFullScreenPoints(num_points_to_render);
  shader_particleRender.end();
  context.end("ParticleSystem.render");

  dst.endDraw();
}
 
開發者ID:diwi,項目名稱:PixelFlow,代碼行數:23,代碼來源:MyParticleSystem.java


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