Java Code Examples for processing.core.PGraphics#noStroke()
The following examples show how to use
processing.core.PGraphics#noStroke() .
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: PG.java From haxademic with MIT License | 6 votes |
public static void drawGrid(PGraphics pg, int bgColor, int strokeColor, float cols, float rows, float strokeSize) { // update texture pg.beginDraw(); pg.background(bgColor); pg.fill(strokeColor); pg.noStroke(); float cellW = (float) pg.width / (float) cols; cellW -= strokeSize / cols; float cellH = (float) pg.height / (float) rows; cellH -= strokeSize / rows; for (float x = 0; x <= pg.width; x += cellW) { pg.rect(x, 0, strokeSize, pg.height); } for (float y = 0; y <= pg.height; y += cellH) { pg.rect(0, y, pg.width, strokeSize); } pg.endDraw(); }
Example 2
Source File: BaseMappedPolygon.java From haxademic with MIT License | 6 votes |
protected void drawFlashFadeOverlay(PGraphics pg) { // run flash fading _isFlash *= 0.9f; if(_isFlash > 0.01f) { if(_isFlashMode == 0) { if(_isWireMode == 0) { pg.noStroke(); pg.fill(0, _isFlash * 255f); } else { pg.stroke(0, _isFlash * 255f); pg.strokeWeight(1.1f); pg.noFill(); } } else { if(_isWireMode == 0) { pg.noStroke(); pg.fill(255, _isFlash * 255f); } else { pg.stroke(255, _isFlash * 255f); pg.strokeWeight(1.1f); pg.noFill(); } } rawDrawPolygon(pg); } }
Example 3
Source File: BFLinewaveRender.java From haxademic with MIT License | 6 votes |
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 4
Source File: PG.java From haxademic with MIT License | 6 votes |
public static void feedback(PGraphics pg, int color, float colorFade, float feedbackDistance) { PG.setDrawCorner(pg); PG.setDrawFlat2d(pg, true); pg.copy( pg, 0, 0, pg.width, pg.height, P.round(-feedbackDistance), P.round(-feedbackDistance), P.round(pg.width + feedbackDistance * 2f), P.round(pg.height + feedbackDistance * 2f) ); if(color != -1) { pg.fill(color, colorFade * 255f); pg.noStroke(); pg.rect(0, 0, pg.width, pg.height); } PG.setDrawFlat2d(pg, false); }
Example 5
Source File: PG.java From haxademic with MIT License | 6 votes |
public static void drawTestPattern(PGraphics pg) { pg.beginDraw(); pg.noStroke(); int cellSize = pg.pixelWidth / 20; int twoCells = cellSize * 2; for( int x=0; x < pg.width; x+= cellSize) { for( int y=0; y < pg.height; y+= cellSize) { if( ( x % twoCells == 0 && y % twoCells == 0 ) || ( x % twoCells == cellSize && y % twoCells == cellSize ) ) { pg.fill(0); } else { pg.fill(255); } pg.rect(x,y,cellSize,cellSize); } } pg.endDraw(); }
Example 6
Source File: PG.java From haxademic with MIT License | 6 votes |
public static PGraphics newDataPG(int w, int h) { // PGraphics newPG = P.p.createGraphics(w, h, PRenderers.P3D); // PGraphics newPG = P.p.createGraphics(w, h, P.P32); PGraphics newPG = PGraphics32.createGraphics(P.p, w, h); newPG.noSmooth(); ((PGraphicsOpenGL)newPG).textureSampling(2); newPG.beginDraw(); // newPG.hint(P.DISABLE_TEXTURE_MIPMAPS); newPG.hint(PConstants.DISABLE_DEPTH_SORT); newPG.hint(PConstants.DISABLE_DEPTH_TEST); newPG.hint(PConstants.DISABLE_DEPTH_MASK); newPG.background(0, 0); newPG.noStroke(); newPG.endDraw(); // moved these calls into this block for a full test of options // OpenGLUtil.setTextureQualityLow(newPG); // necessary for proper texel lookup in GLSL! // OpenGLUtil.optimize2D(newPG); return newPG; }
Example 7
Source File: UITitle.java From haxademic with MIT License | 6 votes |
public void draw(PGraphics pg) { PG.setDrawCorner(pg); // outline pg.noStroke(); pg.fill(ColorsHax.BUTTON_OUTLINE); pg.rect(rect.x, rect.y, rect.width, rect.height); // background pg.fill(ColorsHax.TITLE_BG); pg.rect(rect.x+1, rect.y+1, rect.width-2, rect.height-2); // text label IUIControl.setFont(pg); pg.fill(ColorsHax.BUTTON_TEXT); pg.text(label, rect.x + TEXT_INDENT, rect.y); }
Example 8
Source File: HaiBlobsSSAO.java From haxademic with MIT License | 6 votes |
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 9
Source File: Shapes.java From haxademic with MIT License | 5 votes |
public static void drawTexturedLine(PGraphics pg, PImage texture, float xStart, float yStart, float xEnd, float yEnd, int color, float thickness, float texOffset, float cornerRadius) { // calc textured rectangle rotation * distance float startToEndAngle = MathUtil.getRadiansToTarget(xStart, yStart, xEnd, yEnd); float dist = MathUtil.getDistance(xStart, yStart, xEnd, yEnd); float thicknessHalf = thickness/2f; float textureHeightHalf = texture.height/2f; // set context OpenGLUtil.setTextureRepeat(pg); pg.push(); pg.translate(xStart, yStart); pg.rotate(startToEndAngle); // draw textured rect pg.noStroke(); pg.beginShape(); pg.texture(texture); pg.textureMode(P.IMAGE); pg.tint(color); if(cornerRadius <= 0) { pg.vertex(0, -thicknessHalf, 0, texOffset, 0); pg.vertex(dist, -thicknessHalf, 0, texOffset + dist, 0); pg.vertex(dist, thicknessHalf, 0, texOffset + dist, texture.height); pg.vertex(0, thicknessHalf, 0, texOffset, texture.height); } else { // diamond shape, left/center, clockwise to right/center pg.vertex(0, 0, 0, texOffset, textureHeightHalf); pg.vertex(cornerRadius, -thicknessHalf, 0, texOffset + cornerRadius, 0); pg.vertex(dist - cornerRadius, -thicknessHalf, 0, texOffset + dist - cornerRadius, 0); // right/center, clockwise to left/center pg.vertex(dist, 0, 0, texOffset + dist, textureHeightHalf); pg.vertex(dist - cornerRadius, thicknessHalf, 0, texOffset + dist - cornerRadius, texture.height); pg.vertex(cornerRadius, thicknessHalf, 0, texOffset + cornerRadius, texture.height); } pg.endShape(); pg.noTint(); pg.pop(); }
Example 10
Source File: Demo_BackgroundGradientAndShadow.java From haxademic with MIT License | 5 votes |
protected void drawShape(PGraphics pg) { pg.noStroke(); pg.pushMatrix(); pg.translate(0, 180 * P.sin(FrameLoop.progressRads())); pg.rotateY(FrameLoop.progressRads()); pg.box(400, 20, 50); pg.box(50, 20, 400); // PShapeUtil.drawTriangles(pg, obj, null, 1); pg.popMatrix(); }
Example 11
Source File: DwFoldingTile.java From PixelFlow with MIT License | 5 votes |
public void displayMesh(PGraphics pg, DwIndexedFaceSet ifs){ // pg.beginShape(PConstants.TRIANGLES); pg.textureMode(PConstants.NORMAL); pg.texture(DEF.style.texture); pg.noStroke(); int s0,s1,s2; int i0,i1,i2; float[] t0,t1,t2; float[] v0,v1,v2; for(int i = 0; i < DEF.FACES_COUNT; i++){ i0 = faces[i][0]; v0 = ifs.verts[i0]; i1 = faces[i][1]; v1 = ifs.verts[i1]; i2 = faces[i][2]; v2 = ifs.verts[i2]; i0 = DEF.FACES[i][0]; s0 = DEF.HILO[i0]; t0 = DEF.TEX_COORDS[i0]; i1 = DEF.FACES[i][1]; s1 = DEF.HILO[i1]; t1 = DEF.TEX_COORDS[i1]; i2 = DEF.FACES[i][2]; s2 = DEF.HILO[i2]; t2 = DEF.TEX_COORDS[i2]; int ci = DEF.FACES_COL[i]; if(DEF.style.texture != null){ DwDisplayUtils.vertex(pg, v0, t0); DwDisplayUtils.vertex(pg, v1, t1); DwDisplayUtils.vertex(pg, v2, t2); } else { // pg.fill(DEF.style.COL[s0]); DwDisplayUtils.vertex(pg, v0); // pg.fill(DEF.style.COL[s1]); DwDisplayUtils.vertex(pg, v1); // pg.fill(DEF.style.COL[s2]); DwDisplayUtils.vertex(pg, v2); pg.fill(DEF.style.RGBS[ci][s0]); DwDisplayUtils.vertex(pg, v0); pg.fill(DEF.style.RGBS[ci][s1]); DwDisplayUtils.vertex(pg, v1); pg.fill(DEF.style.RGBS[ci][s2]); DwDisplayUtils.vertex(pg, v2); } } // pg.endShape(); }
Example 12
Source File: BezierSurface.java From sketch-mapper with MIT License | 4 votes |
/** * Actual rendering of the surface. Is called from the render method. * Should normally not be accessed directly. * * @param g * @param tex */ private void renderSurface(PGraphics g, PImage tex) { float tWidth = 1; float tHeight = 1; float tOffX = 0; float tOffY = 0; tWidth = tex.width * (textureWindow[1].x); tHeight = tex.height * (textureWindow[1].y); tOffX = tex.width * textureWindow[0].x; tOffY = tex.height * textureWindow[0].y; if (this.isUsingEdgeBlend() || this.isUsingSurfaceMask()) { if (bufferScreen == null || bufferScreen.width != this.getBufferScreenWidth()) { bufferScreen = parent.createGraphics(this.getBufferScreenWidth(), this.getBufferScreenWidth()); } bufferScreen.beginDraw(); bufferScreen.beginShape(PApplet.QUADS); bufferScreen.texture(tex); bufferScreen.vertex(0, 0, tOffX, tOffY); bufferScreen.vertex(bufferScreen.width, 0, tWidth + tOffX, tOffY); bufferScreen.vertex(bufferScreen.width, bufferScreen.height, tWidth + tOffX, tHeight + tOffY); bufferScreen.vertex(0, bufferScreen.height, tOffX, tHeight + tOffY); bufferScreen.endShape(PApplet.CLOSE); bufferScreen.endDraw(); if (this.isUsingSurfaceMask()) { // maskFilter.setParameterValue("mask_factor", 0.0f); // maskFilter.apply(new GLTexture[]{bufferScreen.getTexture(), surfaceMask}, maskedTex); // applyEdgeBlendToTexture(maskedTex); } else { applyEdgeBlendToTexture(bufferScreen.get()); } } g.beginDraw(); g.noStroke(); g.beginShape(PApplet.QUADS); if (this.isUsingSurfaceMask() || this.isUsingEdgeBlend()) { g.texture(maskedTex); tOffX = 0; tOffY = 0; tWidth = maskedTex.width; tHeight = maskedTex.height; } else { g.texture(tex); if (bufferScreen != null) bufferScreen = null; } for (int i = 0; i < GRID_RESOLUTION; i++) { for (int j = 0; j < GRID_RESOLUTION; j++) { g.vertex(vertexPoints[i][j].x, vertexPoints[i][j].y, vertexPoints[i][j].z + currentZ, ((float) i / GRID_RESOLUTION) * tWidth + tOffX, ((float) j / GRID_RESOLUTION) * tHeight + tOffY); g.vertex(vertexPoints[i + 1][j].x, vertexPoints[i + 1][j].y, vertexPoints[i + 1][j].z + currentZ, (((float) i + 1) / GRID_RESOLUTION) * tWidth + tOffX, ((float) j / GRID_RESOLUTION) * tHeight + tOffY); g.vertex(vertexPoints[i + 1][j + 1].x, vertexPoints[i + 1][j + 1].y, vertexPoints[i + 1][j + 1].z + currentZ, (((float) i + 1) / GRID_RESOLUTION) * tWidth + tOffX, (((float) j + 1) / GRID_RESOLUTION) * tHeight + tOffY); g.vertex(vertexPoints[i][j + 1].x, vertexPoints[i][j + 1].y, vertexPoints[i][j + 1].z + currentZ, ((float) i / GRID_RESOLUTION) * tWidth + tOffX, (((float) j + 1) / GRID_RESOLUTION) * tHeight + tOffY); } } g.endShape(PApplet.CLOSE); g.endDraw(); }
Example 13
Source File: MappedQuad.java From haxademic with MIT License | 4 votes |
public void draw( PGraphics pg ) { if( _texture != null ) { if( _mappingStyle == MAP_STYLE_CONTAIN_TEXTURE ) { if( _mappingOrientation == 0 ) { pg.beginShape(PConstants.QUAD); pg.texture(_texture); pg.vertex(x1, y1, 0, 0, 0); pg.vertex(x2, y2, 0, _texture.width, 0); pg.vertex(x3, y3, 0, _texture.width, _texture.height); pg.vertex(x4, y4, 0, 0, _texture.height); pg.endShape(); } else if( _mappingOrientation == 1 ) { pg.vertex(x1, y1, 0, 0, 0); pg.vertex(x2, y2, 0, _texture.width, 0); pg.vertex(x3, y3, 0, _texture.width/2, _texture.height); } else if( _mappingOrientation == 2 ) { pg.vertex(x1, y1, 0, 0, _texture.height/2); pg.vertex(x2, y2, 0, _texture.width, 0); pg.vertex(x3, y3, 0, _texture.width, _texture.height); } else if( _mappingOrientation == 3 ) { pg.vertex(x1, y1, 0, 0, _texture.height); pg.vertex(x2, y2, 0, _texture.width/2, 0); pg.vertex(x3, y3, 0, _texture.width, _texture.height); } } else if( _mappingStyle == MAP_STYLE_MASK ) { pg.beginShape(PConstants.QUAD); pg.texture(_texture); // map the screen coordinates to the texture coordinates // crop to fill the mapped area with the current texture pg.vertex(x1, y1, 0, _maskRect[0].x, _maskRect[0].y); pg.vertex(x2, y2, 0, _maskRect[1].x, _maskRect[1].y); pg.vertex(x3, y3, 0, _maskRect[2].x, _maskRect[2].y); pg.vertex(x4, y4, 0, _maskRect[3].x, _maskRect[3].y); pg.endShape(); } else if( _mappingStyle == MAP_STYLE_CONTAIN_RANDOM_TEX_AREA ) { pg.beginShape(PConstants.QUAD); pg.texture(_texture); // map the polygon coordinates to the random sampling coordinates pg.vertex(x1, y1, 0, _randRect.x, _randRect.y); pg.vertex(x2, y2, 0, _randRect.x + _randRect.width, _randRect.y); pg.vertex(x3, y3, 0, _randRect.x + _randRect.width, _randRect.y + _randRect.height); pg.vertex(x4, y4, 0, _randRect.x, _randRect.y + _randRect.height); pg.endShape(); } else if( _mappingStyle == MAP_STYLE_EQ ) { pg.beginShape(PConstants.QUAD); pg.fill(pg.color(_color, P.constrain( AudioIn.audioFreq(_eqIndex) * 255, 0, 255 ))); pg.vertex(x1, y1, 0); pg.vertex(x2, y2, 0); pg.vertex(x3, y3, 0); pg.fill(pg.color(_color, P.constrain( AudioIn.audioFreq(_eqIndex) * 100, 0, 190 ))); pg.vertex(x4, y4, 0); pg.endShape(); } // flash fade overlay drawFlashFadeOverlay(pg); // overlay with gradient, oscillating from white to black over time float whiteFade = P.sin(P.p.frameCount / _gradientFadeDivisor); //P.constrain( AudioIn.getEqBand((_eqIndex)) * 200 * _isFlash, 0, 50 ); pg.noStroke(); pg.beginShape(PConstants.QUAD); pg.fill(255*whiteFade,fakeLightAlpha); pg.vertex(x2, y2, 0); pg.vertex(x3, y3, 0); pg.fill(255*whiteFade,0); pg.vertex(x4, y4, 0); pg.vertex(x1, y1, 0); pg.endShape(); } // show debug info // pg.fill(255); // pg.textSize(20); // pg.text(_mappingStyle+"", _centerX, _centerY); }
Example 14
Source File: Partycles.java From haxademic with MIT License | 4 votes |
public void update(PGraphics pg) { if(available()) return; // update position gravity.x *= 0.97f; speed.add(gravity); pos.add(speed); rotation += gravity.z; // update size sizeProgress.update(); float audioAmp = (1f + 1f * AudioIn.audioFreq(audioIndex)); if(sizeProgress.value() == 1) shrink -= 0.01f; float curSize = (sizeProgress.value() == 1) ? size * shrink * audioAmp: size * Penner.easeOutQuad(sizeProgress.value()) * audioAmp; // if(sizeProgress.value() == 1) sizeProgress.setTarget(0); // draw image or polygon if(image != null) { // draw image pg.pushMatrix(); pg.translate(pos.x, pos.y); pg.rotate(rotation); pg.tint(color); pg.image(image, 0, 0, curSize * 2f, curSize * 2f); pg.tint(255); pg.popMatrix(); } else { // draw shape float segmentRads = P.TWO_PI / vertices; pg.fill(color); // , 150); // pg.stroke(255); pg.noStroke(); pg.pushMatrix(); pg.translate(pos.x, pos.y); pg.rotate(rotation); pg.beginShape(P.POLYGON); for(float i = 0; i <= vertices; i++) { pg.vertex(P.cos(segmentRads * i) * curSize, P.sin(segmentRads * i) * curSize); } pg.endShape(); pg.popMatrix(); // pg.rect(pos.x, pos.y, 2, 2); } pg.tint(255); }
Example 15
Source File: QuadSurface.java From sketch-mapper with MIT License | 4 votes |
/** * Actual rendering of the QUAD. Is called from the render method. Should * normally not be accessed directly. * * @param g * @param tex */ private void renderQuad(PGraphics g, PImage tex) { tOffX = tex.width * textureWindow[0].x; tOffY = tex.height * textureWindow[0].y; tWidth = tex.width * (textureWindow[1].x); tHeight = tex.height * (textureWindow[1].y); if (this.isUsingEdgeBlend() || this.isUsingSurfaceMask()) { // // if (bufferScreen == null || bufferScreen.width != this.getBufferScreenWidth()) { // bufferScreen = parent.createGraphics(this.getBufferScreenWidth(), this.getBufferScreenWidth()); // } // bufferScreen.beginDraw(); // bufferScreen.beginShape(PApplet.QUADS); // bufferScreen.texture(tex); // bufferScreen.vertex(0, 0, tOffX, tOffY); // bufferScreen.vertex(bufferScreen.width, 0, tWidth + tOffX, tOffY); // bufferScreen.vertex(bufferScreen.width, bufferScreen.height, tWidth + tOffX, tHeight + tOffY); // bufferScreen.vertex(0, bufferScreen.height, tOffX, tHeight + tOffY); // bufferScreen.endShape(PApplet.CLOSE); // bufferScreen.endDraw(); // // // if (this.isUsingSurfaceMask()) { //// maskFilter.setParameterValue("mask_factor", 0.0f); //// maskFilter.apply(new GLTexture[]{bufferScreen.getTexture(), surfaceMask}, maskedTex); //// applyEdgeBlendToTexture(maskedTex); // } else { // applyEdgeBlendToTexture(bufferScreen.get()); // } } g.beginDraw(); g.noStroke(); g.beginShape(PApplet.QUADS); g.texture(tex); if (this.isUsingSurfaceMask() || this.isUsingEdgeBlend()) { g.texture(maskedTex); tOffX = 0; tOffY = 0; tWidth = maskedTex.width; tHeight = maskedTex.height; } else { g.texture(tex); if (bufferScreen != null) { bufferScreen = null; } if (blendScreen != null) { blendScreen = null; } } for (int i = 0; i < GRID_RESOLUTION - 1; i++) { for (int j = 0; j < GRID_RESOLUTION - 1; j++) { g.vertex(vertexPoints[i][j].x, vertexPoints[i][j].y, vertexPoints[i][j].z + currentZ, ((float) i / (GRID_RESOLUTION - 1)) * tWidth + tOffX, ((float) j / (GRID_RESOLUTION - 1)) * tHeight + tOffY); g.vertex(vertexPoints[i + 1][j].x, vertexPoints[i + 1][j].y, vertexPoints[i + 1][j].z + currentZ, (((float) i + 1) / (GRID_RESOLUTION - 1)) * tWidth + tOffX, ((float) j / (GRID_RESOLUTION - 1)) * tHeight + tOffY); g.vertex(vertexPoints[i + 1][j + 1].x, vertexPoints[i + 1][j + 1].y, vertexPoints[i + 1][j + 1].z + currentZ, (((float) i + 1) / (GRID_RESOLUTION - 1)) * tWidth + tOffX, (((float) j + 1) / (GRID_RESOLUTION - 1)) * tHeight + tOffY); g.vertex(vertexPoints[i][j + 1].x, vertexPoints[i][j + 1].y, vertexPoints[i][j + 1].z + currentZ, ((float) i / (GRID_RESOLUTION - 1)) * tWidth + tOffX, (((float) j + 1) / (GRID_RESOLUTION - 1)) * tHeight + tOffY); } } g.endShape(PApplet.CLOSE); g.endDraw(); }
Example 16
Source File: Demo_KinectV1MultiCamWrapper.java From haxademic with MIT License | 4 votes |
protected int drawKinectDepthPixels(KinectWrapperV1 kinect, PGraphics buffer, int pixelColor, boolean drawAllData) { // open context buffer.beginDraw(); if(drawAllData == true) buffer.background(0, 0); buffer.noStroke(); buffer.fill(pixelColor); // loop through kinect data within player's control range float pixelDepth; float avgX = 0; float avgY = 0; float numPoints = 0; float kinectDepthZone = slider(KINECT_FAR) - slider(KINECT_NEAR); float distancePixels = (float) KinectWrapperV1.KWIDTH / kinectDepthZone; // map distance to width float pixelSkip = slider(PIXEL_SIZE); // float pixelHalf = pixelSkip / 2f; // TODO: Switch to ONLY loop through kinect points that we need for ( int x = 0; x < DepthCameraSize.WIDTH; x += pixelSkip ) { for ( int y = 0; y < KinectWrapperV2.KHEIGHT; y += pixelSkip ) { pixelDepth = kinect.getDepthAt( x, y ); if(pixelDepth != 0 && pixelDepth > slider(KINECT_NEAR) && pixelDepth < slider(KINECT_FAR)) { // draw depth points float userZ = P.map(pixelDepth, slider(KINECT_NEAR), slider(KINECT_FAR), 0, kinectDepthZone * distancePixels); if(drawAllData == true || (y > slider(KINECT_TOP) && y < slider(KINECT_BOTTOM))) { buffer.rect(x - 5, userZ - 5, 10, 10); } // calc data processing numPoints++; avgX += x; avgY += userZ; } } } // show CoM buffer.fill(pixelColor); if(drawAllData == false) buffer.ellipse(avgX / numPoints, avgY / numPoints, 20, 20); // close buffer buffer.endDraw(); return (int) numPoints; }
Example 17
Source File: SurfaceMapper.java From sketch-mapper with MIT License | 4 votes |
/** * Render method used when calibrating. Shouldn't be used for final rendering. * * @param glos */ public void render(PGraphics glos) { // glos.beginDraw(); // glos.endDraw(); if (MODE == MODE_CALIBRATE) { parent.cursor(); glos.beginDraw(); if (this.isUsingBackground()) { glos.image(backgroundTexture, 0, 0, width, height); } glos.fill(0, 40); glos.noStroke(); glos.rect(-2, -2, width + 4, height + 4); glos.stroke(255, 255, 255, 40); glos.strokeWeight(1); /* * float gridRes = 32.0f; * * float step = (float) (width / gridRes); * * for (float i = 1; i < width; i += step) { glos.line(i, 0, i, parent.height); } * * step = (float) (height / gridRes); * * for (float i = 1; i < width; i += step) { glos.line(0, i, parent.width, i); } */ glos.stroke(255); glos.strokeWeight(2); glos.line(1, 1, width - 1, 1); glos.line(width - 1, 1, width - 1, height - 1); glos.line(1, height - 1, width - 1, height - 1); glos.line(1, 1, 1, height - 1); glos.endDraw(); for (int i = 0; i < surfaces.size(); i++) { surfaces.get(i).render(glos); } // Draw circles for SelectionDistance or SnapDistance (snap if CMD // is down) glos.beginDraw(); if (enableSelectionMouse) { if (!ctrlDown) { glos.ellipseMode(PApplet.CENTER); glos.fill(this.getSelectionMouseColor(), 100); glos.noStroke(); glos.ellipse(parent.mouseX, parent.mouseY, this.getSelectionDistance() * 2, this.getSelectionDistance() * 2); } else { glos.ellipseMode(PApplet.CENTER); glos.fill(255, 0, 0, 100); glos.noStroke(); glos.ellipse(parent.mouseX, parent.mouseY, this.getSnapDistance() * 2, this.getSnapDistance() * 2); } } if (selectionTool != null && !disableSelectionTool) { glos.stroke(255, 100); glos.strokeWeight(1); glos.fill(0, 200, 255, 50); glos.rect(selectionTool.x, selectionTool.y, selectionTool.width, selectionTool.height); glos.noStroke(); } glos.endDraw(); } else { parent.noCursor(); } }
Example 18
Source File: ImageUtil.java From haxademic with MIT License | 4 votes |
public static void drawTextureMappedRect(PGraphics dest, PImage texture, int subdivideX, int subdivideY, float topLeftX, float topLeftY, float topRightX, float topRightY, float bottomRightX, float bottomRightY, float bottomLeftX, float bottomLeftY) { // draw to screen with pinned corner coords // generalized version ported from PGraphicsKeystone // inspired by: https://github.com/davidbouchard/keystone & http://marcinignac.com/blog/projectedquads-source-code/ dest.textureMode(PConstants.IMAGE); dest.noStroke(); dest.fill(255); dest.beginShape(PConstants.QUAD); dest.texture(texture); if(subdivideX > 0) { // subdivide quad for better resolution float stepsX = subdivideX; float stepsY = subdivideY; for( float x=0; x < stepsX; x += 1f ) { // calculate spread of mesh grid and uv coordinates float xPercent = x/stepsX; float xPercentNext = (x+1f)/stepsX; if( xPercentNext > 1 ) xPercentNext = 1; float uPercent = xPercent; float uPercentNext = xPercentNext; for( float y=0; y < stepsY; y += 1f ) { // calculate spread of mesh grid and uv coordinates float yPercent = y/stepsY; float yPercentNext = (y+1f)/stepsY; if( yPercentNext > 1 ) yPercentNext = 1; float vPercent = yPercent; float vPercentNext = yPercentNext; // calc grid positions based on interpolating columns between corners float colTopX = interp(topLeftX, topRightX, xPercent); float colTopY = interp(topLeftY, topRightY, xPercent); float colBotX = interp(bottomLeftX, bottomRightX, xPercent); float colBotY = interp(bottomLeftY, bottomRightY, xPercent); float nextColTopX = interp(topLeftX, topRightX, xPercentNext); float nextColTopY = interp(topLeftY, topRightY, xPercentNext); float nextColBotX = interp(bottomLeftX, bottomRightX, xPercentNext); float nextColBotY = interp(bottomLeftY, bottomRightY, xPercentNext); // calc quad coords float quadTopLeftX = interp(colTopX, colBotX, yPercent); float quadTopLeftY = interp(colTopY, colBotY, yPercent); float quadTopRightX = interp(nextColTopX, nextColBotX, yPercent); float quadTopRightY = interp(nextColTopY, nextColBotY, yPercent); float quadBotRightX = interp(nextColTopX, nextColBotX, yPercentNext); float quadBotRightY = interp(nextColTopY, nextColBotY, yPercentNext); float quadBotLeftX = interp(colTopX, colBotX, yPercentNext); float quadBotLeftY = interp(colTopY, colBotY, yPercentNext); // draw subdivided quads dest.vertex(quadTopLeftX, quadTopLeftY, 0, texture.width * uPercent, texture.height * vPercent); dest.vertex(quadTopRightX, quadTopRightY, 0, texture.width * uPercentNext, texture.height * vPercent); dest.vertex(quadBotRightX, quadBotRightY, 0, texture.width * uPercentNext, texture.height * vPercentNext); dest.vertex(quadBotLeftX, quadBotLeftY, 0, texture.width * uPercent, texture.height * vPercentNext); } } } else { // default single mapped quad dest.vertex(topLeftX, topLeftY, 0, 0, 0); dest.vertex(topRightX, topRightY, 0, texture.width, 0); dest.vertex(bottomRightX, bottomRightY, 0, texture.width, texture.height); dest.vertex(bottomLeftX, bottomLeftY, 0, 0, texture.height); } dest.endShape(); }
Example 19
Source File: LeapRegion.java From haxademic with MIT License | 4 votes |
public void update(PGraphics debugGraphics) { // find kinect readings in the region _isActive = false; if( leapMotion != null ) { DebugView.setValue("leapMotion.getHands()", leapMotion.getHands().size()); for(Hand hand : leapMotion.getHands()){ PVector hand_position = hand.getPosition(); // PVector hand_stabilized = hand.getStabilizedPosition(); DebugView.setValue("hand "+hand.getId(), hand_position.toString()); // draw debug hand position if(debugGraphics != null) { debugGraphics.noStroke(); debugGraphics.fill(255); debugGraphics.pushMatrix(); debugGraphics.translate(hand_position.x, hand_position.y, -1f * hand_position.z); debugGraphics.box(40, 40, 40); debugGraphics.popMatrix(); } // set position if hand is in region if( hand_position.x > _left && hand_position.x < _right && hand_position.y > _top && hand_position.y < _bottom && hand_position.z > _near && hand_position.z < _far ) { _isActive = true; _controlX = (MathUtil.getPercentWithinRange(_left, _right, hand_position.x) - 0.5f) * 2f; _controlY = (MathUtil.getPercentWithinRange(_top, _bottom, hand_position.y) - 0.5f) * 2f; _controlZ = (MathUtil.getPercentWithinRange(_near, _far, hand_position.z) - 0.5f) * 2f; } } } // if none found, reset values if(_isActive == false) { _controlX = 0; _controlY = 0; _controlZ = 0; } }
Example 20
Source File: UITextInput.java From haxademic with MIT License | 4 votes |
public void draw( PGraphics pg ) { pg.pushMatrix(); PG.setDrawCorner(pg); // outline pg.noStroke(); pg.fill(ColorsHax.BUTTON_OUTLINE); pg.rect(rect.x, rect.y, rect.width, rect.height); // draw input background if( pressed == true || focused == true ) { pg.fill(ColorsHax.BUTTON_BG_PRESS); } else if( over == true ) { pg.fill(ColorsHax.BUTTON_BG_HOVER); } else { pg.fill(ColorsHax.BUTTON_BG); } pg.rect(rect.x+1, rect.y+1, rect.width-2, rect.height-2); // set font on context boolean isUIComponent = (rect.height == IUIControl.controlH); if(isUIComponent) { // lock to UI size if we're a UI component IUIControl.setFont(pg); pg.fill(ColorsHax.BUTTON_TEXT); } else { PFont font = FontCacher.getFont(fontFile, fontSize); FontCacher.setFontOnContext(pg, font, ColorsHax.BUTTON_TEXT, 1f, align, PTextAlign.CENTER); } // get text width for cursor and to "scroll" text String displayText = value; float textW = pg.textWidth(displayText); int maxTextW = rect.width - padX * 2; while(textW > maxTextW) { displayText = displayText.substring(1); // shift chars off the front of the text textW = pg.textWidth(displayText); } if(isUIComponent) { pg.text(displayText, rect.x + TEXT_INDENT, rect.y, rect.width, rect.height); } else { pg.text(displayText, rect.x + padX, rect.y - rect.height * 0.05f, rect.width, rect.height); } // draw blinking cursor cursorX = rect.x + padX + textW + cursorPadding; if(isUIComponent) cursorX -= 3; if(align == PTextAlign.CENTER) cursorX = rect.x + rect.width/2 + textW/2 + cursorPadding * 3f; if(focused == true) { pg.noStroke(); pg.fill(ColorsHax.BUTTON_TEXT); if( P.p.millis() % 1000f > 500 ) pg.rect( cursorX, rect.y + rect.height * 0.25f, 2f, fontSize ); } pg.popMatrix(); }