From 03b7b9845b076b85adb0419ecc0a2fff1ffdac60 Mon Sep 17 00:00:00 2001 From: staceyl Date: Wed, 3 Dec 2025 15:23:17 -0800 Subject: [PATCH 01/17] octogram --- lec40_git/StaceyStar.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lec40_git/StaceyStar.java 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 From 0dedfadd1811cc1170f6f28995356d0ec6cbb1ca Mon Sep 17 00:00:00 2001 From: Josh Hug Date: Wed, 3 Dec 2025 16:39:11 -0800 Subject: [PATCH 02/17] hi --- lec40_git/CS10Shape.java | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 lec40_git/CS10Shape.java 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 From 6405dc4fc4193e9fb68890d3ce5022a5a45e4e87 Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 3 Dec 2025 16:48:27 -0800 Subject: [PATCH 03/17] added a simple line --- lec40_git/line.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lec40_git/line.java 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 From 087a3853a3a1b4dada58ab97089f8b01b62d994b Mon Sep 17 00:00:00 2001 From: Ansel Yi Date: Wed, 3 Dec 2025 16:49:22 -0800 Subject: [PATCH 04/17] added turt --- lec40_git/AnselTurtle.java | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lec40_git/AnselTurtle.java diff --git a/lec40_git/AnselTurtle.java b/lec40_git/AnselTurtle.java new file mode 100644 index 0000000..17872c5 --- /dev/null +++ b/lec40_git/AnselTurtle.java @@ -0,0 +1,41 @@ +import java.awt.*; +import java.awt.geom.Line2D; + +/** + * A simple "Turtle Graphics" style tool for students. + */ +public class AnselTurtle { + private Graphics2D g2d; + private double x = 0; + private double y = 0; + private double heading = 0; // Degrees, 0 is East + + public AnselTurtle(Graphics2D g2d) { + this.g2d = g2d; + // Set default stroke + g2d.setStroke(new BasicStroke(3)); + } + + public void setColor(Color c) { + g2d.setColor(c); + } + + public void forward(double pixels) { + double rad = Math.toRadians(heading); + double newX = x + Math.cos(rad) * pixels; + double newY = y + Math.sin(rad) * pixels; + + g2d.draw(new Line2D.Double(x, y, newX, newY)); + + x = newX; + y = newY; + } + + public void turnRight(double degrees) { + heading += degrees; + } + + public void turnLeft(double degrees) { + heading -= degrees; + } +} \ No newline at end of file From 28a3a7e00d35543382d20739e68198b5f87643a7 Mon Sep 17 00:00:00 2001 From: Andrew Schoenen Date: Wed, 3 Dec 2025 16:50:19 -0800 Subject: [PATCH 05/17] maybe this doesn't work i forgot geometry? --- lec40_git/tweleveSidedShape.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lec40_git/tweleveSidedShape.java 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 From 6e063b9e9493195a32138130f899cc8369bdc6d4 Mon Sep 17 00:00:00 2001 From: Henry Hutchings Date: Wed, 3 Dec 2025 16:51:13 -0800 Subject: [PATCH 06/17] Just a diamond because I'm lazy --- lec40_git/Diamond.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lec40_git/Diamond.java diff --git a/lec40_git/Diamond.java b/lec40_git/Diamond.java new file mode 100644 index 0000000..7258d16 --- /dev/null +++ b/lec40_git/Diamond.java @@ -0,0 +1,16 @@ +import java.awt.Color; + +// This acts as the "default" shape so the screen isn't empty. +public class Diamond implements PartyShape { + + public void draw(Turtle t) { + t.setColor(Color.GREEN); + // Draw a square 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 From d17a954f21e24857c9de7a14463254c9b238a7a1 Mon Sep 17 00:00:00 2001 From: Jason Zhang Date: Wed, 3 Dec 2025 16:52:13 -0800 Subject: [PATCH 07/17] Don't really have an idea what shape might be --- lec40_git/JasonShape.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lec40_git/JasonShape.java 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 From 46e05feb42a6cff2867bca4ab08fa9688cc00625 Mon Sep 17 00:00:00 2001 From: harshinipulivarthi Date: Wed, 3 Dec 2025 16:54:23 -0800 Subject: [PATCH 08/17] super star --- lec40_git/SuperStar.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lec40_git/SuperStar.java diff --git a/lec40_git/SuperStar.java b/lec40_git/SuperStar.java new file mode 100644 index 0000000..dd57877 --- /dev/null +++ b/lec40_git/SuperStar.java @@ -0,0 +1,18 @@ +import java.awt.Color; + +public class Star 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 From 6db65ee383671284a1ef8799d6aad52452fd1ce2 Mon Sep 17 00:00:00 2001 From: Dylan Toh Date: Wed, 3 Dec 2025 16:54:29 -0800 Subject: [PATCH 09/17] dylans shape --- lec40_git/DylanCircle.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lec40_git/DylanCircle.java 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 From 96aa03c90d848f1de8a141c68430a9a8234db4b6 Mon Sep 17 00:00:00 2001 From: Henry Hutchings Date: Wed, 3 Dec 2025 16:55:21 -0800 Subject: [PATCH 10/17] Just a diamond because I'm lazy --- lec40_git/Diamond.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lec40_git/Diamond.java b/lec40_git/Diamond.java index 7258d16..3edffe0 100644 --- a/lec40_git/Diamond.java +++ b/lec40_git/Diamond.java @@ -1,11 +1,9 @@ import java.awt.Color; -// This acts as the "default" shape so the screen isn't empty. public class Diamond implements PartyShape { - public void draw(Turtle t) { t.setColor(Color.GREEN); - // Draw a square using primitive turtle moves + // Draw a diamond using primitive turtle moves for (int i = 0; i < 2; i++) { t.forward(60); t.turnRight(110); From 509c0da389d0e3ed4487c27133ff38bc6dcc6178 Mon Sep 17 00:00:00 2001 From: emily Date: Wed, 3 Dec 2025 16:55:35 -0800 Subject: [PATCH 11/17] :) --- lec40_git/Line.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lec40_git/Line.java 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 From 69d5a56712cf79e24b376ffa30909cadd0f1a823 Mon Sep 17 00:00:00 2001 From: sidv1711 Date: Wed, 3 Dec 2025 16:57:11 -0800 Subject: [PATCH 12/17] pentagon --- lec40_git/Pentagon.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lec40_git/Pentagon.java 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); + } + } +} From b1c8dcbbc2cdea8779c092a6fb6a5972671a8b28 Mon Sep 17 00:00:00 2001 From: monishka Date: Wed, 3 Dec 2025 16:59:00 -0800 Subject: [PATCH 13/17] spiral shape --- lec40_git/Spiral.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lec40_git/Spiral.java diff --git a/lec40_git/Spiral.java b/lec40_git/Spiral.java new file mode 100644 index 0000000..8c6669a --- /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); + + int step = 1; + for (int i = 0; i < 200; i++) { + t.forward(step); + t.turnRight(10); + step += 1; + } + } +} From 267570e76acb044fa54a93e6b3ef9a77179ef81d Mon Sep 17 00:00:00 2001 From: harshinipulivarthi Date: Wed, 3 Dec 2025 16:59:04 -0800 Subject: [PATCH 14/17] forgot to change class name --- lec40_git/SuperStar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lec40_git/SuperStar.java b/lec40_git/SuperStar.java index dd57877..d532ca1 100644 --- a/lec40_git/SuperStar.java +++ b/lec40_git/SuperStar.java @@ -1,6 +1,6 @@ import java.awt.Color; -public class Star implements PartyShape { +public class SuperStar implements PartyShape { public void draw(Turtle t) { // TODO: Change this color to your favorite! int red = 255; From 98973342610b44c291e803dbdac113689b630932 Mon Sep 17 00:00:00 2001 From: Akira Murata Date: Wed, 3 Dec 2025 16:59:52 -0800 Subject: [PATCH 15/17] try --- lec40_git/hakunaShape.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lec40_git/hakunaShape.java 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); + } + } +} From 2fb0a0574f2b7fd2836b34ad702e41f114dc1242 Mon Sep 17 00:00:00 2001 From: Ansel Yi Date: Wed, 3 Dec 2025 16:59:52 -0800 Subject: [PATCH 16/17] added triangle --- lec40_git/AnselTriangle.java | 14 ++++++++++++ lec40_git/AnselTurtle.java | 41 ------------------------------------ 2 files changed, 14 insertions(+), 41 deletions(-) create mode 100644 lec40_git/AnselTriangle.java delete mode 100644 lec40_git/AnselTurtle.java 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/AnselTurtle.java b/lec40_git/AnselTurtle.java deleted file mode 100644 index 17872c5..0000000 --- a/lec40_git/AnselTurtle.java +++ /dev/null @@ -1,41 +0,0 @@ -import java.awt.*; -import java.awt.geom.Line2D; - -/** - * A simple "Turtle Graphics" style tool for students. - */ -public class AnselTurtle { - private Graphics2D g2d; - private double x = 0; - private double y = 0; - private double heading = 0; // Degrees, 0 is East - - public AnselTurtle(Graphics2D g2d) { - this.g2d = g2d; - // Set default stroke - g2d.setStroke(new BasicStroke(3)); - } - - public void setColor(Color c) { - g2d.setColor(c); - } - - public void forward(double pixels) { - double rad = Math.toRadians(heading); - double newX = x + Math.cos(rad) * pixels; - double newY = y + Math.sin(rad) * pixels; - - g2d.draw(new Line2D.Double(x, y, newX, newY)); - - x = newX; - y = newY; - } - - public void turnRight(double degrees) { - heading += degrees; - } - - public void turnLeft(double degrees) { - heading -= degrees; - } -} \ No newline at end of file From 7e7e75b91afa16fd087e62a6c5aba2cba396e02d Mon Sep 17 00:00:00 2001 From: monishka Date: Wed, 3 Dec 2025 19:21:15 -0800 Subject: [PATCH 17/17] made spiral smaller since it was too big --- lec40_git/Spiral.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lec40_git/Spiral.java b/lec40_git/Spiral.java index 8c6669a..fecd6b4 100644 --- a/lec40_git/Spiral.java +++ b/lec40_git/Spiral.java @@ -10,12 +10,12 @@ public class Spiral implements PartyShape { @Override public void draw(Turtle t) { t.setColor(Color.BLUE); + double step = 0.2; - int step = 1; for (int i = 0; i < 200; i++) { t.forward(step); t.turnRight(10); - step += 1; + step += 0.2; } } }