Skip to content

Commit 0653fd6

Browse files
committed
Added Oval
1 parent e4288e3 commit 0653fd6

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

  • src/org/teachingextensions/logo/shapes
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.teachingextensions.logo.shapes;
2+
3+
import java.awt.Color;
4+
import java.awt.Graphics2D;
5+
6+
import javax.swing.JPanel;
7+
8+
import org.teachingextensions.logo.Colors;
9+
import org.teachingextensions.logo.Paintable;
10+
import org.teachingextensions.windows.ProgramWindow;
11+
12+
public class Oval implements Paintable
13+
{
14+
private final int radius;
15+
private final Color mainColor;
16+
private int x;
17+
private int y;
18+
private int percentTransparent;
19+
public Oval(int radius, Color color)
20+
{
21+
this.radius = radius;
22+
this.mainColor = color;
23+
}
24+
public void setCenter(int x, int y)
25+
{
26+
this.x = x;
27+
this.y = y;
28+
}
29+
public void addTo(ProgramWindow panel)
30+
{
31+
panel.addPaintable(this);
32+
}
33+
@Override
34+
public void paint(Graphics2D g, JPanel caller)
35+
{
36+
Color color2 = Colors.getTransparentVersion(mainColor, percentTransparent);
37+
g.setColor(color2);
38+
//need to incorporate radius, x, y
39+
g.drawOval(x + 320, y - 20, radius + 250, radius + 140);
40+
g.fillOval(75, 140, 250, 400);
41+
}
42+
public void setTransparency(int percentTransparent)
43+
{
44+
this.percentTransparent = percentTransparent;
45+
}
46+
}

0 commit comments

Comments
 (0)