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

The following examples show how to use processing.core.PGraphics#scale() . 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: 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 2
Source File: WashHands.java    From haxademic with MIT License 6 votes vote down vote up
public void update(PGraphics pg) {
	pg.push();
	pg.translate(pg.width * x, pg.height * y, 0);	// -0.25f   -0.33f
	if(FrameLoop.isTick()) {
		if(FrameLoop.curTick() == tickShow) wordWashEase.setInc(0.07f).setTarget(1);
		if(FrameLoop.curTick() == tickShow + 4) wordWashEase.setInc(0.04f).setTarget(0);
		if(tickShow == 4 && FrameLoop.curTick() % 8 == 0)  wordWashEase.setInc(0.04f).setTarget(0);
	}
	wordWashEase.update();
	float easedProgress = Penner.easeInOutExpo(wordWashEase.value());
	pg.rotateY(rotY + FrameLoop.osc(0.125f, -0.2f, 0.2f));  // 0.4f
	if(tickShow != 4) pg.rotateX(rotX + FrameLoop.osc(0.225f, -0.05f, 0.05f));  // -0.1f
	else pg.rotateX(rotX*1.5f);
	pg.scale(easedProgress);
	pg.shape(wordWash);
	pg.pop();
}
 
Example 3
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 4
Source File: ImageSequencePlayer.java    From haxademic with MIT License 5 votes vote down vote up
public int display(PGraphics pg, int x, int y, int frame) {
	boolean flipped = (frameIndexPlaybackSequence[frame] < 0);
	frame = P.abs(frameIndexPlaybackSequence[frame]);
	if(loaded == false) return -1;
	if(imageSequence.size() > frame) {
		pg.pushMatrix();
		pg.translate(x + imgW/2, y + imgH/2);
		if(flipped == true) pg.scale(-1, 1);
		pg.image(imageSequence.get(frame), 0, 0, imgW, imgH);
		pg.popMatrix();
	}
	return frame;
}
 
Example 5
Source File: Particle3d.java    From haxademic with MIT License 5 votes vote down vote up
public void update(PGraphics pg) {
	if(available()) return;
	
	// update position
	if(gravity.mag() > 0) speed.add(gravity);
	if(acceleration != 1) speed.mult(acceleration);
	pos.add(speed);
	rotation.add(rotationSpeed);
	
	// update size
	sizeProgress.update();
	float curSize = size * Penner.easeOutSine(sizeProgress.value());
	if(sizeProgress.value() == 1) sizeProgress.setTarget(0);
	
	// draw image
	pg.pushMatrix();
	pg.translate(pos.x, pos.y, pos.z);
	pg.rotateX(rotation.x);
	pg.rotateY(rotation.y);
	pg.rotateZ(rotation.z);
	pg.fill(color);
	if(customShape != null) {
		pg.pushMatrix();
		pg.scale(Penner.easeOutExpo(sizeProgress.value()) * curSize / customShape.getHeight());
		pg.shape(customShape);
		pg.popMatrix();
	} else {
		if(isSphere) {
			pg.sphere(curSize/2f);
		} else {
			pg.box(curSize, curSize, curSize);
		}
	}
	pg.fill(255);
	pg.popMatrix();
}
 
Example 6
Source File: ImageSequenceMovieClip.java    From haxademic with MIT License 5 votes vote down vote up
public void drawToPGraphics(PGraphics pg, float x, float y, float scale) {
	pg.pushMatrix();
	pg.translate(x, y);
	if(isFlipped == true) pg.scale(-1, 1);
	pg.image(image(), 0, 0, image().width * scale, image().height * scale);
	pg.popMatrix();
}