public class Bubble { // bubble padding float bubblePadding = 20.0; // tab bits float bubbleTabX = 0.0; float bubbleTabY = 0.0; float tabEdgeWidth = 20.0; // bubble location info float bubbleCenterX = 0.0; float bubbleCenterY = 0.0; float bubbleWidth = 0.0; float bubbleHeight = 0.0; public Bubble(float _bubbleCenterX, float _bubbleCenterY, float _bubbleWidth, float _bubbleHeight, float _bubblePadding) { bubblePadding = _bubblePadding; bubbleCenterX = _bubbleCenterX; bubbleCenterY = _bubbleCenterY; bubbleWidth = _bubbleWidth + 2 * bubblePadding; bubbleHeight = _bubbleHeight + 2 * bubblePadding; } public void drawBubble() { float rightEdge = bubbleCenterX + bubbleWidth/2 + bubblePadding; float leftEdge = bubbleCenterX - bubbleWidth/2 - bubblePadding; float topEdge = bubbleCenterY - bubbleHeight/2 - bubblePadding; float bottomEdge = bubbleCenterY + bubbleHeight/2 + bubblePadding; /** * beginShape(POLYGON); * vertex(bubbleCenterX,topEdge); * bezierVertex(rightEdge,topEdge,rightEdge,topEdge,rightEdge,bubbleCenterY); * bezierVertex(rightEdge,bottomEdge,rightEdge,bottomEdge,bubbleCenterX,bottomEdge); * bezierVertex(leftEdge,bottomEdge,leftEdge,bottomEdge,leftEdge,bubbleCenterY); * bezierVertex(leftEdge,topEdge,leftEdge,topEdge,bubbleCenterX,topEdge); * endShape(); */ // assume on the bottom of the bubble // this is the bottom exit point for the tag float tagExitX_0 = bubbleCenterX + 10; float tagExitY_0 = bottomEdge; float tagExitX_1 = bubbleCenterX - 10; float tagExitY_1 = bottomEdge; float tagVertexX = bubbleCenterX+20;//mouseX; float tagVertexY = bottomEdge+30; beginShape(POLYGON); vertex(bubbleCenterX,topEdge); bezierVertex(rightEdge,topEdge,rightEdge,topEdge,rightEdge,bubbleCenterY); bezierVertex(rightEdge,bottomEdge,rightEdge,bottomEdge,tagExitX_0,tagExitY_0); /** * vertex(rightEdge,topEdge); * vertex(rightEdge,bottomEdge); * vertex(tagExitX_0,tagExitY_0); **/ curveVertex(tagExitX_0,tagExitY_0); curveVertex(tagExitX_0,tagExitY_0); curveVertex(tagVertexX,tagVertexY); curveVertex(tagExitX_1,tagExitY_1); curveVertex(tagExitX_1,tagExitY_1); /** * vertex(tagExitX_1,tagExitY_1); * vertex(leftEdge,bottomEdge); * vertex(leftEdge,topEdge); * vertex(bubbleCenterX,topEdge); **/ bezierVertex(leftEdge,bottomEdge,leftEdge,bottomEdge,leftEdge,bubbleCenterY); bezierVertex(leftEdge,topEdge,leftEdge,topEdge,bubbleCenterX,topEdge); endShape(); // draw a word fill(0); // textAlign(CENTER); // text(out, bubbleCenterX, topEdge+fontsize+boxPadLR); //popMatrix(); } }