Java Code Examples for processing.core.PConstants#TWO_PI

The following examples show how to use processing.core.PConstants#TWO_PI . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GifRenderEllo002RotateEased.java    From haxademic with MIT License 6 votes vote down vote up
protected void drawApp() {
		p.background(255);
//		p.fill(255, 40);
//		p.rect(0, 0, p.width, p.height);
		p.noStroke();
		
		float frameRadians = PConstants.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
		float easedPercent = Penner.easeInOutQuart(percentComplete, 0, 1, 1);

		float frameOsc = P.sin( PConstants.TWO_PI * percentComplete);
//		float elloSize = (float)(p.width/1.5f + 7f * frameOsc);
		float elloSize = (float)(p.width);
		
		PG.setDrawCorner(p);
		
		p.translate(p.width/2, p.height/2);
//		p.rotate(frameRadians * p.frameCount);
		p.rotate(easedPercent * PConstants.TWO_PI);
		p.shape(_logo, 0, 0, elloSize, elloSize);
	}
 
Example 2
Source File: GifRenderEllo025LoadingAnimationV3.java    From haxademic with MIT License 6 votes vote down vote up
public void drawGraphics(PGraphics pg) {
		
		float frameRadians = PConstants.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
//		float easedPercent = Penner.easeInOutExpo(percentComplete, 0, 1, 1);
//		float easedPercent = Penner.easeInOutQuart(percentComplete, 0, 1, 1);
		float easedPercent = Penner.easeInOutCubic(percentComplete, 0, 1, 1);

		float frameOsc = P.sin( PConstants.TWO_PI * percentComplete);
		float elloSize = (float)(p.width);
		
		PG.setDrawCenter(pg);
		pg.beginDraw();
		pg.clear();
		pg.background(255);
		pg.noStroke();

		pg.translate(pg.width/2, pg.height/2);
		float rotations = 2;
		pg.rotate(easedPercent * PConstants.TWO_PI * rotations);
		pg.shape(_logo, 0, 0, elloSize, elloSize);

		pg.endDraw();
	}
 
Example 3
Source File: GifRenderEllo015InfiniteScrollLoader.java    From haxademic with MIT License 6 votes vote down vote up
protected void drawApp() {
		p.background(255);
		p.noStroke();
		
		float frameRadians = PConstants.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
		float easedPercent = Penner.easeInOutQuart(percentComplete, 0, 1, 1);

		float frameOsc = P.sin( PConstants.TWO_PI * percentComplete);
		float scale = 0.95f;
		float oscSize = 0.1f;
		float elloSize = (float)(p.width * (scale - oscSize + oscSize * frameOsc));
//		float elloSize = (float)(40 * (scale - oscSize + oscSize * frameOsc));	// with padding
		
		PG.setDrawCenter(p);
		
		p.translate(p.width/2, p.height/2);
//		p.rotate(frameRadians * p.frameCount);
//		p.rotate(easedPercent * PConstants.TWO_PI);
		p.fill(ColorUtil.colorFromHex("#DFDFDF"));
		p.stroke(0,0);
		p.ellipse(0, 0, elloSize, elloSize);
	}
 
Example 4
Source File: BiglyText.java    From haxademic with MIT License 6 votes vote down vote up
public void drawGraphics( PGraphics pg ) {
//		if(p.frameCount == 1) p.background(255);
		pg.beginDraw();
		pg.clear();

//		pg.background(255);
		pg.noStroke();
		
		float frameRadians = PConstants.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
		float progressRads = percentComplete * P.TWO_PI;
		float easedPercent = Penner.easeInOutQuart(percentComplete, 0, 1, 1);

		
		// Bread!
		pg.translate(p.width/2, p.height/2);
		PG.setDrawCenter(pg);
		PG.setPImageAlpha(pg, 0.3f);
		pg.scale(0.9f + P.sin(progressRads) * 0.1f);
		pg.rotate(0.01f * P.sin(P.PI/2 + progressRads));
		pg.image(biglyImg, 0, 0);

		pg.endDraw();
	}
 
Example 5
Source File: GifRenderEllo002ScaleEased.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawApp() {
		p.background(255);
//		p.fill(255, 40);
//		p.rect(0, 0, p.width, p.height);
		p.noStroke();
		
		float frameRadians = PConstants.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
		float easedPercent = Penner.easeInOutQuart(percentComplete, 0, 1, 1);

		float frameOsc = P.sin( PConstants.TWO_PI * percentComplete);
		float elloSize = (float)((p.width - p.width*0.02) + p.width*0.02 * frameOsc);
//		float elloSize = (float)(p.width);
		
		
		p.translate(p.width/2, p.height/2);
//		p.rotate(frameRadians * p.frameCount);
//		p.rotate(easedPercent * PConstants.TWO_PI);
		
		// Ello logo
//		PG.setDrawCorner(p);
//		p.shape(_logo, 0, 0, elloSize, elloSize);
		
		// Bread!
		PG.setDrawCenter(p);
		p.image(_bread, 0, 0, elloSize, elloSize);
	}
 
Example 6
Source File: GifRenderEllo005RollAcross.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawApp() {
		p.background(255);
		
		float frameRadians = PConstants.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
		
		if(percentComplete == 0)
			_elloSize *= 4;
		
		PG.setDrawCorner(p);
				
		float dist = percentComplete * (p.width + _elloSize*2);
		
		float x = -_elloSize + dist;
		float circumference = _elloSize * P.PI;
		float rotationRads = (x / circumference) * P.TWO_PI;
		
		p.pushMatrix();
		p.translate(x, p.height - _elloSize/2f);
		p.rotate(rotationRads);
		p.shape(_logo, 0, 0, _elloSize, _elloSize);
		p.popMatrix();

//		filter(INVERT);
//
//		if(Config.getBoolean("rendering_gif", false) == true) renderGifFrame();
//		if( p.frameCount == _frames * 4 + 5 ) {
//			if(Config.getBoolean("rendering_gif", false) ==  true) encoder.finish();
//			if(videoRenderer != null) {				
//				videoRenderer.stop();
//				P.println("render done!");
//			}
//		}

	}
 
Example 7
Source File: GifRenderEllo003ZoomInBW.java    From haxademic with MIT License 4 votes vote down vote up
protected void drawApp() {
		p.background(255);
//		p.fill(255, 40);
//		p.rect(0, 0, p.width, p.height);
		p.noStroke();
		
		float frameRadians = PConstants.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
		float percentWhiteComplete = P.constrain(((float)(p.frameCount - (_frames/2))/_frames), 0, 1);
		float percentBlackComplete = P.constrain(((float)(p.frameCount)/_frames), 0, 1);
		float easedScale = Penner.easeInOutQuart(percentComplete, 0, 1, 1);
		float easedWhiteScale = Penner.easeInOutQuart(percentWhiteComplete, 0, 1, 1);
		float easedWhiteRot = 0.6f - Penner.easeInOutSine(percentWhiteComplete, 0, 1, 1);
		float easedBlackScale = Penner.easeInOutQuart(percentBlackComplete, 0, 1, 1);
		float easedBlackRot = -0.6f + Penner.easeInOutSine(percentBlackComplete, 0, 1f, 1);

		float frameOsc = P.sin( PConstants.TWO_PI * percentComplete);
//		float elloSize = (float)(p.width/1.5f + 7f * frameOsc);
		float elloSize = (float)(p.width/1.5f);
		
		PG.setDrawCorner(p);
		
		p.translate(p.width/2, p.height/2);
//		p.rotate(frameRadians * p.frameCount);
		
//		P.println("frame",frameCount);
		
		p.pushMatrix();
		p.scale(easedBlackScale * 5f);
		p.rotate(easedBlackRot);
		p.shape(_logo, 0, 0, elloSize, elloSize);
		p.popMatrix();
		
		p.pushMatrix();
		p.scale(easedWhiteScale * 5f);
		p.rotate(easedWhiteRot);
		p.shape(_logoInverse, 0, 0, elloSize, elloSize);
		p.popMatrix();


		if(Config.getBoolean("rendering_gif", false) ==  true) renderGifFrame();
	}
 
Example 8
Source File: GifRenderEllo004SphereTextureMap.java    From haxademic with MIT License 4 votes vote down vote up
protected void drawApp() {
		p.background(255);
//		p.fill(255, 40);
//		p.rect(0, 0, p.width, p.height);
		p.noStroke();
		
//		ambientLight(102, 102, 102);
//		lightSpecular(204, 204, 204);
//		directionalLight(102, 102, 102, 0, 0, -1);
//		specular(255, 255, 255);
//		emissive(51, 51, 51);
//		ambient(50, 50, 50);
//		shininess(50.0f); 
		

		
		float frameRadians = PConstants.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
		float easedScale = Penner.easeInOutQuart(percentComplete, 0, 1, 1);

		float frameOsc = P.sin( PConstants.TWO_PI * percentComplete);
//		float elloSize = (float)(p.width/1.5f + 7f * frameOsc);
		float elloSize = (float)(p.width/1.5f);
		
		PG.setDrawCorner(p);
		
		p.translate(p.width/2, p.height/2);
		
		p.pushMatrix();
		
		p.translate( 0, 0, -p.width*2.7f );
		p.rotateZ(P.PI);
		
//		// spin it - y-axis
//		p.rotateY(9.5f - percentComplete * 3.35f); 
//		// spin it - x-axis
//		p.rotateY(7.825f);
//		p.rotateZ(-P.PI/2f - -percentComplete * P.PI); 
//		// shake "no"
//		p.rotateY(P.PI/2 + P.sin(percentComplete * P.TWO_PI) * 0.2f); 
//		// shake "yes"
//		p.rotateY(P.PI/2); 
//		p.rotateZ(P.sin(percentComplete * P.TWO_PI) * 0.1f);
//		// mouse it
//		p.rotateY(p.mouseX / 20f); 
		
//		MeshUtil.deformMeshWithAudio( _sphereMesh, _deformMesh, p._audioInput, 10 );
	
		// draw texture. if tinting happened, reset after drawing
		if( _texture != null ) MeshUtilToxi.drawToxiMesh( p, Toxiclibs.instance(p).toxi, _deformMesh, _texture );
		
		p.popMatrix();
	}
 
Example 9
Source File: GifRenderEllo006SpinTunnel.java    From haxademic with MIT License 4 votes vote down vote up
protected void drawApp() {
		p.background(255);
		
		float frameRadians = PConstants.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
//		float easedPercent = Penner.easeInCirc(percentComplete, 0, 1, 1);
		
		PG.setDrawCorner(p);
		p.translate(p.width/2, p.height/2f);

		float iterateFactor = 3f;
		float origSize = p.width * 2f;
		float growth = ((origSize * iterateFactor * iterateFactor) - origSize);
		_elloSize = origSize + percentComplete * growth;

		int index = 0;
		while( _elloSize > 2 ) {
			p.pushMatrix();
			if(index % 2 == 0) {
				p.rotate(frameRadians * p.frameCount * (index+1));
//				p.fill(255);
				p.ellipse(0, 0, _elloSize, _elloSize);
				p.shape(_logo, 0, 0, _elloSize, _elloSize);
			} else {				
				p.rotate(frameRadians * p.frameCount * (index+1));
				p.shape(_logoInverse, 0, 0, _elloSize, _elloSize);
			}
			p.popMatrix();
			
			
			_elloSize /= iterateFactor;
			index++;
		}
		

//		filter(INVERT);

//		if(Config.getBoolean("rendering_gif", false) == true) renderGifFrame();
//		if( p.frameCount == _frames * 8 ) {
//			if(Config.getBoolean("rendering_gif", false) ==  true) encoder.finish();
//			if(isRendering == true) {				
//				videoRenderer.stop();
//				P.println("render done!");
//			}
//		}

	}
 
Example 10
Source File: Utility.java    From Project-16x16 with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Calculates the angle between two PVectors where: East = 0; North = -1/2PI;
 * West = -PI; South = -3/2PI | 1/2PI
 * 
 * @param tail PVector Coordinate 1.
 * @param head PVector Coordinate 2.
 * @return float θ in radians.
 */
public static float angleBetween(PVector tail, PVector head) {
	float a = PApplet.atan2(tail.y - head.y, tail.x - head.x);
	if (a < 0) {
		a += PConstants.TWO_PI;
	}
	return a;
}