processing.core.PApplet Java Examples
The following examples show how to use
processing.core.PApplet.
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: NectarOpenNI.java From PapARt with GNU Lesser General Public License v3.0 | 6 votes |
public NectarOpenNI(PApplet parent, Camera anotherCam) throws CannotCreateCameraException { super(parent); if (anotherCam instanceof CameraNectar) { this.camera = (CameraNectar) anotherCam; this.camera.setUseDepth(true); } else { initDefaultCamera(); this.anotherCamera = anotherCam; } if (this.anotherCamera == null) { this.anotherCamera = getColorCamera(); } cameraNectar = (CameraNectar) camera; camera.getDepthCamera().setCalibration(Papart.AstraSDepthCalib); camera.getColorCamera().setCalibration(Papart.AstraSRGBCalib); setStereoCalibration(Papart.AstraSStereoCalib); // setStereoCalibration(Papart.kinectStereoCalib); // TODO: Hacks to try to handle the SR300 distorsions // camera.getDepthCamera().setCalibration(Papart.SR300IRCalib); // camera.getIRCamera().setCalibration(Papart.SR300IRCalib); }
Example #2
Source File: RingtoneVideo.java From haxademic with MIT License | 6 votes |
public void update( float vol ) { vol *= 4; // calc how many to draw int numToDraw = PApplet.floor( vol / _eqSegment ); float remainder = vol - numToDraw * _eqSegment; // draw whole steps tint( 1, 1 ); for( int i = 0; i < numToDraw; i ++ ) { pushMatrix(); image( _image, _index * 100, 500 - i*100, 100, 100 ); popMatrix(); } // draw last tint( 1, vol ); pushMatrix(); image( _image, _index * 100, 500 - numToDraw*100, 100, 100 ); popMatrix(); }
Example #3
Source File: MultiSimpleCalibrator.java From PapARt with GNU Lesser General Public License v3.0 | 6 votes |
public static void drawAR(PApplet parent, PGraphicsOpenGL g, MultiSimpleCalibrator multiCalibrator, PVector pt) { // AR rendering, for touch and color tracking (and debug). if (multiCalibrator.getDisplay() instanceof ARDisplay) { ARDisplay display = (ARDisplay) multiCalibrator.getDisplay(); display.drawScreensOver(); parent.noStroke(); PImage img = multiCalibrator.getCameraTracking().getPImage(); if (multiCalibrator.getCameraTracking() != null && img != null) { parent.image(img, 0, 0, parent.width, parent.height); // ((PGraphicsOpenGL) (parent.g)).image(camera.getPImage(), 0, 0, frameWidth, frameHeight); } // TODO: Distorsion problems with higher image space distorisions (useless ?) DrawUtils.drawImage((PGraphicsOpenGL) parent.g, display.render(), 0, 0, parent.width, parent.height); } }
Example #4
Source File: PShape.java From CPE552-Java with GNU General Public License v3.0 | 6 votes |
public void quadraticVertex(float cx, float cy, float x3, float y3) { if (vertices == null) { vertices = new float[10][]; } else if (vertexCount + 1 >= vertices.length) { vertices = (float[][]) PApplet.expand(vertices); } vertices[vertexCount++] = new float[] { cx, cy }; vertices[vertexCount++] = new float[] { x3, y3 }; // vertexCodes must be allocated because a vertex() call is required if (vertexCodes.length == vertexCodeCount) { vertexCodes = PApplet.expand(vertexCodes); } vertexCodes[vertexCodeCount++] = QUADRATIC_VERTEX; if (x3 > width) { width = x3; } if (y3 > height) { height = y3; } }
Example #5
Source File: KinectWrapperV2.java From haxademic with MIT License | 6 votes |
public KinectWrapperV2( PApplet p, boolean initRGB, boolean initDepthImage ) { this.p = p; DepthCameraSize.setSize(KWIDTH, KHEIGHT); _kinect = new KinectPV2(p); _kinect.enableDepthImg(initDepthImage); _kinect.enableColorImg(initRGB); _kinect.enableDepthMaskImg(true); _kinect.enableBodyTrackImg(true); _kinect.enableInfraredImg(true); _kinect.init(); //TODO: Setup configurations to activate each individually //_kinect.activateRawColor(true); //_kinect.enableInfraredImg(true); //_kinect.enableLongExposureInfraredImg(true); int bufSize = _kinect.getDepthImage().height * _kinect.getDepthImage().width; _depthArray = new int[bufSize]; setMirror(false); }
Example #6
Source File: Tileset.java From Project-16x16 with GNU General Public License v3.0 | 6 votes |
public static ArrayList<PImage> getAnimation(String name){ for(int i = 0; i < JSONanimations.size(); i++) { JSONObject animation = JSONanimations.getJSONObject(i); if (animation.getString("name").contentEquals(name)) { ArrayList<PImage> tiles = new ArrayList<PImage>(); JSONArray tileRefs = animation.getJSONArray("tileRef"); for(int k = 0; k < tileRefs.size(); k++) { JSONObject tileRef = tileRefs.getJSONObject(k); tiles.add(getTile(tileRef.getString("name"))); } return tiles; } } PApplet.println("<Tileset> Error while loading, null string reference to animation ( " + name + " ) >"); return null; }
Example #7
Source File: MapProvider.java From constellation with Apache License 2.0 | 6 votes |
@Override public Coordinate sourceCoordinate(final Coordinate coordinate) { final float columnSize = PApplet.pow(2, coordinate.zoom); float wrappedColumn = coordinate.column % columnSize; while (wrappedColumn < 0) { wrappedColumn += columnSize; } final float rowSize = PApplet.pow(2, coordinate.zoom); float wrappedRow = coordinate.row % rowSize; while (wrappedRow < 0) { wrappedRow += rowSize; } return new Coordinate(wrappedRow, wrappedColumn, coordinate.zoom); }
Example #8
Source File: Stats.java From haxademic with MIT License | 5 votes |
/** * Ported from https://github.com/mrdoob/stats.js * @param p */ public Stats( PApplet p ) { this.p = p; _time = p.millis(); _timeLastFrame = _time; _timeLastSecond = _time; }
Example #9
Source File: TimeFactoredFps.java From haxademic with MIT License | 5 votes |
public TimeFactoredFps( PApplet p, float targetFps ) { this.targetFps = targetFps; timeFactor = 1; timeFactorEased = new EasingFloat(1, 20); actualFps = targetFps; lastTime = p.millis(); }
Example #10
Source File: QuadSurface.java From sketch-mapper with MIT License | 5 votes |
/** * Convenience method used by the constructors. * * @param parent * @param ks * @param res * @param id */ private void init(PApplet parent, SurfaceMapper ks, int res, int id, String name) { this.parent = parent; this.sm = ks; this.surfaceId = id; this.surfaceName = name; this.GRID_RESOLUTION = res + 1; this.updateCalibrateTexture(); this.cornerPoints = new Point3D[4]; for (int i = 0; i < this.cornerPoints.length; i++) { this.cornerPoints[i] = new Point3D(); } GRID_LINE_COLOR = parent.color(160, 160, 160, 50); GRID_LINE_SELECTED_COLOR = parent.color(0, 255, 255); SELECTED_OUTLINE_OUTER_COLOR = parent.color(0, 255, 255, 128); SELECTED_OUTLINE_INNER_COLOR = parent.color(50, 255, 255); CORNER_MARKER_COLOR = parent.color(255, 255, 255, 100); SELECTED_CORNER_MARKER_COLOR = parent.color(255, 0, 255); this.initTransform(); //maskFilter = new PImage(parent, "Mask.xml"); //edgeBlendTex = new GLTexture(parent, "edgeblendmask.png"); }
Example #11
Source File: Device.java From KinectPV2 with MIT License | 5 votes |
/** * Get Long Exposure Infrared Image as PImage 512 x 424 * * @return PImage */ public PImage getInfraredLongExposureImage() { int[] longExposureData = jniGetInfraredLongExposure(); PApplet.arrayCopy(longExposureData, 0, infraredLongExposureImg.pixels(), 0, infraredLongExposureImg.getImgSize()); infraredLongExposureImg.updatePixels(); return infraredLongExposureImg.img; }
Example #12
Source File: GifMaker.java From gif-animation with GNU General Public License v3.0 | 5 votes |
public GifMaker(PApplet parent, String filename, int quality, int bgColor) { this.parent = parent; parent.registerMethod("dispose", this); encoder = initEncoder(filename); setQuality(quality); setTransparent(bgColor); }
Example #13
Source File: BezierSurface.java From sketch-mapper with MIT License | 5 votes |
private void updateBlendScreen() { if (blendScreen == null) { blendScreen = parent.createGraphics(512, 512); } blendScreen.beginDraw(); if (this.isBlendLeft()) { blendScreen.noStroke(); blendScreen.beginShape(PApplet.QUADS); blendScreen.texture(edgeBlendTex); blendScreen.vertex(-2, 0, 0, 0); blendScreen.vertex(blendScreen.width * this.getBlendLeftSize(), 0, edgeBlendTex.width, 0); blendScreen.vertex(blendScreen.width * this.getBlendLeftSize(), blendScreen.height, edgeBlendTex.width, edgeBlendTex.height); blendScreen.vertex(-2, blendScreen.height, 0, edgeBlendTex.height); blendScreen.endShape(PApplet.CLOSE); } if (this.isBlendRight()) { blendScreen.noStroke(); blendScreen.beginShape(PApplet.QUADS); blendScreen.texture(edgeBlendTex); blendScreen.vertex(blendScreen.width - (blendScreen.width * this.getBlendRightSize()), 0, edgeBlendTex.width, 0); blendScreen.vertex(blendScreen.width + 2, 0, 0, 0); blendScreen.vertex(blendScreen.width + 2, blendScreen.height, 0, edgeBlendTex.height); blendScreen.vertex(blendScreen.width - (blendScreen.width * this.getBlendRightSize()), blendScreen.height, edgeBlendTex.width, edgeBlendTex.height); blendScreen.endShape(PApplet.CLOSE); } blendScreen.endDraw(); }
Example #14
Source File: AudioIn.java From processing-sound with GNU Lesser General Public License v2.1 | 5 votes |
/** * @param parent * typically use "this" * @param in * input channel number (optional, default 0) */ public AudioIn(PApplet parent, int in) { super(parent); // TODO check if the current input device actually has 'in' input channels, // otherwise an ugly exception is thrown if (Engine.getAudioManager() instanceof JSynAndroidAudioDeviceManager) { if (in != 0) { Engine.printWarning("if you want to capture audio from somewhere other than the default\n" + "device on Android, use: new Sound(this).inputDevice(deviceID)\n" + "where for deviceID you can fill in any of Android's MediaRecorder.AudioSource constants."); } // we're on Android, check if the sketch has permission to capture Audio if (!parent.hasPermission(Manifest.permission.RECORD_AUDIO)) { Engine.printError(AudioIn.ANDROID_PERMISSION_WARNING_MESSAGE); throw new AndroidPermissionException("RECORD_AUDIO permission not granted"); } Engine.printMessage("capturing audio in from device " + Engine.getSelectedInputDeviceName()); } this.input = new ChannelIn(in); this.multiplier = new Multiply(); this.multiplier.inputA.connect(this.input.output); this.amplitude = this.multiplier.inputB; // set default amplitude this.multiplier.inputB.set(1.0); this.circuit = new JSynCircuit(this.multiplier.output); this.circuit.add(this.input); }
Example #15
Source File: PointsDeformAndTextureFilter.java From haxademic with MIT License | 5 votes |
public PointsDeformAndTextureFilter(PApplet p) { super(p, "haxademic/shaders/point/points-default-frag.glsl", "haxademic/shaders/point/points-deform-and-texture-vert.glsl" ); setColorMap(DemoAssets.justin()); setDisplacementMap(DemoAssets.justin()); setDisplaceAmp(1f); setMaxPointSize(3f); setModelMaxExtent(1000); setSheetMode(true); setColorPointSizeMode(true); }
Example #16
Source File: PShape.java From CPE552-Java with GNU General Public License v3.0 | 5 votes |
/** Resize the children[] array to be in line with childCount */ protected void crop() { // https://github.com/processing/processing/issues/3347 if (children.length != childCount) { children = (PShape[]) PApplet.subset(children, 0, childCount); } }
Example #17
Source File: MagicProjectile.java From Project-16x16 with GNU General Public License v3.0 | 5 votes |
private void setParticleAnimation(SideScroller a) { particleAnimation = new ArrayList<PImage>(); PImage image = Tileset.getTile("MAGIC_SOURCE"); float scale = 0.12f; float angle = PApplet.radians(11); while(scale > 0.025f) { particleAnimation.add(Utility.resizeImage(Utility.resizeImage(Utility.rotateImage(image.copy(), angle), scale), 4)); angle += PApplet.radians(11); scale -= Math.random() * 0.03f; } }
Example #18
Source File: MathUtils.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
/** * RGB distance of two colors. Return true if all channels differences are * below the difference threshold. * * @param c1 * @param c2 * @param threshold * @return */ public static boolean colorDistRGB(int c1, int c2, int threshold) { int r1 = c1 >> 16 & 255; int g1 = c1 >> 8 & 255; int b1 = c1 >> 0 & 255; int r2 = c2 >> 16 & 255; int g2 = c2 >> 8 & 255; int b2 = c2 >> 0 & 255; int dr = PApplet.abs(r1 - r2); int dg = PApplet.abs(g1 - g2); int db = PApplet.abs(b1 - b2); return dr < threshold && dg < threshold && db < threshold; }
Example #19
Source File: Device.java From KinectPV2 with MIT License | 5 votes |
/** * Get InfraredImage as PImage 512 x 424 * * @return PImage */ public PImage getInfraredImage() { int[] infraredData = jniGetInfraredData(); PApplet.arrayCopy(infraredData, 0, infraredImg.pixels(), 0, infraredImg.getImgSize()); infraredImg.updatePixels(); return infraredImg.img; }
Example #20
Source File: ProcessingSigViewer_V2.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
static public void main(String[] passedArgs) { String[] appletArgs = new String[] { "ProcessingSigViewer_V2" }; if (passedArgs != null) { PApplet.main(concat(appletArgs, passedArgs)); } else { PApplet.main(appletArgs); } }
Example #21
Source File: Camera.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
static public void convertARParams(PApplet parent, ProjectiveDeviceP projectiveDevice, String calibrationARtoolkit) { try { fr.inria.papart.utils.ARToolkitPlusUtils.convertARParamFromDevice(parent, projectiveDevice, calibrationARtoolkit); } catch (Exception e) { PApplet.println("Conversion error. " + e); } }
Example #22
Source File: MathUtils.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
/** * RGB distance of two colors. Return true if all channels differences are * below the difference threshold. * * @param c1 * @param c2 * @param tr * @param tg * @param tb * @return */ public static boolean colorDistRGB(int c1, int c2, int tr, int tg, int tb) { int r1 = c1 >> 16 & 255; int g1 = c1 >> 8 & 255; int b1 = c1 >> 0 & 255; int r2 = c2 >> 16 & 255; int g2 = c2 >> 8 & 255; int b2 = c2 >> 0 & 255; int dr = PApplet.abs(r1 - r2); int dg = PApplet.abs(g1 - g2); int db = PApplet.abs(b1 - b2); return dr < tr && dg < tg && db < tb; }
Example #23
Source File: PShape.java From CPE552-Java with GNU General Public License v3.0 | 5 votes |
protected void beginContourImpl() { if (vertexCodes == null) { vertexCodes = new int[10]; } else if (vertexCodes.length == vertexCodeCount) { vertexCodes = PApplet.expand(vertexCodes); } vertexCodes[vertexCodeCount++] = BREAK; }
Example #24
Source File: DrawUtils.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
static public void drawImage(PGraphics3D pg3d, PImage img, int x, int y, int w, int h) { pg3d.pushMatrix(); pg3d.translate(x, y); pg3d.scale(-1, 1, 1); pg3d.rotate(PApplet.PI); pg3d.image(img, 0, 0, w, h); pg3d.popMatrix(); }
Example #25
Source File: Device.java From KinectPV2 with MIT License | 5 votes |
/** * Get Depth Image as PImage 512 x 424 * * @return PImage */ public PImage getDepthImage() { int [] depthData = jniGetDepth16Data(); PApplet.arrayCopy(depthData, 0, depthImg.pixels(), 0, depthImg.getImgSize()); depthImg.updatePixels(); return depthImg.img; }
Example #26
Source File: KinectWrapperV1.java From haxademic with MIT License | 5 votes |
public KinectWrapperV1( PApplet p, boolean initRGB, boolean initDepthImage, int cameraIndex ) { this.p = p; this.cameraIndex = cameraIndex; // init camera object. 2nd camera (and theoretically beyond) need a different constructor if(this.cameraIndex == 0) { _kinect = new SimpleOpenNI( p, SimpleOpenNI.RUN_MODE_DEFAULT ); } else { _kinect = new SimpleOpenNI( SimpleOpenNI.RUN_MODE_MULTI_THREADED, p, 1 ); } // init kinect properties boolean initSuccess = _kinect.enableDepth(); if(initRGB) _kinect.enableRGB(); // _kinect.setMirror(false); // _kinect.enableIR(); // IR doesn't like being enabled off the bat - it kills the RGB camera?! // enable depthMap generation if(initSuccess == false && KINECT_ERROR_SHOWN == false) { DebugUtil.alert("Can't access the Kinect. Make sure it's plugged into the computer and a power outlet."); _kinectActive = false; KINECT_ERROR_SHOWN = true; p.exit(); } else { // capture one frame of depth data so the array exists. otherwise the new threading would return null on the first frame _depthArray = _kinect.depthMap(); } }
Example #27
Source File: DwSoftBody3D.java From PixelFlow with MIT License | 5 votes |
@Override public void createShapeParticles(PApplet papplet, boolean icosahedron){ PShape shp = papplet.createShape(PShape.GROUP); for(int i = 0; i < particles.length; i++){ float radius = 1; // float radius = particles[i].rad; PShape shp_pa = createShape(papplet, radius, icosahedron); particles[i].setShape(shp_pa); shp.addChild(shp_pa); } setShapeParticles(papplet, shp); }
Example #28
Source File: ProcessingSigViewer_V2.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Transforms the data into the frequency domain using the Minim library, and returns only those frequencies between * the given lowest and highest frequency. * @param parent - papplet * @param data - the data you want to show * @param lowFreq - the lower cutoff frequency * @param highFreq - the upper cutoff frequency * @param sampleFreq - used as sample rate * @return result - the data between lowFreq and highFreq in the frequency domain */ public static float[] procfft(PApplet parent, double [] data, int lowFreq, int highFreq, float sampleFreq) { Minim minim = new Minim(parent); float[] fdata = BasicStats.toFloatArray(data); // this should be as large as you want your FFT to be. generally speaking, 1024 is probably fine. int fftSize = 1024; float[] fftSamples = new float[fftSize]; FFT fft = new FFT( fftSize, sampleFreq ); ArrayList<Float> spectrum = new ArrayList(); //Array to put the results in System.arraycopy( fdata, 0, fftSamples, 0, fdata.length); // in case the data is not a power of 2 if ( fdata.length < fftSize ) { java.util.Arrays.fill( fftSamples, fdata.length, fftSamples.length - 1, 0.0f ); } // now analyze this buffer fft.forward( fftSamples ); for (int i = 0; i < fftSize/2; ++i) { if (fft.indexToFreq(i) <= highFreq && fft.indexToFreq(i) >= lowFreq) { spectrum.add(fft.getBand(i)); } } float[] result = new float[spectrum.size()]; for (int i = 0; i < spectrum.size(); i++) { result[i] = (float) spectrum.get(i); } return result; }
Example #29
Source File: ColorDetection.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
/** * Draw the zone captured to compute the color. */ public void drawCaptureZone() { paperScreen.pushMatrix(); paperScreen.translate(pos.x, pos.y, 0.2f); paperScreen.strokeWeight(2); paperScreen.noFill(); paperScreen.stroke(80); paperScreen.rectMode(PApplet.CORNER); paperScreen.rect(0, 0, captureSize.x, captureSize.y); paperScreen.popMatrix(); }
Example #30
Source File: LeaveWhiteFilter.java From haxademic with MIT License | 4 votes |
public LeaveWhiteFilter(PApplet p) { super(p, "haxademic/shaders/filters/leave-white.glsl"); setCrossfade(1f); }