Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void corazon(int x, int y, int size, Color color, boolean relleno, boolean flecha, Graphics g){
- Graphics2D g2D = (Graphics2D) g;
- int d = size/2;
- int r = d/2;
- int h = x+r;
- int k = y+r;
- double m = 4.0/3;
- double x1 = ( (h+r)*m*m - 3.0*r*m + h) / (m*m+1);
- double y1 = (int)(m*(x1-h-r)+k+3*r);
- double x2 = (int)(x+2*r+(h-x1+r));
- double y2 = y1;
- double x3 = (int)(h+r);
- double y3 = (int)(k+3.0*r);
- int ang = (int)Math.toDegrees(Math.atan(1/m))+180;
- //(puntoIzq, puntoDer, puntoV)
- int[] xP = {(int)x1, (int)x2, (int)x3};
- int[] yP = {(int)y1, (int)y2, (int)y3};
- if( relleno ){
- g.setColor(color);
- g.fillRect(h, k, d, r);
- g.fillPolygon(xP, yP, xP.length);
- if( flecha ){
- g2D.setStroke( new BasicStroke( 6 ) );
- g.setColor(Color.black);
- g.drawLine(x, y+2*d, x+2*d+26, y-26);
- int xF[] = {x+2*d+26+15, x+2*d+26-10, x+2*d+26+10};
- int yF[] = {y-26-15, y-26-10, y-26+10};
- g.fillPolygon(xF, yF, xF.length);
- g.setColor(color);
- }
- g.fillOval(x, y, d, d);
- g.fillOval(x+d, y, d, d);
- }
- g2D.setStroke( new BasicStroke( 2 ) );
- g.setColor(Color.black);
- g.drawArc(x, y, d, d, 0, ang);
- g.drawArc(x+d, y, d, d, 3*180-ang, ang);
- //La V
- g.drawLine((int)x3, (int)y3, (int)x1, (int)y1);
- g.drawLine((int)x3, (int)y3, (int)x2, (int)y2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement