diff --git a/lec40_git/AnselTriangle.java b/lec40_git/AnselTriangle.java new file mode 100644 index 0000000..465bec2 --- /dev/null +++ b/lec40_git/AnselTriangle.java @@ -0,0 +1,14 @@ +import java.awt.*; + +public class AnselTriangle implements PartyShape { + public void draw(Turtle t) { + // TODO: Change this color to your favorite! + t.setColor(Color.BLUE); + + // Draw a triangle + for (int i = 0; i < 3; i++) { + t.forward(60); + t.turnRight(120); + } + } +} \ No newline at end of file diff --git a/lec40_git/CS10Shape.java b/lec40_git/CS10Shape.java new file mode 100644 index 0000000..6fe1b89 --- /dev/null +++ b/lec40_git/CS10Shape.java @@ -0,0 +1,48 @@ +import java.awt.Color; +import java.util.Random; + +public class CS10Shape implements PartyShape { + + private int currentSegment = 0; + private int totalSegments = 0; + private int colorVelocity = 0; + private Random r = new Random(); + + @Override + public void draw(Turtle t) { + double length = 200; + int depth = 3; + colorVelocity = -5; + + + totalSegments = 3 * (int)Math.pow(4, depth) - colorVelocity; + + for (int i = 0; i < 3; i++) { + drawHelper(t, length, depth); + t.turnRight(120); + } + } + + private void drawHelper(Turtle t, double length, int depth) { + if (depth == 0) { + float hue = 0.75f - (0.6f * (currentSegment % totalSegments) / totalSegments); + + // High saturation (0.9) and brightness (1.0) for visibility + t.setColor(Color.getHSBColor(hue, 0.9f, 1.0f)); + + t.forward(length); + currentSegment++; + + } else { + double segmentLength = length / 3.0; + + drawHelper(t, segmentLength, depth - 1); + t.turnLeft(60); + drawHelper(t, segmentLength, depth - 1); + t.turnRight(120); + drawHelper(t, segmentLength, depth - 1); + t.turnLeft(60); + drawHelper(t, segmentLength, depth - 1); + } + } +} \ No newline at end of file diff --git a/lec40_git/Diamond.java b/lec40_git/Diamond.java new file mode 100644 index 0000000..3edffe0 --- /dev/null +++ b/lec40_git/Diamond.java @@ -0,0 +1,14 @@ +import java.awt.Color; + +public class Diamond implements PartyShape { + public void draw(Turtle t) { + t.setColor(Color.GREEN); + // Draw a diamond using primitive turtle moves + for (int i = 0; i < 2; i++) { + t.forward(60); + t.turnRight(110); + t.forward(60); + t.turnRight(70); + } + } +} \ No newline at end of file diff --git a/lec40_git/DylanCircle.java b/lec40_git/DylanCircle.java new file mode 100644 index 0000000..e47d212 --- /dev/null +++ b/lec40_git/DylanCircle.java @@ -0,0 +1,18 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +import java.awt.Color; + +public class DylanCircle implements PartyShape { + public void draw(Turtle t) { + t.setColor(Color.ORANGE); + + for(int i = 0; i < 36; ++i) { + t.forward((double)20.0F); + t.turnRight((double)15.0F); + } + + } +} \ No newline at end of file diff --git a/lec40_git/JasonShape.java b/lec40_git/JasonShape.java new file mode 100644 index 0000000..d40de96 --- /dev/null +++ b/lec40_git/JasonShape.java @@ -0,0 +1,15 @@ +import java.awt.Color; + +public class Hexagon implements PartyShape { + + @Override + public void draw(Turtle t) { + t.setColor(Color.Blue); + + t.forward(100); + t.turnRight(); + t.forward(100); + t.turnRight(); + t.forward(100); + } +} \ No newline at end of file diff --git a/lec40_git/Line.java b/lec40_git/Line.java new file mode 100644 index 0000000..81e460b --- /dev/null +++ b/lec40_git/Line.java @@ -0,0 +1,11 @@ +import java.awt.Color; + +public class Line implements PartyShape { + public void draw(Turtle t) { + + t.setColor(Color.YELLOW); + + // draw a line + t.forward(50); + } +} \ No newline at end of file diff --git a/lec40_git/Pentagon.java b/lec40_git/Pentagon.java new file mode 100644 index 0000000..26183d7 --- /dev/null +++ b/lec40_git/Pentagon.java @@ -0,0 +1,19 @@ +import java.awt.*; + +public class Pentagon implements PartyShape { + /** + * Draw your shape using the provided Turtle. + * The Turtle starts at (0,0) facing East. + * + * @param t + */ + @Override + public void draw(Turtle t) { + t.setColor(Color.CYAN); + // Draw a square using primitive turtle moves + for (int i = 0; i < 5; i++) { + t.forward(100); + t.turnRight(108); + } + } +} diff --git a/lec40_git/Spiral.java b/lec40_git/Spiral.java new file mode 100644 index 0000000..fecd6b4 --- /dev/null +++ b/lec40_git/Spiral.java @@ -0,0 +1,21 @@ +import java.awt.Color; +public class Spiral implements PartyShape { + + /** + * Draw your shape using the provided Turtle. + * The Turtle starts at (0,0) facing East. + * + * @param t + */ + @Override + public void draw(Turtle t) { + t.setColor(Color.BLUE); + double step = 0.2; + + for (int i = 0; i < 200; i++) { + t.forward(step); + t.turnRight(10); + step += 0.2; + } + } +} diff --git a/lec40_git/StaceyStar.java b/lec40_git/StaceyStar.java new file mode 100644 index 0000000..bed8eb0 --- /dev/null +++ b/lec40_git/StaceyStar.java @@ -0,0 +1,14 @@ +import java.awt.Color; + +public class StaceyStar implements PartyShape { + public void draw(Turtle t) { + // TODO: Change this color to your favorite! + t.setColor(Color.MAGENTA); + + // Draw a 8-pointed star + for (int i = 0; i < 8; i++) { + t.forward(50); + t.turnRight(135); + } + } +} \ No newline at end of file diff --git a/lec40_git/SuperStar.java b/lec40_git/SuperStar.java new file mode 100644 index 0000000..d532ca1 --- /dev/null +++ b/lec40_git/SuperStar.java @@ -0,0 +1,18 @@ +import java.awt.Color; + +public class SuperStar implements PartyShape { + public void draw(Turtle t) { + // TODO: Change this color to your favorite! + int red = 255; + Color tcolor = new Color(red, 0, 127); + t.setColor(Color.PINK); + + // Draw a 5-pointed star + for (int i = 0; i < 5; i++) { + t.forward(50); + red = red - 10; + Color tcolor = new Color(red, 0, 127); + t.turnRight(144); + } + } +} \ No newline at end of file diff --git a/lec40_git/hakunaShape.java b/lec40_git/hakunaShape.java new file mode 100644 index 0000000..6bcdc8b --- /dev/null +++ b/lec40_git/hakunaShape.java @@ -0,0 +1,14 @@ +import java.awt.Color; + +// This acts as the "default" shape so the screen isn't empty. +public class hakunaShape implements PartyShape { + + public void draw(Turtle t) { + t.setColor(Color.GREEN); + // Draw a square using primitive turtle moves + for (int i = 0; i < 8; i++) { + t.forward(30); + t.turnRight(25); + } + } +} diff --git a/lec40_git/line.java b/lec40_git/line.java new file mode 100644 index 0000000..97cb5d5 --- /dev/null +++ b/lec40_git/line.java @@ -0,0 +1,12 @@ +import java.awt.Color; + +public class Line implements PartyShape { + + @Override + public void draw(Turtle t) { + t.setColor(Color.GREEN); + + + t.forward(90) + } +} \ No newline at end of file diff --git a/lec40_git/tweleveSidedShape.java b/lec40_git/tweleveSidedShape.java new file mode 100644 index 0000000..d1ad832 --- /dev/null +++ b/lec40_git/tweleveSidedShape.java @@ -0,0 +1,16 @@ +import java.awt.Color; + +public class twelveSidedShape implements PartyShape { + + @Override + public void draw(Turtle t) { + // TODO: Change this color! + t.setColor(Color.MAGENTA); + + // Draw a hexagon + for (int i = 0; i < 12; i++) { + t.forward(40); + t.turnRight(150); + } + } +} \ No newline at end of file