Java Code Examples for processing.core.PGraphics#fill()
The following examples show how to use
processing.core.PGraphics#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: TiledTexture.java From haxademic with MIT License | 6 votes |
public void drawDebug(PGraphics pg) { // fit to small box // draw background pg.stroke(0); pg.fill(0); pg.rect(0, 0, texture.width, texture.height); // draw image pg.image(texture, 0, 0, texture.width, texture.height); // show texture grab area // float halfSizeX = (sizeX * (float) texture.width) / 2f; // float halfSizeY = (sizeY * (float) texture.height) / 2f; pg.stroke(255, 0, 0, 200); pg.noFill(); pg.beginShape(); pg.vertex(tlX, tlY); pg.vertex(trX, trY); pg.vertex(brX, brY); pg.vertex(blX, blY); pg.vertex(tlX, tlY); pg.endShape(); }
Example 2
Source File: UIButton.java From haxademic with MIT License | 6 votes |
public void draw(PGraphics pg) { PG.setDrawCorner(pg); // outline pg.noStroke(); if(over || pressed) pg.fill(ColorsHax.BUTTON_OUTLINE_HOVER); else pg.fill(ColorsHax.BUTTON_OUTLINE); pg.rect(rect.x, rect.y, rect.width, rect.height); // background if(over && value == 0 && !pressed) pg.fill(ColorsHax.BUTTON_BG_HOVER); else if(pressed) pg.fill(ColorsHax.BUTTON_BG_PRESS); else if(toggles && value == 1) pg.fill(ColorsHax.WHITE); else pg.fill(ColorsHax.BUTTON_BG); pg.rect(rect.x+1, rect.y+1, rect.width-2, rect.height-2); // text label IUIControl.setFont(pg); if(toggles && value == 1) pg.fill(ColorsHax.BLACK); else pg.fill(ColorsHax.BUTTON_TEXT); pg.text(label, rect.x + TEXT_INDENT, rect.y, rect.width, rect.height); // set active if drawing activeTime = P.p.millis(); }
Example 3
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 4
Source File: DebugView.java From haxademic with MIT License | 5 votes |
protected void drawHighlightedValue() { if(highlightedText != null) { PGraphics pg = P.p.g; // draw bg rect int fill = P.p.color(0, 100, 0); PG.drawStrokedRect(pg, pg.width, controlH, 1, fill, ColorsHax.BUTTON_OUTLINE); // text label pg.fill(ColorsHax.BUTTON_TEXT); pg.text(highlightedText, IUIControl.TEXT_INDENT, 1f); // , IUIControl.controlW, controlH } }
Example 5
Source File: Demo_SpatialLighting.java From haxademic with MIT License | 5 votes |
protected void drawLight(PGraphics pg) { PG.push(pg); pg.fill(color.colorInt()); pg.translate(position.x * roomW, position.y * roomH, position.z * roomD); pg.sphere(20); // draw debug channel text pg.translate(25, 0, 0); pg.fill(0, 255, 0); pg.text(name, 0, 0); // pop PG.pop(pg); }
Example 6
Source File: IDepthCamera.java From haxademic with MIT License | 5 votes |
public static void drawPointCloudForRect(PGraphics pg, IDepthCamera camera, boolean mirrored, int pixelSkip, float alpha, float scale, float depthClose, float depthFar, int top, int right, int bottom, int left ) { pg.pushMatrix(); // Translate and rotate int curZ; // Scale up by 200 float scaleFactor = scale; pg.noStroke(); for (int x = left; x < right; x += pixelSkip) { for (int y = top; y < bottom; y += pixelSkip) { curZ = camera.getDepthAt(x, y); // draw a point within the specified depth range if( curZ > depthClose && curZ < depthFar ) { pg.fill( 255, alpha * 255f ); } else { pg.fill( 255, 0, 0, alpha * 255f ); } pg.pushMatrix(); pg.translate( x * scaleFactor, y * scaleFactor, scaleFactor * curZ/40f ); // Draw a point pg.point(0, 0); pg.rect(0, 0, 4, 4); pg.popMatrix(); } } pg.popMatrix(); }
Example 7
Source File: Fluid.java From haxademic with MIT License | 5 votes |
public void renderD(PGraphics pg) { for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { float x = i * scale; float y = j * scale; pg.noStroke(); pg.fill(density[index(i, j)]); pg.rect(x, y, scale, scale); } } }
Example 8
Source File: ImageGradient.java From haxademic with MIT License | 5 votes |
public void drawDebug(PGraphics pg) { pg.image(gradientImg, 0, 0); pg.stroke(255, 0, 0); pg.noFill(); pg.rect(sampleX - 1, 0, 3, gradientImg.height); pg.fill(255); pg.noStroke(); }
Example 9
Source File: DwFoldingTile.java From PixelFlow with MIT License | 5 votes |
public void displayMesh(PGraphics pg, DwParticle3D[] particles){ // 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; DwParticle3D v0,v1,v2; for(int i = 0; i < DEF.FACES_COUNT; i++){ i0 = faces[i][0]; v0 = particles[i0]; if(v0.all_springs_deactivated) continue; i1 = faces[i][1]; v1 = particles[i1]; if(v1.all_springs_deactivated) continue; i2 = faces[i][2]; v2 = particles[i2]; if(v2.all_springs_deactivated) continue; 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 10
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 11
Source File: SlideTitle.java From haxademic with MIT License | 5 votes |
public void update(PGraphics pg) { showProgress.update(); if(titleQueued != null && showProgress.value() == 0) { title = titleQueued; titleQueued = null; showProgress.setTarget(1); } if(title != null) { PG.setDrawCorner(pg); pg.noStroke(); // get eased y float easedProgress = Penner.easeInOutCubic(showProgress.value()); pg.pushMatrix(); // draw bg pg.fill(0, opacity * easedProgress); pg.rect(0, 0, pg.width, pg.height); // draw text // buffer.textLeading(font.getSize() * 0.75f); pg.fill(255, 255 * easedProgress); pg.textAlign(P.CENTER, P.CENTER); pg.textFont(font); pg.text(title, 0, 0, pg.width, pg.height); pg.popMatrix(); PG.setDrawCenter(pg); } }
Example 12
Source File: LeapRegion.java From haxademic with MIT License | 5 votes |
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 13
Source File: Rectangle.java From haxademic with MIT License | 4 votes |
public void draw(PGraphics pg) { pg.stroke(255); pg.noFill(); if(collided) pg.fill(0, 255, 0, 50); pg.rect(x, y, width, height); }
Example 14
Source File: KinectRegion.java From haxademic with MIT License | 4 votes |
public void update(PGraphics debugGraphics) { IDepthCamera depthCamera = DepthCamera.instance().camera; float depthDivider = 0.3f; if(debugGraphics != null) { debugGraphics.beginShape(PShapeTypes.QUADS); debugGraphics.stroke(debugColor); debugGraphics.fill( 255, pixelCount / minPixels * 10f ); debugGraphics.vertex(left, bottom, -near * depthDivider); debugGraphics.vertex(right, bottom, -near * depthDivider); debugGraphics.vertex(right, bottom, -far * depthDivider); debugGraphics.vertex(left, bottom, -far * depthDivider); debugGraphics.endShape(); debugGraphics.noStroke(); } // find kinect readings in the region _isActive = false; if( depthCamera != null ) { pixelCount = 0; float controlXTotal = 0; float controlZTotal = 0; float pixelDepth = 0; for ( int x = left; x < right; x += pixelSkip ) { for ( int y = top; y < bottom; y += pixelSkip ) { pixelDepth = depthCamera.getDepthAt( x, y ); if( pixelDepth != 0 && pixelDepth > near && pixelDepth < far ) { if(debugGraphics != null) { debugGraphics.fill( debugColor, 127 ); debugGraphics.pushMatrix(); debugGraphics.translate(x, y, -pixelDepth * depthDivider); debugGraphics.box(pixelSkip, pixelSkip, pixelSkip); debugGraphics.popMatrix(); } // add up for calculations pixelCount++; controlXTotal += x; controlZTotal += pixelDepth; } } } // if we have enough blocks in a region, update the player's joystick position if( pixelCount > minPixels ) { _isActive = true; // compute averages if( controlXTotal > 0 && controlZTotal > 0 ) { float avgX = controlXTotal / pixelCount; _controlX = (MathUtil.getPercentWithinRange(left, right, avgX) - 0.5f) * 2f; float avgZ = controlZTotal / pixelCount; _controlZ = (MathUtil.getPercentWithinRange(near, far, avgZ) - 0.5f) * 2f; // show debug if(debugGraphics != null) { debugGraphics.fill( 255, 127 ); debugGraphics.pushMatrix(); debugGraphics.translate(avgX, bottom - 250, -avgZ * depthDivider); debugGraphics.box(20, 500, 20); debugGraphics.popMatrix(); } } } } }
Example 15
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 16
Source File: Polygon.java From haxademic with MIT License | 4 votes |
protected void drawCentroid(PGraphics pg) { pg.fill(0, 255, 0); pg.noStroke(); pg.circle(center.x, center.y, 4); }
Example 17
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(); }
Example 18
Source File: MappedTriangle.java From haxademic with MIT License | 4 votes |
public void draw( PGraphics pg ) { if( _texture != null ) { updateVertices(); if( _mappingStyle == MAP_STYLE_CONTAIN_TEXTURE ) { pg.beginShape(PConstants.TRIANGLE); pg.texture(_texture); if( _mappingOrientation == 0 ) { setUVCoordinates(0, 0, _texture.width, _texture.height/2, 0, _texture.height); } else if( _mappingOrientation == 1 ) { setUVCoordinates(0, 0, _texture.width, 0, _texture.width/2, _texture.height); } else if( _mappingOrientation == 2 ) { setUVCoordinates(0, _texture.height/2, _texture.width, 0, _texture.width, _texture.height); } else if( _mappingOrientation == 3 ) { setUVCoordinates(0, _texture.height, _texture.width/2, 0, _texture.width, _texture.height); } pg.vertex(_x1.value(), _y1.value(), getZ(x1, y1), _UVx1.value(), _UVy1.value()); pg.vertex(_x2.value(), _y2.value(), getZ(x2, y2), _UVx2.value(), _UVy2.value()); pg.vertex(_x3.value(), _y3.value(), getZ(x3, y3), _UVx3.value(), _UVy3.value()); pg.endShape(); } else if( _mappingStyle == MAP_STYLE_MASK ) { pg.beginShape(PConstants.TRIANGLE); pg.texture(_texture); // map the screen coordinates to the texture coordinates // crop to fill the mapped area with the current texture setUVCoordinates(_maskTriangle[0].x, _maskTriangle[0].y, _maskTriangle[1].x, _maskTriangle[1].y, _maskTriangle[2].x, _maskTriangle[2].y); pg.vertex(_x1.value(), _y1.value(), getZ(x1, y1), _UVx1.value(), _UVy1.value()); pg.vertex(_x2.value(), _y2.value(), getZ(x2, y2), _UVx2.value(), _UVy2.value()); pg.vertex(_x3.value(), _y3.value(), getZ(x3, y3), _UVx3.value(), _UVy3.value()); pg.endShape(); } else if( _mappingStyle == MAP_STYLE_CONTAIN_RANDOM_TEX_AREA ) { pg.beginShape(PConstants.TRIANGLE); pg.texture(_texture); // map the polygon coordinates to the random sampling coordinates setUVCoordinates(_randTriangle[0].x, _randTriangle[0].y, _randTriangle[1].x, _randTriangle[1].y, _randTriangle[2].x, _randTriangle[2].y); pg.vertex(_x1.value(), _y1.value(), getZ(x1, y1), _UVx1.value(), _UVy1.value()); pg.vertex(_x2.value(), _y2.value(), getZ(x2, y2), _UVx2.value(), _UVy2.value()); pg.vertex(_x3.value(), _y3.value(), getZ(x3, y3), _UVx3.value(), _UVy3.value()); pg.endShape(); } else if( _mappingStyle == MAP_STYLE_EQ ) { _curColor = P.p.lerpColor(_curColor, _color, 0.1f); pg.beginShape(PConstants.TRIANGLE); pg.fill(pg.color(_curColor, P.constrain( AudioIn.audioFreq(_eqIndex) * 255, 0, 255 ))); pg.vertex(_x1.value(), _y1.value(), getZ(x1, y1)); pg.vertex(_x2.value(), _y2.value(), getZ(x2, y2)); pg.fill(pg.color(_curColor, P.constrain( AudioIn.audioFreq(_eqIndex) * 100, 0, 190 ))); pg.vertex(_x3.value(), _y3.value(), getZ(x3, y3)); 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.TRIANGLE); pg.fill(255*whiteFade,fakeLightAlpha); pg.vertex(_x1.value(), _y1.value(), getZ(x1, y1)); pg.fill(255*whiteFade,0); pg.vertex(_x2.value(), _y2.value(), getZ(x2, y2)); pg.vertex(_x3.value(), _y3.value(), getZ(x3, y3)); pg.endShape(); // // show debug info // pg.fill(255); // pg.textSize(20); // pg.text(_mappingStyle+"", _centerX, _centerY); } }
Example 19
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 20
Source File: ConstellationClusterMarker.java From constellation with Apache License 2.0 | 4 votes |
@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; }