Turtle Programming v0.0.9: Add SetX, SetY, Square and Rect!

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

Along with bug fixes and code tweaks, This Commit has added the support of the following features/functions:

  1. Add SetX, SetY that allows turtle to move in only 1 directions. (one parameter)
  2. Set Square to draw a filled square. (one parameter)
  3. Add Rect to draw a filled rectangle. (two parameters)

Screenshots

image.png

Drawing a curve

ht cs make "x 1 make "y 1
repeat 100 [
  setx :x
  sety :y
  make "x :x+1 make "y :y*1.05
]

image.png

SetX and SetY in Javascript


case "setx":
    word_next = this.evalVars(word_next);
    if ((word_next == '') || (!isNumeric(word_next))) {
        this.pushErr(word, LOGO_ERR_MISSING_NUMBERS, word_next);
        return false;
    }
    this.logo.moveToX(parseFloat(word_next));
    i = y.next;
    break;      
case "sety":
    word_next = this.evalVars(word_next);
    if ((word_next == '') || (!isNumeric(word_next))) {
        this.pushErr(word, LOGO_ERR_MISSING_NUMBERS, word_next);
        return false;
    }
    this.logo.moveToY(-parseFloat(word_next));
    i = y.next;
    break;  

The Y coordinate mapping to canvas need to be inverted as the positive Y in Logo Coordinate system have a smaller Y value in Canvas.

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. Sleep
  17. 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:  

I love playing with turtle, I implemented my own in clojure awhile ago. Its a really great way to exercise your programming skills.

Great extension btw.

@justyy, thank you for supporting @steemitboard as a witness.

Here is a small present to show our gratitude
You can click on your award to jump to your Board of Honor

Once again, thanks for your support!

Thank you for the contribution. It has been approved.

You can contact us on Discord.

[utopian-moderator]

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

cool project

Coin Marketplace

STEEM 0.27
TRX 0.11
JST 0.031
BTC 67138.06
ETH 3678.23
USDT 1.00
SBD 3.73