-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat: a turtle graphics demo program #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Ready to be reviewed |
|
Just thinking out loud. Would it ever make sense to support the following functionaliy allowing the path to a local JAR file to be specified as a dependency? or maybe even (without having to first download the jar file) support the following syntax as well. Some jars are not published to Maven Central, but can be downloaded from project specific web sites to a local folder. APLU5.jar is one of them. APLU5.jar is self-contained and do not depend on any other external Java libraries. |
|
What is the "best" turtle graphics library for Java? |
|
Standalone jars are not dependencies but class path entries. '--classpath %{url}' should work. Not at laptop atm so can't verify if we ever got around to implement //CLASPATH in source files. |
Link doesn't work |
examples/turtle.java
Outdated
| // Usage: jbang turtle.java | ||
| // Requires: JDK 8 or higher | ||
|
|
||
| //DEPS ch.aplu.turtle:aplu5:0.1.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i love the idea of turtle example but if it not something available from maven central or that some other way jbang can fetch it (*) then i think it makes more damage than good
(*) yes, we should probably support //CLASSPATH but we dont right now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, there are not other good Java-based turtle examples. This is the only one that I could find.
Now updated to the Java 25 version that you provided.
|
This new TurtleDemo.java program can be run without relying on external dependencies. $ jbang run TurtleDemo.java |
Unfortunately, none of the Turtle graphics libraries created for Java are availalbe from Maven Central. They are mostly available as source code or downloadable JAR files. The Turtle Demo has been re-implemented using Turtle.java from |
|
Well running |
|
But somehow I would find this even more "impressive": ///usr/bin/env jbang "$0" "$@" ; exit $?
//SOURCES https://github.com/NicholasSeward/Turtle/blob/main/Turtle.java
import java.awt.Color;
public class TurtleDemo {
public static void main(String[] args) {
Turtle joe = new Turtle();
joe.penColor(Color.RED);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 4; j++) {
joe.forward(150);
joe.right(90);
}
joe.left(36);
}
joe.left(90);
}
}No need to copy a file, instead it gets taken directly from the source. |
|
had same thought @quintesse. One reason to copy it though could be so we could get rid of these warnings: |
|
Sure, but it would be nicer to do that upstream, right? |
|
Btw, I just found another one-file library that could be nice for a JBang example: https://github.com/arkanovicz/essential-json/blob/master/src/main/java/com/republicate/json/Json.java it's a JSON parser in a single file (there's also a Maven artifact, but where's the fun in that? :-) ) |
|
I've submitted a pull request to resolve one of the warnings in the Turtle.java code |

A turtle graphics example program for the kids (or young at heart) learning to program in Java using JBang