|
-
Jun 24th, 2010, 07:48 PM
#1
Thread Starter
New Member
Piao Java 2D General Path
Hello guys, nice being appart of this forum, im new here and hope to get some help, im having some problem, im trying to draw in java 2d a object called... sorry but i dont no the name in english but the link of the image to you guys have an ideia is this:

Unfortanly im not the best in java, and to tell you guys the truth this is a assignment that i have to do, but unfortanly time isnt at my side :S, here is the code, hope you guys could give me a hand:
Im trying to make the shape, but no luke:
Code:
package br.com.pontov.piao;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
public class Ghost {
private Color color = Color.RED;
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
drawBody(g2d);
g2d.dispose();
}
public void setColor(Color color)
{
this.color = color;
}
public Color getColor()
{
return color;
}
private void drawBody(Graphics2D g2d) {
GeneralPath gp = new GeneralPath();
gp.moveTo(0, 35);
gp.lineTo(35, 100);
gp.quadTo(10, 100, 100,100);
gp.lineTo(80, 35);
gp.curveTo(70, -5, 8, -5, 0, 30);
Paint oldPaint = g2d.getPaint();
GradientPaint paint = new GradientPaint(
0, 40, color,
70, 40, color.darker());
g2d.setPaint(paint);
g2d.fill(gp);
g2d.setPaint(oldPaint);
}
}
Hope whit some help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|