Skip to content

Commit

Permalink
Agrega 2 formas de tortuga, corrige error al cerrar la forma de tortuga
Browse files Browse the repository at this point in the history
  • Loading branch information
titos-carrasco committed Apr 14, 2022
1 parent c4930cd commit 214e6d1
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 10 deletions.
38 changes: 38 additions & 0 deletions src/rcr/turtle/CircleShape.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package rcr.turtle;

/**
* Forma tortuga (tomada de turtle python)
*
* @author Roberto Carrasco (titos.carrasco@gmail-com)
*
*/
public class CircleShape extends PolygonShape {

/**
* Constructor
*/
public CircleShape() {
super();

path.moveTo(10, 0);
path.lineTo(9.51, 3.09);
path.lineTo(8.09, 5.88);
path.lineTo(5.88, 8.09);
path.lineTo(3.09, 9.51);
path.lineTo(0, 10);
path.lineTo(-3.09, 9.51);
path.lineTo(-5.88, 8.09);
path.lineTo(-8.09, 5.88);
path.lineTo(-9.51, 3.09);
path.lineTo(-10, 0);
path.lineTo(-9.51, -3.09);
path.lineTo(-8.09, -5.88);
path.lineTo(-5.88, -8.09);
path.lineTo(-3.09, -9.51);
path.lineTo(-0.00, -10.00);
path.lineTo(3.09, -9.51);
path.lineTo(5.88, -8.09);
path.lineTo(8.09, -5.88);
path.lineTo(9.51, -3.09);
}
}
3 changes: 1 addition & 2 deletions src/rcr/turtle/ClassicShape.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package rcr.turtle;

/**
* Forma clasica de tortuga (tomada de turtle python=
* Forma clasica de tortuga (tomada de turtle python)
*
* @author Roberto Carrasco (titos.carrasco@gmail-com)
*
Expand All @@ -18,6 +18,5 @@ public ClassicShape() {
path.lineTo(-5, -9);
path.lineTo(0, -7);
path.lineTo(5, -9);
path.closePath();
}
}
3 changes: 1 addition & 2 deletions src/rcr/turtle/SquareShape.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package rcr.turtle;

/**
* Forma rectangular de tortuga (tomada de turtle python=
* Forma rectangular de tortuga (tomada de turtle python)
*
* @author Roberto Carrasco (titos.carrasco@gmail-com)
*
Expand All @@ -18,6 +18,5 @@ public SquareShape() {
path.lineTo(10, 10);
path.lineTo(10, -10);
path.lineTo(-10, -10);
path.closePath();
}
}
3 changes: 1 addition & 2 deletions src/rcr/turtle/TriangleShape.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package rcr.turtle;

/**
* Forma triangular de tortuga (tomada de turtle python=
* Forma triangular de tortuga (tomada de turtle python)
*
* @author Roberto Carrasco (titos.carrasco@gmail-com)
*
Expand All @@ -16,6 +16,5 @@ public TriangleShape() {
path.moveTo(10, -5);
path.lineTo(0, 11);
path.lineTo(-10, -5);
path.closePath();
}
}
3 changes: 2 additions & 1 deletion src/rcr/turtle/Turtle.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class Turtle {
registerShape("square", SquareShape.class);
registerShape("triangle", TriangleShape.class);
registerShape("classic", ClassicShape.class);
registerShape("circle", CircleShape.class);
registerShape("turtle", TurtleShape.class);
}

/**
Expand Down Expand Up @@ -420,7 +422,6 @@ public void setShapeColor(Color color) {
* path.lineTo(10, 10);
* path.lineTo(10, -10);
* path.lineTo(-10, -10);
* path.closePath();
* }
* }
* </pre>
Expand Down
42 changes: 42 additions & 0 deletions src/rcr/turtle/TurtleShape.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package rcr.turtle;

/**
* Forma tortuga (tomada de turtle python)
*
* @author Roberto Carrasco (titos.carrasco@gmail-com)
*
*/
public class TurtleShape extends PolygonShape {

/**
* Constructor
*/
public TurtleShape() {
super();

path.moveTo(0, 16);
path.lineTo(-2, 14);
path.lineTo(-1, 10);
path.lineTo(-4, 7);
path.lineTo(-7, 9);
path.lineTo(-9, 8);
path.lineTo(-6, 5);
path.lineTo(-7, 1);
path.lineTo(-5, -3);
path.lineTo(-8, -6);
path.lineTo(-6, -8);
path.lineTo(-4, -5);
path.lineTo(0, -7);
path.lineTo(4, -5);
path.lineTo(6, -8);
path.lineTo(8, -6);
path.lineTo(5, -3);
path.lineTo(7, 1);
path.lineTo(6, 5);
path.lineTo(9, 8);
path.lineTo(7, 9);
path.lineTo(4, 7);
path.lineTo(1, 10);
path.lineTo(2, 14);
}
}
6 changes: 3 additions & 3 deletions src/test/Hilbert.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public Hilbert() {
}

public void run() {
t.setShape("classic");
t.setShape("turtle");
t.setPenUp();
t.setVisible(true);
t.setShapeScale(3, 3);
t.setShapeScale(1,1);
t.setShapeColor(Color.BLUE);
t.setHeading(0);
t.setPosition(0, 0);
t.setSpeed(10);
t.setSpeed(8);

t.setPenColor(Color.RED);
t.setPenSize(5);
Expand Down

0 comments on commit 214e6d1

Please sign in to comment.