Turtle Programming v0.0.8: /* */ comments, dotxy, and javascript!
Introduction to Logo Turtle
LogoTurtle is currently the FIRST and only one Chrome Extension for Turtle Graphics. I have also written a PHP version of Logo Interpreter in 2006 but that runs only on the server.
Previous Contributions
- v0.0.7: Turtle Programming v0.0.7: Functions with Parameters + Recursion!
- v0.0.6: Turtle Programming v0.0.6: Adding Circle, MoveTo, Turn and Screen!
- v0.0.5: Turtle Programming v0.0.5: Adding IF/ELSE and STOP!
- v0.0.4: LogoTurtle: Make Variables and Comments
- v0.0.3: Turtle Graphics Programming Update: Adding text, jump, dot, fontsize, download as png
- v0.0.2: LogoTurtle v0.0.2: ShowTurtle, HideTurtle, Color, Width and Help.
- Teach Your Kids Programming - The First Logo Interpreter (Turtle Graphics) in Chrome Extension!
v0.0.1
v0.0.8 New Features
Along with bug fixes and code tweaks, This Commit has added the support of the following features:
- Ignore Multi-line comments /* */ pairs like other high-level modern programming languages.
- dotxy takes two parameters that allow you to place a dot without moving the turtle anywhere.
- js that allows you to run the javascript code that handles the canvas directly!.
Screenshots
Classic Logo, Source code:
# Spiral
/*
draw a spiral
*/
cs
to spiral :size :angle
if (:size>:T) [stop] ; size too big
forward :size
right :angle
spiral :size+2 :angle
end
spiral 1 91 ; call the function
Drawing a line using dotxy
cs width 2 make "x 1 make "y 1
repeat 80 [
dotxy :x :y
make "x :x+1
make "y :y+1
]
You can control the Turtle using Javascript via JS
cs js [
for (let i = 0; i < 5; i ++ ) {
this.logo.fd(100);
this.logo.rt(144);
}
]
Javascript Parser to Skip Comments, Whitespaces and New Lines
// jump comments and white spaces
skipTo(s, i, U) {
// skip for white spaces and newlines
while ((i < U) && (isSpace(s[i]) || s[i] == '\n')) {
i ++;
}
if (i >= U) { // reach block end
return i;
}
// skip comments till the end
if ((s[i] == ';') || (s[i] == '#')) {
i ++;
while ((i < U) && (s[i] != '\n')) {
i ++;
}
i ++;
}
// skip // comments
if (i + 1 < U) {
if ((s[i] == '/') && (s[i + 1] == '/')) {
i += 2;
while ((i < U) && (s[i] != '\n')) {
i ++;
}
i ++;
}
}
// skip /* */ comments
if (i + 1 < U) {
if ((s[i] == '/') && (s[i + 1] == '*')) {
i += 2;
while ((i < U) && ((s[i] != '*') || (s[i + 1] != '/'))) {
i ++;
}
i += 2;
}
}
return i;
}
Roadmap of Chrome Extension: Logo Turtle
Add FunctionsAdd IF/THEN/ELSEAdd VariablesAdd ColorsAdd MoveToAdd PrintTextAdd Circle- Add Arc
- Add Eraser
- Add Fill
Save As Picture- Save As Program
CommentsAdd Recursion Support- Add Global/Local Scopes
- Sleep
- etc. etc.
Technology Stack
If an App can be written in Javascript, eventually it will be written in Javascript.
Chrome Webstore
Install the Turtle Programming for Kids Now!
Contribution Welcome
Github: https://github.com/DoctorLai/LogoTurtle
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request.
Posted on Utopian.io - Rewarding Open Source Contributors



nice!
没有看懂啥意思
Very nice @justyy
Thank you for the contribution. It has been approved.
Thanks! :)
You can contact us on Discord.
[utopian-moderator]
Hey @justyy I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x