8000 GitHub - wbabic/turtle-graphics: an exploration of turtle graphics using clojure and clojurescript
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

wbabic/turtle-graphics

Repository files navigation

turtle graphics

idea

reincarnate the spirit of the famous LOGO turtle using the power of clojure and the reach of javascript

this is not meant to reproduce the LOGO language, but rather to use the idioms of clojure to implement a turtle that can be used todo

explore mathematics, geometry in particulr, computer programming, using computer graphics

the approach is to build up turtles and components in an interactive way with immediate feedback

to this end, we make use of devcards and figwheel and the reagent wrapper of react

download the git repository, start up the figwheel repl, open a borwser, open an editor

then read the devcards, read the code, edit the code, see the results in the browser - withou even refreshing it

the other idea at play here is that of buiding a geometer’s toolbox for a working programmer/mathematician exploring geometry building tools along the way as well as understanding programmable turtles are tools to add to the toolbox along with lines, circles, triangles and trasnformations cross ratio and stereographic projections

this is about more than writing turtle programs, is is about writing turtle program execution environments creating turtle habitats in new places

we start with svg, canvas, quil, electron and then move to native mobile devices

usage

start the app with: lein run -m clojure.main script/figwheel.clj

open a browser to: http://localhost:3451/cards.html

from the fighweel repl, go into a namespace: (in-ns ‘turtle-graphics.turtles.square.turtle)

and run turtle programs: (run-program (circle-dance :lt-green :lt-blue :lt-red :lt-purple) 1000)

open browser developer tools, to see turtle commands being processed in console and generated svg in html

introduction

an svg turtle with a position and a heading and some style, a stroke and a fill color and a set of commands that can make paths, that can be stoked or filled, and transformed

turtle-paths

a turtle and a set of commands commands are sent to the turtle causing it to change its postion, heading, or style

with each command the program changes state and a new view is rendered using hiccup style markup with reagent and react

commands include: move, turn, resize, repeat, recur, path programs composed of the basic commands, like circle, point, polygon, star, sierpensky

turtle state

the turtle state consists of a position and a heading

the position is a point in the plane the heading is a 2d vector

the heading and position are changed by turtle commands

turtle commands

as data, hiccup style [:move d] [:forward d] [:turn a] [:resize s]

as data, using clojure records (->Move d) (->Forward d) (->Left) (->Right) (->Circle color) (->Point point) (->Resize s)

svg rendering

[:svg {:width 200 :height 200} [:defs [:path {:d path-string}] [:clip]] [:circles …] [:paths …]]

svg commands

svg path commands as data structures [:M position] [:m vector] [:circle style] [:path {:id path-name} path-data]

path-data: “d M x1 y1 L x2 y2 Z”

quadratic bezier curve P0 P1 P2 cubic bezire curve P0 P1 P2 P3

turtle programs

an initial turtle-state a sequence of turtle commands

each command alters the turtle’s state and draws to the screen

program execution

create named path with id in defs element that draws the turtle shell and can then be transformed according to position and heading to where ever the turtle may be the turtle carries it’s shell with it, as you know and it’s own coordinate system

square dance

select from turtle programs creating svg points lines circles paths groups

turtle art

collected in galleries

turtle geometry

Hal Abelson The Computer as a Medium for Exploring Mathematics https://mitpress.mit.edu/books/turtle-geometry

turtle habitats

svg-turtle

this turtle lives in an svg document that can either be a standalone file or be embedded in an html web page rendered using react

canvas-turtle

this turtle lives in an html5 canvas both in two-dimensions and three, making use of web-gl

quil-processing-turtle

existing clojure quil turtles

google

https://github.com/google/clojure-turtle A Clojure library that implements the Logo programming language in a Clojure context

quil sketch

https://github.com/santoshryadav/Clojure-Turtle-Program A Quil sketch designed to draw Turtle and execute turtle commands in a Quil window.

clojure bridge

a dialect of google clojure turtle https://github.com/ClojureBridge/welcometoclojurebridge/blob/master/outline/TURTLE-SAMPLES.md rivendell:~/dev/clojure git clone https://github.com/ClojureBridge/welcometoclojurebridge

electron-turtle

a collection of turtles

simple turtle

responds only to commands Move, Turn, Resize can only display its own shell in svg

turtle robot

on the floor of the mit ui department and then onto the screen as a virtual turtle

mythical turtle

the story behind the turtle robot, a work of pure fiction where the turtle charater of our stories meets and inspires Jean Praget and Seymour Papert who then goes on to invent the famous LOGO turtle in mathland helping children to learn programming and mathematics turtle geometry

complex turtle

this turtle is not famous, but is the star of this application

this turtle lives in the complex plane using complex numbers to represent its position and heading and the processing of turtle commands employ additon and multiplication of complex numbers

geometric interpretations of complex addition and multiplication become tangible as the learner interacts with this complex turtle

this turtle also has some special powers. above and beyond traditional turtles

circles are fundamental as are lines

this turtle can show how a line is like a circle with infinate radius

affine turtle

this is the standard turtle, whose natural home is the affine plane

projective turtle

central and paralell projections with a pair of turtles

to explore projective geometry the projective plane and projective space

using homogeneous coordinates

hyperbolic turtle

this turtle explores hyperbolic space

About

an exploration of turtle graphics using clojure and clojurescript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0