当前位置: 首页>>代码示例>>Java>>正文


Java PApplet类代码示例

本文整理汇总了Java中processing.core.PApplet的典型用法代码示例。如果您正苦于以下问题:Java PApplet类的具体用法?Java PApplet怎么用?Java PApplet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PApplet类属于processing.core包,在下文中一共展示了PApplet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SoundFile

import processing.core.PApplet; //导入依赖的package包/类
public SoundFile(PApplet theParent, String path) {
	this.parent = theParent;
	parent.registerMethod("dispose", this);
	m_engine.setPreferences(theParent, 512, 44100);
   	m_engine.start();
   	methCla = new MethClaInterface();
	m_filePath=theParent.dataPath(path);
	File sample = new File(m_filePath);
	if(sample.isFile() == true){
		m_info = m_engine.soundFileInfo(m_filePath);
	}
	else {
		System.out.println("Error: Soundfile doesn't exist. Pleae check path");
	}
	//m_panBusId = m_engine.soundFileConstructMono();
	m_panBusId = m_engine.busConstructMono();
}
 
开发者ID:JacobRoth,项目名称:romanov,代码行数:18,代码来源:SoundFile.java

示例2: createPointsGrid

import processing.core.PApplet; //导入依赖的package包/类
void createPointsGrid(PApplet ap)
{
	
	Vector<PVector> pnts =  new Vector<PVector>();
	int dw = width /nbPoints;
	int dh = height /nbPoints;
	int xoffset = dw,yoffset = dh;
	for(int i = 1 ; i*dw < width - dw ;i++)
	{
		for(int j = 1 ; j*dh< height - dh ;j++)
		{				
			pnts.add(new PVector(xoffset + i*dw,yoffset+j*dh));
		}
		
	}
	System.out.println(pnts);
	voronoiPoints = pnts;
}
 
开发者ID:abuzreq,项目名称:ConstrainedGraphPartitioning,代码行数:19,代码来源:VoronoiGenerator.java

示例3: testGrid

import processing.core.PApplet; //导入依赖的package包/类
boolean testGrid(PVector p, float minDist) {
	int minX = PApplet.floor(PApplet.max(0, (p.x - minDist - _xmin) / _cellSize));
	int maxX = PApplet.ceil(PApplet.min(_gridWidth - 1, (p.x + minDist - _xmin) / _cellSize));
	int minY = PApplet.floor(PApplet.max(0, (p.y - minDist - _ymin) / _cellSize));
	int maxY = PApplet.ceil(PApplet.min(_gridHeight - 1, (p.y + minDist - _ymin) / _cellSize));

	for (int y = minY; y <= maxY; y++) {
		for (int x = minX; x <= maxX; x++) {
			Vector<PVector> cell = _grid.get(y * _gridWidth + x);
			for (PVector t : cell)
				if (PApplet.dist(p.x, p.y, t.x, t.y) <= minDist)
					return false;
		}
	}

	return true;
}
 
开发者ID:abuzreq,项目名称:ConstrainedGraphPartitioning,代码行数:18,代码来源:VoronoiGenerator.java

示例4: createSprite

import processing.core.PApplet; //导入依赖的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

示例5: buildNoisyEdges

import processing.core.PApplet; //导入依赖的package包/类
/***********************************************************/
 void buildNoisyEdges(PApplet ap)
{
  final float f = 0.5f; 
  for(VoronoiGenerator.Map.Edge e : map.edgesList) {
    if(e.f2 == null) continue;
    
    PVector m = lerpVector(e.p1.pos, e.p2.pos, f);  // midpoint
    PVector t = lerpVector(e.p1.pos, e.f1.pos, f);
    PVector q = lerpVector(e.p1.pos, e.f2.pos, f);
    PVector r = lerpVector(e.p2.pos, e.f1.pos, f);
    PVector s = lerpVector(e.p2.pos, e.f2.pos, f);
    
    int minLength = 4;
    if(e.f1.ocean && e.f2.ocean) minLength = 100;
    if(e.f1.ocean != e.f2.ocean) minLength = 2;  // coast
    if(e.river > 0) minLength = 3;
    
    e.noisy1 = buildNoisyLineSegments(ap,e.p1.pos, t, m, q, minLength);
    e.noisy2 = buildNoisyLineSegments(ap,e.p2.pos, s, m, r, minLength);
  }
}
 
开发者ID:abuzreq,项目名称:ConstrainedGraphPartitioning,代码行数:23,代码来源:VoronoiGenerator.java

示例6: subdivideNoisyLineSegment

import processing.core.PApplet; //导入依赖的package包/类
void subdivideNoisyLineSegment(PApplet ap,ArrayList<PVector> pts, 
  PVector A, PVector B, PVector C, PVector D, int minLength)
{
  if(PVector.sub(A, C).mag() < minLength || PVector.sub(B, D).mag() < minLength)
    return;
    
  float p = ap.random(0.2f, 0.8f);
  float q = ap.random(0.2f, 0.8f);
  
  PVector E = lerpVector(A, D, p);
  PVector F = lerpVector(B, C, p);
  PVector G = lerpVector(A, B, q);
  PVector I = lerpVector(D, C, q);
  
  PVector H = lerpVector(E, F, q);
  
  subdivideNoisyLineSegment(ap,pts, A, G, H, E, minLength);
  pts.add(H);
  subdivideNoisyLineSegment(ap,pts, H, F, C, I, minLength);
}
 
开发者ID:abuzreq,项目名称:ConstrainedGraphPartitioning,代码行数:21,代码来源:VoronoiGenerator.java

示例7: intersectionParabolas

import processing.core.PApplet; //导入依赖的package包/类
PVector intersectionParabolas(PVector p0, PVector p1, float l) {
	PVector res = new PVector(), p = p0;
	if (p0.x == p1.x)
		res.y = (p0.y + p1.y) / 2;
	else if (p1.x == l)
		res.y = p1.y;
	else if (p0.x == l) {
		res.y = p0.y;
		p = p1;
	} else {
		float s0 = 2 * (p0.x - l), s1 = 2 * (p1.x - l);
		float a = 1 / s0 - 1 / s1;
		float b = -2 * (p0.y / s0 - p1.y / s1);
		float c = (p0.y * p0.y + p0.x * p0.x - l * l) / s0 - (p1.y * p1.y + p1.x * p1.x - l * l) / s1;
		res.y = (-b - PApplet.sqrt(b * b - 4 * a * c)) / (2 * a);
	}
	res.x = (p.x * p.x + (p.y - res.y) * (p.y - res.y) - l * l) / (2 * p.x - 2 * l);
	return res;
}
 
开发者ID:abuzreq,项目名称:ConstrainedGraphPartitioning,代码行数:20,代码来源:VoronoiGenerator.java

示例8: computeCircle

import processing.core.PApplet; //导入依赖的package包/类
CircleResponse computeCircle(PVector a, PVector b, PVector c) {
	// BC must be a right turn from AB
	if ((b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y) > 0)
		return new CircleResponse(false);

	// Algorithm from O'Rourke 2ed p. 189.
	float A = b.x - a.x, B = b.y - a.y, C = c.x - a.x, D = c.y - a.y, E = A * (a.x + b.x) + B * (a.y + b.y), F = C
			* (a.x + c.x) + D * (a.y + c.y), G = 2 * (A * (c.y - b.y) - B * (c.x - b.x));

	// co-linear
	if (G == 0)
		return new CircleResponse(false);

	// p is the center
	CircleResponse r = new CircleResponse(true);
	r.p.x = (D * E - B * F) / G;
	r.p.y = (A * F - C * E) / G;

	// max x coordinate
	r.x = r.p.x + PApplet.sqrt(PApplet.pow(a.x - r.p.x, 2) + PApplet.pow(a.y - r.p.y, 2));
	return r;
}
 
开发者ID:abuzreq,项目名称:ConstrainedGraphPartitioning,代码行数:23,代码来源:VoronoiGenerator.java

示例9: intersectionSegments

import processing.core.PApplet; //导入依赖的package包/类
PVector intersectionSegments(Segment s, PVector p1, PVector p2) {
	final float eps = 1e-10f;

	PVector p3 = s.p0, p4 = s.p1;
	float den = (p4.y - p3.y) * (p2.x - p1.x) - (p4.x - p3.x) * (p2.y - p1.y);
	float numa = (p4.x - p3.x) * (p1.y - p3.y) - (p4.y - p3.y) * (p1.x - p3.x);
	float numb = (p2.x - p1.x) * (p1.y - p3.y) - (p2.y - p1.y) * (p1.x - p3.x);

	if (PApplet.abs(numa) < eps && PApplet.abs(numb) < eps && PApplet.abs(den) < eps) // Coincident
		return PVector.add(PVector.mult(p1, 0.5f), PVector.mult(p2, 0.5f));

	if (PApplet.abs(den) < eps)
		return null; // Parallel

	float mua = numa / den, mub = numb / den;
	if (mua < 0 || mua > 1 || mub < 0 || mub > 1)
		return null; // Outside of the segments

	return PVector.add(PVector.mult(p1, 1 - mua), PVector.mult(p2, mua));
}
 
开发者ID:abuzreq,项目名称:ConstrainedGraphPartitioning,代码行数:21,代码来源:VoronoiGenerator.java

示例10: PointsLookup

import processing.core.PApplet; //导入依赖的package包/类
PointsLookup(float xmin, float ymin, float xmax, float ymax, int cellSize, float tolerance) {
	_xmin = xmin;
	_xmax = xmax;
	_ymin = ymin;
	_ymax = ymax;
	_cs = cellSize;
	_tol = tolerance;
	_tol2 = tolerance * tolerance;
	_data = new Vector<Vector<PVector>>();
	float fw = xmax - xmin, fh = ymax - ymin;
	_w = PApplet.ceil(fw / (float) _cs);
	_h = PApplet.ceil(fh / (float) _cs); // grid of 10x10 pixels
	int s = _w * _h;
	for (int i = 0; i < s; i++)
		_data.add(new Vector<PVector>());
	_points = new Vector<PVector>();
}
 
开发者ID:abuzreq,项目名称:ConstrainedGraphPartitioning,代码行数:18,代码来源:VoronoiGenerator.java

示例11: Wuerfel

import processing.core.PApplet; //导入依赖的package包/类
Wuerfel(int x, int y, int s, PApplet p) {
	hoeheRec = s;
	breiteRec = s;
	r = hoeheRec / 6;
	xposRec = x;
	yposRec = y;
	parent = p;
	wuerfle(false);
	myDraw();
}
 
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:11,代码来源:Wuerfel.java

示例12: createRandomPointAround

import processing.core.PApplet; //导入依赖的package包/类
PVector createRandomPointAround(PApplet ap, PVector p, float minDist, float maxDist) 
{
	float a,r;
	if(ap != null)
	{
		 a = ap.random(2 * PApplet.PI);
		 r = ap.random(minDist, maxDist);
	}
	else
	{
		 a = alternateRandomRange(0,2 * PApplet.PI);
		 r = alternateRandomRange(minDist, maxDist);
	}
	return new PVector(p.x + r * PApplet.cos(a), p.y + r * PApplet.sin(a));
}
 
开发者ID:abuzreq,项目名称:ConstrainedGraphPartitioning,代码行数:16,代码来源:VoronoiGenerator.java

示例13: WuerfelRahmen

import processing.core.PApplet; //导入依赖的package包/类
WuerfelRahmen(PApplet p) {
	parent = p;
	int anzZ = (int) PApplet.sqrt(anzW);
	int anzS = anzZ;
	int anzL = 0;
	if (anzS * anzZ < anzW) {
		anzS++;
		anzL = anzW - anzS * (anzZ - 1);
		w = p.width;
	}

	if (parent.height < w)
		w = parent.height;
	int s = (w - (anzS + 1) * wuerfelAbstand) / anzS;
	// int f = (w -(s+wuerfelAbstand) * anzL) /2;
	// xx if (anzL == 0) f = wuerfelAbstand;

	for (int j = 0; j < anzZ; j++) {
		for (int i = 0; i < anzS; i++) {
			int x = (wuerfelAbstand + s) * i + wuerfelAbstand;
			int y = (wuerfelAbstand + s) * j + wuerfelAbstand;
			if (anzL != 0 && j == anzZ - 1) {
				if (i >= anzL)
					break;
				// ... x = (wuerfelAbstand + s) * i + f; // HLU 19.5.17 line
				// commented
			}
			wuerfelListe.add(new Wuerfel(x, y, s, parent));
		}
	}
}
 
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:32,代码来源:WuerfelRahmen.java

示例14: loadLifeExpectancyFromCSV

import processing.core.PApplet; //导入依赖的package包/类
public static HashMap<String, Float> loadLifeExpectancyFromCSV(PApplet p, String fileName) {
	// HashMap key: country ID and  data: lifeExp at birth
	HashMap<String, Float> lifeExpMap = new HashMap<String, Float>();

	// get lines of csv file
	String[] rows = p.loadStrings(fileName);
	
	// Reads country name and population density value from CSV row
	for (String row : rows) {
		// split row by commas not in quotations
		String[] columns = row.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
		
		// check if there is any life expectancy data from any year, get most recent
		/*
		 * EXTENSION: Add code to also get the year the data is from.
		 * You may want to use a list of Floats as the  values for the HashMap
		 * and store the year as the second value. (There are many other ways to do this)
		 */
		//
		for(int i = columns.length - 1; i > 3; i--) {
			
			// check if value exists for year
			if(!columns[i].equals("..")) {
				lifeExpMap.put(columns[3], Float.parseFloat(columns[i]));
				
				// break once most recent data is found
				break;
			}
		}
		
	}

	return lifeExpMap;
}
 
开发者ID:simontangbit,项目名称:CourseCode,代码行数:35,代码来源:ParseFeed.java

示例15: getDevices

import processing.core.PApplet; //导入依赖的package包/类
/**
 * get a list of all devices
 * 
 * @param papplet
 * @return
 */
public static PS3EyeP5[] getDevices(PApplet papplet){
  if(PS3EYE_LIST == null){
    Device[] devices = usb.getDevices(PS3Eye.VENDOR_ID, PS3Eye.PRODUCT_ID);
    PS3EYE_LIST = new PS3EyeP5[devices.length];
    for(int i = 0; i < devices.length; i++){
      PS3EYE_LIST[i] = new PS3EyeP5(devices[i], i, papplet);
    }
  }
  return PS3EYE_LIST;
}
 
开发者ID:diwi,项目名称:PS3Eye,代码行数:17,代码来源:PS3EyeP5.java


注:本文中的processing.core.PApplet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。