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

The following examples show how to use processing.core.PGraphics#strokeWeight() . 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: Fluid.java    From haxademic with MIT License 6 votes vote down vote up
public void renderV(PGraphics pg) {
	for (int j = 0; j < height; j++) {
		for (int i = 0; i < width; i++) {
			float x = i * scale;
			float y = j * scale;
			int indx = index(i, j);
			pg.stroke(255);
			pg.strokeWeight(1);
			float vxX = vx[indx];
			float vyY = vy[indx];
			if (vxX + vyY > 0.05) {
				pg.line(x, y, x + scale * vxX, y + scale * vyY);
			}
		}
	}
}
 
Example 3
Source File: BaseMappedPolygon.java    From haxademic with MIT License 6 votes vote down vote up
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 4
Source File: QuadSurface.java    From sketch-mapper with MIT License 6 votes vote down vote up
/**
 * Draws the Cornerpoints
 *
 * @param g
 * @param x
 * @param y
 * @param selected
 * @param cornerIndex
 */
private void renderCornerPoint(PGraphics g, float x, float y, boolean selected, int cornerIndex) {
    g.noFill();
    g.strokeWeight(2);
    if (selected) {
        g.stroke(QuadSurface.SELECTED_CORNER_MARKER_COLOR);
    } else {
        g.stroke(QuadSurface.CORNER_MARKER_COLOR);
    }
    if (cornerIndex == getSelectedCorner() && isSelected()) {
        g.fill(QuadSurface.SELECTED_CORNER_MARKER_COLOR, 100);
        g.stroke(QuadSurface.SELECTED_CORNER_MARKER_COLOR);
    }
    g.ellipse(x, y, 10, 10);
    g.line(x, y - 5, x, y + 5);
    g.line(x - 5, y, x + 5, y);
}
 
Example 5
Source File: BezierSurface.java    From sketch-mapper with MIT License 6 votes vote down vote up
/**
 * Draws the bezier points
 *
 * @param g
 * @param x
 * @param y
 * @param selected
 * @param cornerIndex
 */
private void renderBezierPoint(PGraphics g, float x, float y, boolean selected, int cornerIndex) {
    g.noFill();
    g.strokeWeight(1);
    if (selected) {
        g.stroke(BezierSurface.SELECTED_CORNER_MARKER_COLOR);
    } else {
        g.stroke(BezierSurface.CORNER_MARKER_COLOR);
    }
    if (cornerIndex == getSelectedBezierControl() && isSelected()) {
        g.fill(BezierSurface.SELECTED_CORNER_MARKER_COLOR, 100);
        g.stroke(BezierSurface.SELECTED_CORNER_MARKER_COLOR);
    }
    g.ellipse(x, y, 10, 10);
    g.line(x, y - 5, x, y + 5);
    g.line(x - 5, y, x + 5, y);
}
 
Example 6
Source File: BezierSurface.java    From sketch-mapper with MIT License 6 votes vote down vote up
/**
 * Draws the Corner points
 *
 * @param g
 * @param x
 * @param y
 * @param selected
 * @param cornerIndex
 */
private void renderCornerPoint(PGraphics g, float x, float y, boolean selected, int cornerIndex) {
    g.noFill();
    g.strokeWeight(2);
    if (selected) {
        g.stroke(BezierSurface.SELECTED_CORNER_MARKER_COLOR);
    } else {
        g.stroke(BezierSurface.CORNER_MARKER_COLOR);
    }
    if (cornerIndex == getSelectedCorner() && isSelected()) {
        g.fill(BezierSurface.SELECTED_CORNER_MARKER_COLOR, 100);
        g.stroke(BezierSurface.SELECTED_CORNER_MARKER_COLOR);
    }
    g.ellipse(x, y, 10, 10);
    g.line(x, y - 5, x, y + 5);
    g.line(x - 5, y, x + 5, y);
}
 
Example 7
Source File: SavedPointUI.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawPoint(PGraphics pg) {
	PG.setDrawCenter(pg);
	pg.noFill();
	if(active) {
		pg.stroke(0, 255, 0);
	} else {
		pg.stroke(255);
	}
	pg.strokeWeight((active) ? 3 : 1.5f);
	float indicatorSize = 20f + 3f * P.sin(P.p.frameCount / 10f);
	pg.ellipse(position.x, position.y, indicatorSize, indicatorSize);
	pg.strokeWeight(1f);
	pg.rect(position.x, position.y, 3, 3);
	PG.setDrawCorner(pg);
}
 
Example 8
Source File: ConstellationPointMarker.java    From constellation with Apache License 2.0 5 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;
    }

    final float x = positions.get(0).x;
    final float y = positions.get(0).y;

    graphics.pushStyle();

    if (size > MarkerUtilities.DEFAULT_SIZE) {
        graphics.strokeWeight(strokeWeight);
        graphics.stroke(strokeColor);
        graphics.fill(getFillColor());
        graphics.ellipseMode(PConstants.RADIUS);
        graphics.ellipse(x, y, size, size);
    } else {
        TEMPLATE_IMAGE.loadPixels();
        for (int i = 0; i < TEMPLATE_IMAGE.width * TEMPLATE_IMAGE.height; i++) {
            final int[] pixelArgb = MarkerUtilities.argb(TEMPLATE_IMAGE.pixels[i]);
            if (!(pixelArgb[0] == 0 || (pixelArgb[1] == 0 && pixelArgb[2] == 0 && pixelArgb[3] == 0))) {
                TEMPLATE_IMAGE.pixels[i] = getFillColor();
            }
        }
        TEMPLATE_IMAGE.updatePixels();

        graphics.imageMode(PConstants.CORNER);
        graphics.image(TEMPLATE_IMAGE, x - POINT_X_OFFSET, y - POINT_Y_OFFSET);
    }

    graphics.popStyle();

    return true;
}
 
Example 9
Source File: BaseSavedQuadUI.java    From haxademic with MIT License 5 votes vote down vote up
protected void showMappedRect(PGraphics pg) {
	pg.noFill();
	pg.stroke(0, 255, 0);
	pg.strokeWeight(1);
	pg.line(topLeft.x, topLeft.y, topRight.x, topRight.y);
	pg.line(topRight.x, topRight.y, bottomRight.x, bottomRight.y);
	pg.line(bottomRight.x, bottomRight.y, bottomLeft.x, bottomLeft.y);
	pg.line(bottomLeft.x, bottomLeft.y, topLeft.x, topLeft.y);
	pg.ellipse(center.x - 4, center.y - 4, 8, 8);
}
 
Example 10
Source File: BaseSavedQuadUI.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawPoint(PGraphics pg, Point point) {
	PG.setDrawCenter(pg);
	pg.fill(255, 75);
	pg.stroke(0, 255, 0);
	pg.strokeWeight(2);
	float indicatorSize = 20f + 3f * P.sin(P.p.frameCount / 10f);
	pg.ellipse(point.x, point.y, indicatorSize, indicatorSize);
	PG.setDrawCorner(pg);
}
 
Example 11
Source File: BFLinewaveRender.java    From haxademic with MIT License 5 votes vote down vote up
public void update(PGraphics pg, float frameOsc) {
	_x.update();
	_y.update();
	
	
	pg.noFill();
	pg.stroke(0);
	pg.strokeWeight(HEIGHT);
	p.strokeCap(P.SQUARE);

	float third = 1f/3f;
	float twoThird = 2f/3f;
	float sixth = 1f/6f;
	float curveAdd = 1.25f;
	curveAdd = curveAdd/2f + frameOsc * curveAdd/2f;
	
	pg.beginShape();
	pg.vertex(_x.value(), _y.value());
	pg.bezierVertex(
			_x.value() + WIDTH * sixth, _y.value(), 
			_x.value() + WIDTH * sixth, _y.value() + _index * curveAdd, 
			_x.value() + WIDTH * third, _y.value() + _index * curveAdd
			);
	pg.bezierVertex(
			_x.value() + WIDTH * (third + sixth), _y.value() + _index * curveAdd, 
			_x.value() + WIDTH * (third + sixth), _y.value(), 
			_x.value() + WIDTH * twoThird, _y.value()
			);
	pg.bezierVertex(
			_x.value() + WIDTH * (twoThird + sixth), _y.value(),
			_x.value() + WIDTH * (twoThird + sixth), _y.value() + _index * curveAdd, 
			_x.value() + WIDTH, _y.value() + _index * curveAdd
			);
	pg.endShape();
}
 
Example 12
Source File: MoireProposal.java    From haxademic with MIT License 5 votes vote down vote up
public void drawPointOnFloor(PGraphics tex) {
	float circleSize = tex.width * 0.1f * (1f + 0.2f * P.sin(8f * FrameLoop.progressRads()));
	tex.beginDraw();
	PG.setDrawCenter(p);
	tex.fill(255);
	tex.stroke(0);
	tex.strokeWeight(7);
	tex.ellipse(tex.width / 2, tex.height * 0.785f, circleSize, circleSize);
	tex.endDraw();
	PG.setDrawCorner(p);
}
 
Example 13
Source File: LeapRegion.java    From haxademic with MIT License 5 votes vote down vote up
public void drawDebug(PGraphics debugGraphics) {
	if( _blockColor == -1 ) return;
	
	// set box color for (in)active states
	debugGraphics.strokeWeight(5f);
	if(_isActive == true) {
		debugGraphics.stroke(_blockColor, 255);
		debugGraphics.noFill();
	} else {
		debugGraphics.stroke(255, 127);
		debugGraphics.noFill();
	}
	debugGraphics.pushMatrix();
	
	// move to center of box location & draw box
	debugGraphics.translate(P.lerp(_right, _left, 0.5f), P.lerp(_top, _bottom, 0.5f), -1f * P.lerp(_far, _near, 0.5f));
	debugGraphics.box(_right - _left, _top - _bottom, _far - _near);
	
	// draw text control values
	if(_isActive == true) {
		debugGraphics.noStroke();
		debugGraphics.fill(255);
		debugGraphics.textSize(24);
		debugGraphics.text(MathUtil.roundToPrecision(_controlX, 2)+", "+MathUtil.roundToPrecision(_controlY, 2)+", "+MathUtil.roundToPrecision(_controlZ, 2), -50, 0);
	}
	
	debugGraphics.popMatrix();
}
 
Example 14
Source File: DwFoldingTile.java    From PixelFlow with MIT License 5 votes vote down vote up
public void displayWireframe(PGraphics pg, DwIndexedFaceSet ifs){
  pg.strokeWeight(DEF.style.stroke_w);
  pg.stroke(DEF.style.stroke_r, DEF.style.stroke_g, DEF.style.stroke_b);
  int[] vid = updateVIDX();
  for(int i = 0; i < DEF.EDGES_COUNT; i++){
    int[] edge = DEF.EDGES[i];
    int i0 = vid[edge[0]];
    int i1 = vid[edge[1]];
    float[] v0 = ifs.verts[i0]; 
    float[] v1 = ifs.verts[i1];
    DwDisplayUtils.line(pg, v0, v1);
  }
}
 
Example 15
Source File: DwFoldingTile.java    From PixelFlow with MIT License 5 votes vote down vote up
public void displayWireframe(PGraphics pg, DwParticle3D[] particles){
  pg.strokeWeight(DEF.style.stroke_w);
  pg.stroke(DEF.style.stroke_r, DEF.style.stroke_g, DEF.style.stroke_b);
  int[] vid = updateVIDX();
  for(int i = 0; i < DEF.EDGES_COUNT; i++){
    int[] edge = DEF.EDGES[i];
    int i0 = vid[edge[0]];
    int i1 = vid[edge[1]];
    DwParticle3D v0 = particles[i0]; 
    DwParticle3D v1 = particles[i1];
    if(v0.all_springs_deactivated || v1.all_springs_deactivated) continue;
    DwDisplayUtils.line(pg, v0, v1);
  }
}
 
Example 16
Source File: DwMagnifier.java    From PixelFlow with MIT License 5 votes vote down vote up
public void display(PGraphics pg_canvas, int x, int y){
  setDisplayPosition(x, y);
  pg_canvas.image(pg_region, x, y, w, h);
  pg_canvas.rectMode(PConstants.CORNER);
  pg_canvas.stroke(128);
  pg_canvas.strokeWeight(1);
  pg_canvas.noFill();
  pg_canvas.rect(x, y, w, h);
}
 
Example 17
Source File: PG.java    From haxademic with MIT License 5 votes vote down vote up
public static void resetGlobalProps(PGraphics pg) {
	// p.resetMatrix();
	pg.colorMode( P.RGB, 255, 255, 255, 255 );
	pg.fill( 0, 255, 0, 255 );
	pg.stroke( 0, 255, 0, 255 );
	pg.strokeWeight( 1 );
	pg.camera();
	setDrawCenter(pg);
}
 
Example 18
Source File: SurfaceMapper.java    From sketch-mapper with MIT License 4 votes vote down vote up
/**
 * 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 19
Source File: MeshLineSegment.java    From haxademic with MIT License 4 votes vote down vote up
public void update( PGraphics pg, MODE mode, int color, float ampTotal, float amp ) {
//		if( mode == MODE.MODE_EQ_TOTAL ) {
//			pg.strokeWeight( P.constrain( ampTotal * .5f, 0, 1 ) );
//			pg.stroke(color);
//			pg.line( _point1.x, _point1.y, _point2.x, _point2.y );
//		} else 
		if( mode == MODE.MODE_EQ_BARS_BLACK ) {
			pg.strokeWeight( P.constrain( ampTotal * 1.0f, 1, 3 ) );
			pg.stroke(0);
			pg.line( _point1.x, _point1.y, _point2.x, _point2.y );
		} else if( mode == MODE.MODE_DOTS ) {
			pg.noStroke();
			pg.fill(color, P.constrain(amp * 10, 0, 255));
			float ampNormalized = P.constrain( amp * 2.f, 0, 4 );
			pg.ellipse( _point1.x, _point1.y, ampNormalized, ampNormalized );
		} 
//		else if( mode == MODE.MODE_WAVEFORMS ) {
//			PG.setDrawCorner(pg);
//			
//			amp = 5;
//			
//			if(waveformShapeFrameDrew != P.p.frameCount) {
//				for (int i = 0; i < waveformShape.getVertexCount()-2; i+=2) {
//					waveformShape.setVertex( i, waveformShape.getVertexX(i), P.p._waveformData._waveform[i] * amp );
//				}
//				waveformShapeFrameDrew = P.p.frameCount;
//			}
//						
//			waveformShape.disableStyle();
//			pg.noFill();
//			pg.stroke(color);
//			pg.strokeWeight(1);
//			pg.pushMatrix();
//			pg.translate( _point2.x, _point2.y );
//			pg.rotate(_radians);
//			pg.shape(waveformShape, 0, 0, _length, waveformShape.height);
//			
////			pg.translate( (_point1.x + _point2.x)/2f, (_point1.y + _point2.y)/2f );
////			for (int i = 1; i < waveformData._waveform.length; i++ ) {			
////				pg.line( 
////						startX + (i-1) * _spacing,
////						waveformData._waveform[(i-1)] * amp,
////						startX + i * _spacing,
////						waveformData._waveform[i] * amp 
////				);
////			}
//			pg.popMatrix();
//		} 
//		else if( mode == MODE.MODE_EQ_BARS ) {
//			pg.strokeWeight( P.constrain( amp * 0.3f, 0, 1 ) );
//			pg.stroke(color);
//			pg.line( _point1.x, _point1.y, _point2.x, _point2.y );
//		} 
		else if( mode == MODE.MODE_LINE_EXTEND ) {
			pg.strokeWeight( 1f );
			pg.stroke(color, 147);

			_utilVec.set( _point2 );
			_utilVec.lerp( _point1, P.constrain(amp/10f, 0f, 1f) );
			pg.line( _utilVec.x, _utilVec.y, _point2.x, _point2.y );

			_utilVec.set( _point1 );
			_utilVec.lerp( _point2, P.constrain(amp/10f, 0f, 1f) );
			pg.line( _utilVec.x, _utilVec.y, _point1.x, _point1.y );
		} else if( mode == MODE.MODE_NONE ) {
			// do nothing
		} else if( mode == MODE.MODE_PARTICLES ) {
			// do nothing
		} else if( mode == MODE.MODE_PERLIN) {
			float noise = P.p.noise(
					_point1.x/5f + P.p.noise(P.p.frameCount/100f), 
					_point1.y/10f + P.p.noise(P.p.frameCount/50f) 
			);
			pg.strokeWeight( 1f );
			pg.stroke(color, noise * 255f);
			pg.line( _point1.x, _point1.y, _point2.x, _point2.y );
//		} else if( mode == MODE.MODE_PROGRESS_BAR ) {
//			_progress += _progressDir * ( amp/100f );
//			if(_progressDir == 1 && _progress > 1) {
//				_progressDir = -1;
//				_progress = 1;
//			} else if(_progressDir == -1 && _progress < 0) {
//				_progressDir = 1;
//				_progress = 0;
//			} 
//			_utilLastVec.set(_utilVec);
//			
////			pg.noStroke();
////			pg.fill(color);
//			pg.noFill();
//			pg.stroke(color, 210);
//			pg.strokeWeight(1.3f);
//			_utilVec.set( _point2 );
//			_utilVec.lerp( _point1, _progress );
//			// pg.ellipse( _utilVec.x, _utilVec.y, 2, 2 );
//			pg.line( _utilVec.x, _utilVec.y, _utilLastVec.x, _utilLastVec.y );
//
		}
	}
 
Example 20
Source File: LightBar.java    From haxademic with MIT License 4 votes vote down vote up
public void update(PGraphics pg, int index) {
	// update midpoint
	midPoint.set(point1);
	midPoint.lerp(point2, 0.5f);
	
	// draw
	if(active) {
		// draw enclosing circle to highlight tube
		float highlightSize = point1.dist(point2) + 50;
		pg.noFill();
		pg.strokeWeight(1);
		pg.stroke(0, 255, 0);
		pg.ellipse(midPoint.x, midPoint.y, highlightSize, highlightSize);
		
		// flash color
		int rainbow = P.p.color(
				127 + 127 * P.sin(P.p.frameCount * 0.1f),
				127 + 127 * P.sin(P.p.frameCount * 0.15f),
				127 + 127 * P.sin(P.p.frameCount * 0.225f));
		dmxFixture.color().setCurrentInt((P.p.frameCount % 16 < 8) ? rainbow : P.p.color(0));
		// dmxFixture.color().setCurrentInt(0xffff0000);
	}
	
	// draw light
	pg.noStroke();
	pg.fill(dmxFixture.color().colorInt());
	pg.push();
	pg.translate(midPoint.x, midPoint.y);
	pg.rotate(MathUtil.getRadiansToTarget(point2.x, point2.y, point1.x, point1.y));
	pg.rect(0, 0, point1.dist(point2), 5);
	pg.pop();
	
	// small circular ends
	pg.ellipse(point1.x, point1.y, 3, 3);
	pg.ellipse(point2.x, point2.y, 3, 3);
	
	// show text labels overlay
	if(P.store.getBoolean(DMXEditor.SHOW_DMX_CHANNELS)) {
		drawNumberValue(pg, dmxChannel);
	}
	if(P.store.getBoolean(DMXEditor.SHOW_LIGHT_INDEX)) {
		drawNumberValue(pg, index);
	}
}