Skip to content

Commit

Permalink
fix centering issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aspiringLich committed Feb 5, 2023
1 parent 55a5ccb commit 7f8311d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

// what should the group-id be breon
group 'paintingcanvas'
version '1.2.1'
version '1.2.2'

repositories {}
dependencies {}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/paintingcanvas/drawable/Ellipse.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ public Ellipse(int centerX, int centerY, int width, int height, Color color) {
@Override
public void draw(Graphics2D gc) {
gc.setColor(color);
if (this.filled) gc.fillOval(x, y, width, height);
else gc.drawOval(x, y, width, height);
if (this.filled) gc.fillOval(x - width / 2, y - height / 2, width, height);
else gc.drawOval(x - width / 2, y - height / 2, width, height);
}

@Override
public Point center(Graphics g) {
return new Point(x + width / 2, y + height / 2);
return new Point(x, y);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/paintingcanvas/drawable/Rectangle.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void draw(Graphics2D gc) {

@Override
public Point center(Graphics g) {
return new Point(x + width / 2, y + height / 2);
return new Point(x, y);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/paintingcanvas/drawable/Square.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public Square(int centerX, int centerY, int size, Color color) {
@Override
public void draw(Graphics2D gc) {
gc.setColor(this.color);
if (this.filled) gc.fillRect(x, y, size, size);
else gc.drawRect(x, y, size, size);
if (this.filled) gc.fillRect(x - size / 2, y - size / 2, size, size);
else gc.drawRect(x - size / 2, y - size / 2, size, size);
}

@Override
public Point center(Graphics g) {
return new Point(x + size / 2, y + size / 2);
return new Point(x, y);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/paintingcanvas/drawable/Triangle.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public Triangle(int centerX, int centerY, int width, int height, Color color) {
@Override
public void draw(Graphics2D gc) {
java.awt.Polygon poly = new java.awt.Polygon(
new int[]{x, x + width, x + width / 2},
new int[]{y + height, y + height, y},
new int[]{x - width / 2, x + width / 2, x},
new int[]{y + height / 2, y + height / 2, y - height / 2},
3
);
gc.setColor(this.color);
Expand All @@ -70,7 +70,7 @@ public void draw(Graphics2D gc) {

@Override
public Point center(Graphics g) {
return new Point(x + width / 2, y + height / 2);
return new Point(x, y);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/examples/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void main(String[] args) {

Polygon gaming = new Polygon(new int[][]{{100, 100}, {200, 200}, {200, 100}})
.setColor(0xffff00);
Square square = new Square(300, 300, 100)
Square square = new Square(0, 0, 100)
.setColor(0x00ff00);

Path curvey = new Path()
Expand All @@ -43,6 +43,6 @@ public static void main(String[] args) {

System.out.println("This runs after all the animations are done");

curvey.erase();
curvey.fadeOut(10);
}
}

0 comments on commit 7f8311d

Please sign in to comment.