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

The following examples show how to use processing.core.PGraphics#ellipseMode() . 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: 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 2
Source File: MultiSimpleCalibrator.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void sin(PApplet parent, PGraphics g, int amt, float freq, int xDiff, float size) {
    float v = (PApplet.sin((float) (parent.millis()) / 1000f * PConstants.TWO_PI * freq) + 1f) / 2f;
    g.noStroke();
    g.ellipseMode(CENTER);
    g.fill(v * amt);
    g.ellipse(-xDiff, 0, size, size);
    g.ellipse(0, 0, size, size);
    g.ellipse(xDiff, 0, size, size);
}
 
Example 3
Source File: ConstellationClusterMarker.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean draw(final PGraphics graphics, final List<MapPosition> positions, final UnfoldingMap map) {
    if (positions.isEmpty() || isHidden()) {
        return false;
    }

    clusterCenter = new MapPosition();
    positions.forEach(position -> {
        clusterCenter.add(position);
    });
    clusterCenter.div(positions.size());

    double diameter = 0;
    if (positions.size() > 1) {
        final MapPosition minPosition = new MapPosition(
                new float[]{Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE});
        final MapPosition maxPosition = new MapPosition(
                new float[]{Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE});
        positions.forEach(position -> {
            minPosition.x = Math.min(position.x, minPosition.x);
            minPosition.y = Math.min(position.y, minPosition.y);
            maxPosition.x = Math.max(position.x, maxPosition.x);
            maxPosition.y = Math.max(position.y, maxPosition.y);
        });
        diameter = Math.sqrt(Math.pow((maxPosition.x - minPosition.x), 2)
                + Math.pow((maxPosition.y - minPosition.y), 2));
    }
    clusterRadius = Math.max((float) diameter / 2, MIN_RADIUS);

    graphics.strokeWeight(size == MarkerUtilities.DEFAULT_SIZE ? strokeWeight : size);
    graphics.stroke(strokeColor);
    graphics.fill(getFillColor());
    graphics.ellipseMode(PConstants.RADIUS);
    graphics.ellipse(clusterCenter.x, clusterCenter.y, clusterRadius, clusterRadius);

    final String clusterLabel = String.valueOf(clusterSize);
    graphics.fill(FONT_COLOR);
    graphics.textSize(FONT_SIZE);
    graphics.text(clusterLabel,
            clusterCenter.x - (CHAR_WIDTH * clusterLabel.length() * 0.6f),
            clusterCenter.y + (FONT_SIZE * 0.35f));

    return true;
}
 
Example 4
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 5
Source File: PG.java    From haxademic with MIT License 4 votes vote down vote up
public static void setDrawCorner( PGraphics p ) {
	p.imageMode( PConstants.CORNER );
	p.rectMode( PConstants.CORNER );
	p.ellipseMode( PConstants.CORNER );
	p.shapeMode( PConstants.CORNER );
}
 
Example 6
Source File: PG.java    From haxademic with MIT License 4 votes vote down vote up
public static void setDrawCenter( PGraphics p ) {
	p.imageMode( PConstants.CENTER );
	p.rectMode( PConstants.CENTER );
	p.ellipseMode( PConstants.CENTER );
	p.shapeMode( PConstants.CENTER );
}