Git Product home page Git Product logo

clojure-turtle's People

Contributors

atrus159 avatar austinschwartz avatar echeran avatar hairybreeches avatar nikai3d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clojure-turtle's Issues

ensure turtle is opaque

Currently, the turtle sprite that represents the turtle is drawn in the same color as the currently-set color. It's good to get feedback on the hue of the color, but because opacity determined by the alpha value should be ignored so that the turtle always remains easy to see.

It would be nice to have a method that takes a color vector of size 1, 3, or 4 and returns a vector [r g b 255], maybe called make-opaque.

Then, the get-turtle-sprite can be modified so that the opaque version of the current color can be used.

create a Java GUI with a REPL and canvas window

Create a Java GUI that contains a REPL but can also spawn a turtle graphics canvas.

This issue represents the Java version of the the issue in #11, which targets JavaScript.

There is a library for creating a REPL in a Java Swing GUI: https://github.com/alandipert/clj-swingrepl
And Seesaw makes Swing programming actually fun: https://github.com/daveray/seesaw

Creating a JS-targeted REPL as in #11 obviously has more relevance and reach, but having a Java version is better than not having one, all things being equal. At the time of this writing, neither exists, so deployment of clojure-turtle is still a bit 'manual'.

embed REPL & canvas into teaching materials

Because CLJS is self-hosted (you can compile CLJS code using CLJS -- no JVM required), it is possible to have a webpage that runs its own REPL. Also, it is possible to embed Quil sketches in a webpage. So it should be possible to have a webpage with a REPL next to the Quil canvas that it controls.

The Quil homepage contains examples of sketches that run. You can edit and run your own sketches online, too.

The Quil creator has also written about understanding the CLJS self-hosting features:
http://nbeloglazov.com/2016/03/05/getting-started-with-self-hosted-cljs-part-1.html
http://nbeloglazov.com/2016/03/07/getting-started-with-self-hosted-cljs-part-2.html
(a third part hasn't yet been published)

Examples of webpages that include their own CLJS REPL:
https://github.com/Lambda-X/replumb
https://github.com/yetanalytics/re-pl

add Leiningen plugin for new proj. template

It would be beneficial to have a Leiningen plugin that would create a new clojure-turtle project with all the correct dependencies and versions.

It's one less thing that the user has to think about. Quil itself and many other projects benefit from having an associated Leiningen template for a new project.

add recursion example

Add the typical Logo recursion example of a stick -> tree. Remember that you should "stop the recursion" (that is, have a no-op base case) when the size gets too small.

For fun, also try and make it brown and green!

add speak command?

I'm undecided on whether this functionality would be useful and in line with the simplicity of Logo, but here's the idea:

Have the turtle be able to print text to the screen.

Follow-on considerations for a such a feature include: enable configuring font type & size

event loop discrepancies between CLJ and CLJS

Based on work for issue #6, we have a wait fn that does what you would expect. But only in the CLJS REPL, and only when you try to mix wait and turtle commands, all of the waiting happens first, and all of the rendering happens at the end. As an example, see the difference in the following at the CLJS REPL:

(do (wait 3000) (forward 30) (wait 3000))
clojure-turtle.core=> (do (wait 3000) (println "hello") (wait 3000))

Perhaps the issue is due to how the rendering event loop in either Processing.js or the CLJS version of Quil is implemented. But for whatever reason, the issue is happening. It would be great to identify the problem and fix it if possible.

save the window contents to a file

It would nice to have a save fn that stores the screen contents to a file.

Trying to require quil.core and use the image output API wasn't sufficient. Or perhaps I'm missing something.

If Quil's save fns only work within sketch fns, it may mean clojure-turtle would need to wrap that behavior such that save only executes once, not every time Quil draws a new frame (ex: 30 or 60 times / second).

If this functionality is feasible, it should be feasible in Java Clojure. It may be possible in CLJS too, but I'm not sure what the differences would be between the standard REPL from a CLJ-bundled Jar and a npm-based CLJS REPL.

use Quill.js for a CLJS REPL

Not to be confused with Quil is Quill.js, a JavaScript widget designed to be cross-platform and take advantage of native OS support for rendering.

Quill.js, at least on Mac OS X, supports some Unicode character sets well that other text area / REPL widgets do not support well.

It would be nice to swap in Quill.js for the REPL box once a webpage can be created that has the REPL widget for a CLJS REPL next to the Quil canvas that it controls.

add wait fn

Add a wait function that pauses for a given number of milliseconds. If the syntax for sleep in CLJS is different than it is in Java Clojure, then reader conditionals will need to be used.

Because Quil/Processing animates drawings on a loop and repeatedly calls the draw function, the current way that clojure-turtle does drawing may need to be made more intelligent as well. I currently don't foresee that extra work, nor any need to update a turtle's saved state of commands, which means the work here should be straightforward.

create intro Clojure material using Logo

The following idea is on the basis that I've previously created a set of lessons in the style of a textbook and a 2 hr basic Clojure workshop among other teaching experiences...

When trying to introduce new people to Clojure (students new to programming, curious/interested experienced coworkers), they stop learning when they reach a point where the concept is too difficult/unfamiliar.

So far, there seem to be 2 groups I can think of: beginners in programming, and experienced programmers.

For the first group, Logo is a great way to learn. The key to engage such students once they reach mastery of basic Logo concepts and teach them more / more advanced programming concepts. Doing so in a gradual way, so as not to lose these learners, is one of the original motivating reasons for clojure-turtle. An approach that works for beginners should work for anyone.

For the second group, they look for an approach that makes them feeling like they're learning faster than average. They expect that their programming experience gives them a basis of comparison that they can use to intuit a new language's concepts, syntax, etc. as they bypass "beginner" material. Currently, if there is a stumbling block, it is that most programmers' experience currently does not yet include languages the look or behave like Clojure. The perceived gap here is a gentle intro to Clojure syntax and FP at a pace that assumes knowledge of basic programming concepts. One way to do this is to create a set of materials designed as, "Here's some concept implemented in Python, now here is the equivalent in Clojure".

Although the materials for the groups outline above would be different in nature, the structure of the lessons should be able to achieve convergence -- over time, the learners in the first group should eventually be able to reach the same mastery of Clojure as in the second group, and everyone should be equally satisfied.

Bug with the (clean) function

This may only manifest on my setup, so I need someone to confirm this, but when I use the (clean) function in the in the CLJC repl the drawing position is reset to HOME. The turtle icon remains in its position and will respond to commands normally, but the line drawn behind the turtle will be disconnected from the turtle, drawn as if I had used the (home) command. Below are screenshots:

1
2
3
4
5
6

I believe I did a clean download before running this so it should be in the most recent version

add undo functionality

add a function that can pop off the last commmand given to a turtle

ex: (clean) (forward 10) (undo) would be functionally equivalent to (clean)

Doesn't work with deps.edn/clj toolchain?

Having trouble getting it to work with the official clj/clojure CLI.

% clj -Sdeps '{:deps {com.google/clojure-turtle {:mvn/version "0.3.0"}}}'                                                                                                                                                            20-04-10 - 16:43:22
Downloading: com/google/clojure-turtle/0.3.0/clojure-turtle-0.3.0.pom from clojars
Downloading: quil/quil/2.2.6/quil-2.2.6.pom from clojars
Downloading: quil/processing-core/2.2.1/processing-core-2.2.1.pom from clojars
Downloading: quil/processing-dxf/2.2.1/processing-dxf-2.2.1.pom from clojars
Downloading: quil/processing-pdf/2.2.1/processing-pdf-2.2.1.pom from clojars
Downloading: quil/jogl-all-fat/2.1.5/jogl-all-fat-2.1.5.pom from clojars
Downloading: quil/processing-js/1.4.8.2/processing-js-1.4.8.2.pom from clojars
Downloading: quil/gluegen-rt-fat/2.1.5/gluegen-rt-fat-2.1.5.pom from clojars
Downloading: quil/processing-dxf/2.2.1/processing-dxf-2.2.1.jar from clojars
Downloading: quil/gluegen-rt-fat/2.1.5/gluegen-rt-fat-2.1.5.jar from clojars
Downloading: quil/processing-js/1.4.8.2/processing-js-1.4.8.2.jar from clojars
Downloading: quil/jogl-all-fat/2.1.5/jogl-all-fat-2.1.5.jar from clojars
Downloading: com/google/clojure-turtle/0.3.0/clojure-turtle-0.3.0.jar from clojars
Downloading: quil/processing-pdf/2.2.1/processing-pdf-2.2.1.jar from clojars
Downloading: quil/processing-core/2.2.1/processing-core-2.2.1.jar from clojars
Downloading: quil/quil/2.2.6/quil-2.2.6.jar from clojars
Error building classpath. Could not find artifact bouncycastle:bctsp-jdk14:jar:138 in central (https://repo1.maven.org/maven2/)

examples using core.async

Something that could show off the capabilities of Clojure to learners is core.async, which would give a taste of how Clojure makes concurrency easier.

It should be possible to have multiple turtles acting independently in a canvas, similar Rich Hickey's ants demo (https://youtu.be/hb3rurFxrZ8?t=49m50s), although we only have atoms (no refs) in clojure-turtle because it is preferable to have the same code work the same in CLJS and Java Clojure.

This concept is very much like NetLogo, for which there is already a set of materials built up around the concept.

Regardless of whether we attempt to create teaching materials that correspond to NetLogo, at least NetLogo would contain some nifty examples that are worth mimicking.

make turtle sprite centered over position

Instead of having the turtle sprite drawn exactly from the current position (running forward 10 creates an "arrow"), it provides more clarity to have the current position visible from inside the boundaries of the sprite.

add animation examples

Come up with examples where you can create animations.

Once there is a wait fn, an animation in Logo can created by drawing a picture, calling wait, calling clean, and doing it over again with another picture.

An animation using Logo functions will need to handle looping, termination, and loop state that each loop's picture can use. The easiest way is probably (dotimes [i MAX-FRAMES] ...)

round decimals to 2 places

When printing the turtle position in the REPL, we get full precision of the floating point. We only need 2 decimal places at most.

add doc on color

The main Readme should have screenshots and text to show the use of color to change the line stroke color and shape fill color.

Color is handled by Quil in different ways. As it's used by clojure-turtle, the user can either provide a grayscale value, RGB values, or RGBA values. All values are 0-255 (even the alpha value in RGBA). clojure-turtle takes in the color value as a vector.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.