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

The following examples show how to use processing.core.PGraphics#smooth() . 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: ConstellationLineMarker.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public boolean draw(final PGraphics graphics, final List<MapPosition> positions, final UnfoldingMap map) {
    if (positions.isEmpty() || isHidden()) {
        return false;
    }

    graphics.pushStyle();
    graphics.noFill();
    graphics.strokeWeight(size == MarkerUtilities.DEFAULT_SIZE ? strokeWeight : size);
    graphics.stroke(getFillColor());
    graphics.smooth();

    graphics.beginShape(PConstants.LINES);
    for (int i = 0; i < positions.size() - 1; ++i) {
        final MapPosition lastPosition = positions.get(i);
        final MapPosition currentPosition = positions.get(i + 1);
        graphics.vertex(lastPosition.x, lastPosition.y);
        graphics.vertex(currentPosition.x, currentPosition.y);
    }
    graphics.endShape();
    graphics.popStyle();

    return true;
}
 
Example 2
Source File: HaiBlobsSSAO.java    From haxademic with MIT License 6 votes vote down vote up
protected void builtGradientTextureLoop() {
	int textureW = p.width * 1;
	int textureH = p.height;
	int gradientW = textureW / 4;
	PGraphics img = p.createGraphics(textureW, textureH, P.P2D);
	img.smooth(8);
	tickerFXBuffer = p.createGraphics(textureW, textureH, P.P2D);
	tickerFXBuffer.smooth(8);
	img.beginDraw();
	img.noStroke();
	img.translate(gradientW / 2, textureH/2);
	Gradients.linear(img, gradientW, textureH, COLOR_1, COLOR_3);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_3, COLOR_2);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_2, COLOR_4);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_4, COLOR_1);
	img.endDraw();
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	
	ticker = new TickerScroller(img, p.color(255), textureW, textureH, (float)textureW / (float)_frames);
}
 
Example 3
Source File: BlindSpotColored.java    From haxademic with MIT License 6 votes vote down vote up
protected void builtGradientTextureLoop() {
		int textureW = p.width * 4;
		int textureH = p.height * 1;
		int gradientW = textureW / 4;
		PGraphics img = p.createGraphics(textureW, textureH, P.P2D);
		img.smooth(8);
		tickerFXBuffer = p.createGraphics(textureW, textureH, P.P2D);
		tickerFXBuffer.smooth(8);
		img.beginDraw();
		img.noStroke();
		img.translate(gradientW / 2, textureH/2);
		Gradients.linear(img, gradientW, textureH, COLOR_1, COLOR_3);
		img.translate(gradientW, 0);
		Gradients.linear(img, gradientW, textureH, COLOR_3, COLOR_2);
		img.translate(gradientW, 0);
		Gradients.linear(img, gradientW, textureH, COLOR_2, COLOR_4);
		img.translate(gradientW, 0);
		Gradients.linear(img, gradientW, textureH, COLOR_4, COLOR_1);
		img.endDraw();
		BlurHFilter.instance(p).setBlurByPercent(0.75f, img.width);
		BlurHFilter.instance(p).applyTo(img);
//		BlurHFilter.instance(p).applyTo(img);
//		BlurHFilter.instance(p).applyTo(img);
		
		ticker = new TickerScroller(img, p.color(255), textureW, textureH, (float)textureW / (float)frames);
	}
 
Example 4
Source File: Demo_PGraphicsKeystone_Grid.java    From haxademic with MIT License 5 votes vote down vote up
protected void buildCanvas() {
	keystoneQuads = new PGraphicsKeystone[rows * cols];
	for (int i = 0; i < keystoneQuads.length; i++) {
		PGraphics pg = p.createGraphics( p.width / 2, p.height / 2, P.P3D );
		pg.smooth(OpenGLUtil.SMOOTH_HIGH);
		keystoneQuads[i] = new PGraphicsKeystone(p, pg, 12, FileUtil.getPath("text/keystoning/grid-demo"+i+".txt"));
	}
}
 
Example 5
Source File: BlobsForFun.java    From haxademic with MIT License 5 votes vote down vote up
protected void builtGradientTextureLoop() {
	int textureW = p.width * 4;
	int textureH = p.height;
	int gradientW = textureW / 6;
	PGraphics img = p.createGraphics(textureW, textureH, P.P2D);
	img.smooth(8);
	tickerFXBuffer = p.createGraphics(textureW, textureH, P.P2D);
	tickerFXBuffer.smooth(8);
	img.beginDraw();
	img.noStroke();
	img.translate(gradientW / 2, textureH/2);
	Gradients.linear(img, gradientW, textureH, COLOR_1, COLOR_2);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_2, COLOR_3);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_3, COLOR_4);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_4, COLOR_5);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_5, COLOR_6);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_6, COLOR_1);
	img.endDraw();
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	
	ticker = new TickerScroller(img, p.color(255), textureW, textureH, (float)textureW / (float)_frames);
}
 
Example 6
Source File: HaiBlobs.java    From haxademic with MIT License 5 votes vote down vote up
protected void builtGradientTextureLoop() {
	int textureW = p.width * 4;
	int textureH = p.height;
	int gradientW = textureW / 6;
	PGraphics img = p.createGraphics(textureW, textureH, P.P2D);
	img.smooth(8);
	tickerFXBuffer = p.createGraphics(textureW, textureH, P.P2D);
	tickerFXBuffer.smooth(8);
	img.beginDraw();
	img.noStroke();
	img.translate(gradientW / 2, textureH/2);
	Gradients.linear(img, gradientW, textureH, COLOR_1, COLOR_2);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_2, COLOR_3);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_3, COLOR_4);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_4, COLOR_5);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_5, COLOR_6);
	img.translate(gradientW, 0);
	Gradients.linear(img, gradientW, textureH, COLOR_6, COLOR_1);
	img.endDraw();
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	BlurHFilter.instance(p).setBlurByPercent(0.5f, img.width);
	
	ticker = new TickerScroller(img, p.color(255), textureW, textureH, (float)textureW / (float)_frames);
}
 
Example 7
Source File: GradientsBaseLayer2.java    From haxademic with MIT License 4 votes vote down vote up
protected void firstFrame() {
		int[] colors = new int[] {
				// superbowl: #0D131B
				ColorUtil.colorFromHex("#ff0D131B"),
				// team 1
//				ColorUtil.colorFromHex("#ff0B1630"),
//				ColorUtil.colorFromHex("#ffBB0022"),
//				ColorUtil.colorFromHex("#ff0B1630"),
//				ColorUtil.colorFromHex("#ffBB0022"),
				// team 2
//				ColorUtil.colorFromHex("#ff471D6C"),
//				ColorUtil.colorFromHex("#ffF5AB2C"),
//				ColorUtil.colorFromHex("#ff471D6C"),
//				ColorUtil.colorFromHex("#ffF5AB2C"),
				// team 3
				ColorUtil.colorFromHex("#ff9AAAA8"),
				ColorUtil.colorFromHex("#ff0E1210"),
				ColorUtil.colorFromHex("#ff9AAAA8"),
				ColorUtil.colorFromHex("#ff0E1210"),
//				// superbowl: #0D131B
				ColorUtil.colorFromHex("#ff0D131B"),
		};
		
		int gradientW = P.round(p.width * 0.25f);
		
		PGraphics img = p.createGraphics(gradientW * colors.length, p.height, P.P3D);
		img.smooth(8);
		
		img.beginDraw();
		img.noStroke();
		img.translate(gradientW/2, p.height/2);
		
		for (int i = 0; i < colors.length; i++) {
			Gradients.linear(img, gradientW, p.height, colors[i], colors[(i+1) % colors.length]);
			img.translate(gradientW, 0);
		}
		
		img.endDraw();
		
		// apply blur
		BlurHFilter.instance(p).setBlurByPercent(0.15f, img.width);
		for (int i = 0; i < 10; i++) BlurHFilter.instance(p).applyTo(img);
		
		// add to debug display
		DebugView.setTexture("gradient", img);
		
		// build ticker
		float tickerLoopSpeed = (float) img.width / (float) FRAMES;
		ticker = new TickerScroller(img, p.color(255), gradientW, p.height, tickerLoopSpeed);
	}