Java Code Examples for processing.core.PGraphics#clear()

The following examples show how to use processing.core.PGraphics#clear() . 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: Demo_MaskConcentric.java    From haxademic with MIT License 6 votes vote down vote up
public void updateShadows() {
	for (int i = 0; i < numCircles; i++) {
		PGraphics shadow = shadows[i];
		shadow.beginDraw();
		shadow.clear();
		shadow.image(images[i], 0, 0);
		BlurProcessingFilter.instance(p).setBlurSize(12);
		BlurProcessingFilter.instance(p).setSigma(2.4f);
		for (int j = 0; j < 6; j++) {
			BlurProcessingFilter.instance(p).applyTo(shadow);
		}
		colorTransformShader.set("color", 0f, 0f, 0f);
		shadow.filter(colorTransformShader);
		shadow.endDraw();
	}
}
 
Example 2
Source File: ShaderSSAO.java    From haxademic with MIT License 6 votes vote down vote up
protected void drawShapes(PGraphics pg, boolean addLights) {
		pg.beginDraw();
		pg.clear();
		PG.setDrawCenter(pg);
		pg.sphereDetail(7);
		pg.noStroke();
				
		// move to center
		pg.translate(pg.width/2, pg.height/2, 0);
		
		// lighting
		if(addLights == true) pg.lights();
		
//		drawCubesInCircle(pg);
//		drawCubesInGrid(pg);
		drawFewCubes(pg);
		
		pg.endDraw();
	}
 
Example 3
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 4
Source File: BFLinewaveRender.java    From haxademic with MIT License 6 votes vote down vote up
protected void drawGraphics( PGraphics pg ) {
	pg.beginDraw();
	pg.clear();
	PG.setDrawCorner(pg);
	
	// timeline
	float percentComplete = ((float)(p.frameCount%_frames)/_frames);
	float frameOsc = P.sin( PConstants.TWO_PI * percentComplete);

	// reference image
	pg.image(_print, 0, 0, p.width, p.height);
	
	// white bg
	pg.fill(255, 255);
	pg.noStroke();
	pg.rect(266, 175, 373, 537);
	
	// draw lines
	int numLines = _lines.size();
	for (int i = 0; i < numLines; i++) {
		_lines.get(i).update(pg, frameOsc);
	}
	
	pg.endDraw();
}
 
Example 5
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 6
Source File: Silhouect.java    From haxademic with MIT License 6 votes vote down vote up
protected void storeUserFrame() {
	if(noUser == false && flashFrame == true) {
		// if user, add a frame to the array
		if(lastUserBuffer.size() < USER_HISTORY_SIZE) {
			PGraphics newUserBuffer = p.createGraphics(userBuffer.width, userBuffer.height, PRenderers.P2D); 
			if(lastUserBuffer.size() == 0) slideshow.add(newUserBuffer);	// add a single PGraphics to end of slideshow array
			lastUserBuffer.add(newUserBuffer);
			userHistoryStorageIndex = lastUserBuffer.size() - 1;
		} else {
			userHistoryStorageIndex++;
			if(userHistoryStorageIndex >= lastUserBuffer.size()) userHistoryStorageIndex = 0;
		}
		
		// draw current frame to oldest buffer
		PGraphics oldBuffer = lastUserBuffer.get(userHistoryStorageIndex);
		oldBuffer.beginDraw();
		oldBuffer.clear();
		oldBuffer.copy(userBuffer, 0, 0, userBuffer.width, userBuffer.height, 0, 0, oldBuffer.width, oldBuffer.height);
		oldBuffer.endDraw();
	}
}
 
Example 7
Source File: Utility.java    From Project-16x16 with GNU General Public License v3.0 5 votes vote down vote up
public static PImage resizeImage(PImage img, float scl) {
	PGraphics pg = applet.createGraphics((int) (img.width * scl), (int) (img.height * scl));

	pg.noSmooth();
	pg.beginDraw();
	pg.clear();
	pg.scale(scl, scl);
	pg.image(img, 0, 0);
	pg.endDraw();

	return pg;
}
 
Example 8
Source File: Utility.java    From Project-16x16 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Rotates a PImage object by a given angle in radians.
 *
 * @param img PImage image to rotate.
 * @param angle Angle in radians.
 * @return new PImage object transformed.
 */
public static PImage rotateImage(PImage img, float angle) {
	PGraphics pg = applet.createGraphics((int) (img.width * 1.5), (int) (img.height * 1.5));

	pg.beginDraw();
	pg.clear();
	pg.imageMode(PApplet.CENTER);
	pg.translate(pg.width / 2, pg.height / 2);
	pg.rotate(angle);
	pg.image(img, 0, 0);
	pg.endDraw();

	return pg;
}
 
Example 9
Source File: Demo_Shapes_drawDisc2.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawGraphicsNative( PGraphics pg ) {
		PG.setDrawCenter(pg);
		pg.beginDraw();
		pg.clear();
		PG.setBasicLights(pg);
		
		float frameRadians = P.TWO_PI / _frames;
		float percentComplete = ((float)(p.frameCount%_frames)/_frames);
		float radiansComplete = P.TWO_PI * percentComplete;
		float easedPercent = Penner.easeInOutCubic(percentComplete);
		float easedPercentHard = Penner.easeInOutQuad(percentComplete);

//		pg.background(0);
		pg.translate(p.width/2, p.height/2 + p.height * 0.04f);
		pg.blendMode(P.SCREEN);
//		pg.blendMode(P.MULTIPLY);

//		pg.rotateY(p.mouseX * 0.01f);
//		pg.rotateX(p.mouseY * 0.01f);
		pg.rotateX(4.3f + 0.01f * P.sin(percentComplete * P.TWO_PI));
//		pg.rotateX(4.3f);
		
		pg.noStroke();
		
		int numDiscs = 25;
		float spacing = p.width * 0.019f;
		pg.translate(0, 0, spacing * numDiscs * 0.3f);
		for (int i = 0; i < numDiscs; i++) {			
			float percentDone = percentComplete + ((float)i/numDiscs);
			float size = p.width * 0.3f + p.width * 0.01f * P.sin(percentDone * P.TWO_PI);
			int discColor = p.color(200 + (i*5), 100 + (i*5), 170 - (i*5), 60);
			pg.fill(discColor);

			pg.translate(0,0,-spacing);
//			Shapes.drawDisc3D(pg, size, size * 0.9f - size * (P.sin(percentDone * P.TWO_PI)+1) * 0.15f, spacing, 40, discColor, discColor);
			Shapes.drawDisc(pg, size, size * 0.9f - size * (P.sin(percentDone * P.TWO_PI)+1) * 0.15f, 6); 
		}
		
		pg.endDraw();
	}
 
Example 10
Source File: Demo_MotionBlurPGraphics.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawGraphics( PGraphics pg ) {
	// redraw pgraphics grid
	PG.setDrawCenter(pg);
	pg.beginDraw();
	pg.clear();
	pg.stroke(0);
	pg.fill(255);
	pg.translate((p.frameCount * 3) % p.width, p.height/2);
	pg.rotate(p.frameCount * 0.1f);
	pg.rect(0, 0, 50, 50);
	pg.endDraw();
}
 
Example 11
Source File: Demo_DropShadowBlur.java    From haxademic with MIT License 5 votes vote down vote up
public PGraphics imageToImageWithPadding(PImage img, float scaleCanvasUp) {
	PGraphics pg = PG.newPG(P.ceil((float) img.width * scaleCanvasUp), P.ceil((float) img.height * scaleCanvasUp));
	pg.beginDraw();
	PG.setDrawCenter(pg);
	pg.clear();
	pg.translate(pg.width/2, pg.height/2);
	pg.image(img, 0, 0);
	pg.endDraw();
	return pg;
}
 
Example 12
Source File: GifRenderEllo021ElloBurst.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawGraphics( PGraphics pg ) {
	pg.beginDraw();
	pg.clear();
	PG.setDrawCorner(_pg);
	int numBursts = _bursts.size();
	for (int i = 0; i < numBursts; i++) {
		_bursts.get(i).update();
	}
	pg.endDraw();
}
 
Example 13
Source File: ImageUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static PGraphics imageToGraphicsWithPadding(PImage img, float fillAmount) {
	PGraphics image = ImageUtil.imageToGraphics(img);
	image.beginDraw();
	PG.setDrawCenter(image);
	image.clear();
	image.translate(image.width/2, image.height/2);
	image.image(img, 0, 0, img.width * fillAmount, img.height * fillAmount);
	image.endDraw();
	return image;
}
 
Example 14
Source File: ImageUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static PImage imageToImageWithPadding(PImage img, float scaleCanvasUp) {
	PGraphics pg = P.p.createGraphics(P.ceil((float) img.width * scaleCanvasUp), P.ceil((float) img.height * scaleCanvasUp));
	pg.beginDraw();
	PG.setDrawCenter(pg);
	pg.clear();
	pg.translate(pg.width/2, pg.height/2);
	pg.image(img, 0, 0);
	pg.endDraw();
	return pg.copy();
}