Giter Site home page Giter Site logo

jslogo's Introduction

JsLogo

(A project using JavaScript does Logo language's do)

Using Qt builtin Google V8 JavaScript-Engine as a flexible script using in C++

(A demo to test the @RPGV2's scenarist executing script)

JSLogo's common snapshot

running_image

Installation

This project is based on QtSDK version 5.10, and you can compile the project using any version of Qt5 environment.

To download this project, please using:

	git clone https://github.com/Ruilx/JsLogo

and 'cd' in JsLogo, then:

	qmake
	make qmake_all

and finally 'make'(or with MinGW make 'mingw32-make') the project.

	make -f Makefile.Release

JsLogo's Functions

Using JavaScript to control a "turtle" to draw shapes, and command like @Logo-language.

The code had already built a JS object "turtle" to do the logo command.

  • Turtle movement
    • Go forward (forward, fd)
    • Go backward (backward, bk)
    • Go home (home)
    • Go to any coordinate (setX, setY, setXY)
  • Turtle rotation
    • Turn left (left, lt)
    • Turn right (right, rt)
  • Turtle drawable
    • Pen down (penDown, pd)
    • Pen up (penUp, pu)
  • Turtle penstyle
    • Pen width (setWidth)
    • Pen color (setPenColor, setPC)
    • Background color (setBackground, setBg)
  • Turtle visible
    • Show Turtle (showTurtle, st)
    • Hide Turtle (hideTurtle, ht)
  • Math Calculating
    • Trigonometric functions / Inverse trigonometric functions
    • Logarithm
    • Randoms
  • Other functions

What the turtle does

Using object "turtle" can send the command to turtle on the screen

  • Forward and backward
	turtle.forward(100);
	turtle.backward(100);

forward_image

  • Turn left and right
	turtle.left(90);
	turtle.right(90);

turn_image

  • Any coordinate and go home
	turtle.setXY(50, 50);
	turtle.home();

coord_image

  • Draw and release
	turtle.forward(50);
	turtle.penUp();
	turtle.forward(50);
	turtle.penDown();
	turtle.forward(50);

draw_image

  • Show and hide
	turtle.forward(100);
	turtle.hideTurtle();
	turtle.forward(100);

visible_image

  • Pen style
	turtle.forward(50);
	turtle.setWidth(10);
	turtle.forward(50);

pen_image

  • Initialization
	turtle.draw();
  • Repeated

Because JavaScript has cyclic programming, the REPEAT command will replace by "for" or "while" in JavaScript.

  • Complex drawing
	for(var i = 0; i < 36; i++){
		for(var j = 0;  j < 4; j++){
			turtle.forward(100);
			turtle.left(90);
		}
		turtle.left(10);
	}

complex_image complex_image complex_image

Issues

I am grateful you to setup a issue or make a pull request if you found any issues in the project, and if you appreciate this project, please lightup a star on the right top of the page~

Many Thanks for your star~

jslogo's People

Contributors

ruilx avatar

Stargazers

Landon avatar  avatar

Watchers

James Cloos avatar  avatar

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.