Java Code Examples for processing.core.PApplet#fill()

The following examples show how to use processing.core.PApplet#fill() . 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: DrawToxiMesh.java    From haxademic with MIT License 5 votes vote down vote up
public static void drawPointsWithAudio( PApplet p, WETriangleMesh mesh, AudioInputWrapper audioData, float spectrumFaceRatio, float pointSize, TColor fillColor, TColor strokeColor, float baseAlpha ) {
	p.rectMode( P.CENTER );
	int faceIndex = 0;
	int color = fillColor.toARGB();
	Face f;
	float alpha;
	baseAlpha = baseAlpha * 255;
	p.noStroke();
	for (Iterator<Face> i = mesh.faces.iterator(); i.hasNext();) {
		if( faceIndex % 2 == 0 ) {
			// set colors
			alpha = audioData.getFFT().spectrum[(int)(faceIndex/spectrumFaceRatio) % 512] * 1.3f;
			p.fill( color, baseAlpha + alpha * 255 );
			
			p.pushMatrix();
			f = (Face) i.next();
			Vec3D center = f.getCentroid();
			
			p.translate( center.x, center.y, center.z );
			p.rotateX( f.normal.x );
			p.rotateY( f.normal.y );
			p.rotateZ( f.normal.z );
			p.rect( 0, 0, pointSize + pointSize * alpha, pointSize + pointSize * alpha );
			p.popMatrix();
			
		}
		faceIndex ++;
	}
}
 
Example 2
Source File: KinectWrapperV2.java    From haxademic with MIT License 5 votes vote down vote up
public void drawPointCloudForRect( PApplet p, boolean mirrored, int pixelSkip, float alpha, float scale, float depthClose, float depthFar, int top, int right, int bottom, int left ) {
	p.pushMatrix();

	// Translate and rotate
	int curZ;
	
	// Scale up by 200
	float scaleFactor = scale;
	
	p.noStroke();
	
	for (int x = left; x < right; x += pixelSkip) {
		for (int y = top; y < bottom; y += pixelSkip) {
			curZ = getDepthAt(x, y);
			// draw a point within the specified depth range
			if( curZ > depthClose && curZ < depthFar ) {
				p.fill( 255, alpha * 255f );
			} else {
				p.fill( 255, 0, 0, alpha * 255f );
			}
			p.pushMatrix();
			p.translate( x * scaleFactor, y * scaleFactor, scaleFactor * curZ/40f );
			// Draw a point
			p.point(0, 0);
			p.rect(0, 0, 4, 4);
			p.popMatrix();
		}
	}
	p.popMatrix();
}
 
Example 3
Source File: KinectWrapperV1.java    From haxademic with MIT License 5 votes vote down vote up
public void drawPointCloudForRect( PApplet p, boolean mirrored, int pixelSkip, float alpha, float scale, float depthClose, float depthFar, int top, int right, int bottom, int left ) {
	p.pushMatrix();

	// Translate and rotate
	int curZ;
	
	// Scale up by 200
	float scaleFactor = scale;
	
	p.noStroke();
	
	for (int x = left; x < right; x += pixelSkip) {
		for (int y = top; y < bottom; y += pixelSkip) {
			curZ = getDepthAt(x, y);
			// draw a point within the specified depth range
			if( curZ > depthClose && curZ < depthFar ) {
				p.fill( 255, alpha * 255f );
			} else {
				p.fill( 255, 0, 0, alpha * 255f );
			}
			p.pushMatrix();
			p.translate( x * scaleFactor, y * scaleFactor, scaleFactor * curZ/40f );
			// Draw a point
			p.point(0, 0);
			p.rect(0, 0, 4, 4);
			p.popMatrix();
		}
	}
	p.popMatrix();
}