Turtle Programming v0.0.6: Adding Circle, MoveTo, Turn and Screen!

in #utopian-io6 years ago (edited)

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.6 New Features

This Commit has the following changes:

  1. Add MoveTo function
  2. Add Circle function
  3. Add Turning (absolute degree)
  4. Set Screen Color
  5. Enhanced Error/Warning handling

Screenshots

Let's put all the above in one LOGO source code to demonstrate:

ht cs screen green color yellow ; test comment
pu moveto -200 20 pd turn 270
repeat 8 [circle 50 fd 10 rt 45]

image.png

Parse Source Code with 2 Parameters

The MoveTo takes two parameters that moves the turtle to a given coordinate, which is handled by the following javascript.

case "moveto":
    expr = this.evalVars(word_next);
    try {
        word_next = eval(expr);
    } catch (e) {
        this.pushErr(word, LOGO_ERR_EVAL, expr);
        return false;
    }               
    if ((word_next == '') || (!isNumeric(word_next))) {
        this.pushErr(word, LOGO_ERR_MISSING_NUMBERS, word_next);
        return false;
    }
    second_word = getNextWord(s, y.next, U);
    second_word_word = second_word.word;
    expr = this.evalVars(second_word_word);
    try {
        second_word_word = eval(expr);
    } catch (e) {
        this.pushErr(word, LOGO_ERR_EVAL, expr);
        return false;
    }                       
    if ((second_word_word == '') || (!isNumeric(second_word_word))) {
        this.pushErr(word, LOGO_ERR_MISSING_NUMBERS, second_word_word);
        return false;
    }                   
    this.logo.moveTo(word_next, second_word_word);
    i = second_word.next;
    break;  

Roadmap of Chrome Extension: Logo Turtle

  1. Add Functions
  2. Add IF/THEN/ELSE
  3. Add Variables
  4. Add Colors
  5. Add MoveTo
  6. Add PrintText
  7. Add Circle
  8. Add Arc
  9. Add Eraser
  10. Add Fill
  11. Save As Picture
  12. Save As Program
  13. Comments
  14. Add Recursion Support
  15. Add Global/Local Scopes
  16. 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

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.

[utopian-moderator]

@justyy 想问一下,什么情况可以用#cn-programming ?

想让中国人看的编程文章?

Hey @justyy I am @utopian-io. I have just upvoted you!

Achievements

  • WOW WOW WOW People loved what you did here. GREAT JOB!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

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

Coin Marketplace

STEEM 0.16
TRX 0.16
JST 0.031
BTC 59559.24
ETH 2523.49
USDT 1.00
SBD 2.42