All Projects → arthurealike → Turtle.lua

arthurealike / Turtle.lua

Licence: mit
Turtle graphics library for LÖVE.

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to Turtle.lua

Luxor.jl
Simple drawings using vector graphics; Cairo "for tourists!"
Stars: ✭ 293 (+423.21%)
Mutual labels:  drawing, simple
Mopaint
🎨💪 Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-10.71%)
Mutual labels:  drawing
Pencil
Pencil2D is an easy, intuitive tool to make 2D hand-drawn animations. Pencil2D is open source and cross-platform.
Stars: ✭ 968 (+1628.57%)
Mutual labels:  drawing
Omdb Graphql Wrapper
🚀 GraphQL wrapper for the OMDb API
Stars: ✭ 45 (-19.64%)
Mutual labels:  simple
Chalk
Chalk is a high quality, completely customizable, performant and 100% free Jekyll blog theme.
Stars: ✭ 987 (+1662.5%)
Mutual labels:  simple
Galeri Www
A perpetual artwork streaming app. (Website Repo)
Stars: ✭ 46 (-17.86%)
Mutual labels:  drawing
Arduino Foc Reaction Wheel Inverted Pendulum
Reaction wheel inverted pendulum project based on the Arduino Simple FOC library and SimpleFOC shied.
Stars: ✭ 30 (-46.43%)
Mutual labels:  simple
Simpleparallax.js
Simple and tiny JavaScript library that adds parallax animations on any images
Stars: ✭ 1,075 (+1819.64%)
Mutual labels:  simple
Scenekit Scnline
Draw a tube or thick line in SceneKit
Stars: ✭ 49 (-12.5%)
Mutual labels:  drawing
Munin C
C rewrite of various munin components
Stars: ✭ 43 (-23.21%)
Mutual labels:  simple
Minipaint
online image editor
Stars: ✭ 1,014 (+1710.71%)
Mutual labels:  drawing
Filesize.js
JavaScript library to generate a human readable String describing the file size
Stars: ✭ 997 (+1680.36%)
Mutual labels:  simple
Literallycanvas
A canvas in your browser. Literally.
Stars: ✭ 1,043 (+1762.5%)
Mutual labels:  drawing
Miniedit
Mini text editor with highlighting code, made for PHP, Pascal, D, Lua, HTML and css or any text code.
Stars: ✭ 36 (-35.71%)
Mutual labels:  simple
Derrick
🙌 Derrick is a clean minimal and fast theme for a personal blog.
Stars: ✭ 51 (-8.93%)
Mutual labels:  simple
Module Project
扩展性和灵活性非常好的模块化开发框架,内置很灵活高效的模板引擎
Stars: ✭ 33 (-41.07%)
Mutual labels:  simple
Perfect Freehand
Draw perfect pressure-sensitive freehand strokes.
Stars: ✭ 999 (+1683.93%)
Mutual labels:  drawing
Nasa Cli
🚀 Download NASA Picture of the Day from your terminal!
Stars: ✭ 45 (-19.64%)
Mutual labels:  simple
Mapit
An easy way to embed google maps in your site.
Stars: ✭ 54 (-3.57%)
Mutual labels:  simple
Slop
Simple Lightweight Option Parsing - ✨ new contributors welcome ✨
Stars: ✭ 1,067 (+1805.36%)
Mutual labels:  simple

turtle.lua MIT License

LÖVE

Minimalist drawing library is inspired by turtle graphics , written in lua for löve2d.

Prerequisite

How to use

Create a turtle instance. Give it your commands and call its draw() function in love.draw(), That's it!

View methods in detail

To draw a triangle:

local triangle = Turtle()

function love.load()
 -- turtle.lua supports chain methods as you can see below
    triangle:forward(60):left(120):forward(60):left(120):forward(60)
end

function love.draw()
   triangle:draw()
end

Result:


Examples

We added some examples to introduce you turtle library. See what we've done in Examples

What is turtle?

As docs.python introduces:

Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in 1967.

Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an import turtle, give it the command turtle.forward(15), and it moves (on-screen!) 15 pixels in the direction it is facing, drawing a line as it moves. Give it the command turtle.right(25), and it rotates in-place 25 degrees clockwise.

By combining together these and similar commands, intricate shapes and pictures can easily be drawn.

Turtle Methods

1. Turtle motion

  • Move and draw
 forward() | fd()  
 backward() | bk() | back()
 right() | rt()
 left() | lt()
 tl()
 rt()
 circle()
 setheading() | seth()
 home()
 go_to() | go() | setpos() | setposition()
 setx()
 sety()
 undo(c)
 speed()
  • Turtle's state
   position()
   heading()
   xcor()
   ycor()
   distance()
   name()
   nodecount()
   print()

2. Pen control

  • Drawing state
 pendown() | pd() | down()
 penup() | pu() | up()
 pensize() | width()
 isdown()
  • Color control
 color(...)
 fillcolor(...)
 turtlecolor()
  • Filling
 begin_fill()
 end_fill()
  • Drawing control
 reset()
 clear()

3. Turtle state

  • Visibility
 showturtle() | st()
 hideturtle() | ht()
 isvisible()
  • Color
 turtlecolor() | tc()

4. Event

 ondrawfinish() 

5. Animation

 play()
 pause()
 toggle()

6. Debug

 debugon()
 debugoff()
 drawDebug()

Quick example

local line = Turtle()
local circle = Turtle(100,100,1)
local triangle = Turtle(100,150,1, {1, 1, 1})

function love.load()
    local red = {1, 0, 0}
    line:clear():right(35):forward(100)
    circle:setcolor(1,1,1):penup()
    for i=1, 360 do
        circle:pendown():right(1):forward(2)
    end
    triangle:setcolor(red):left(60):forward(50):right(120):forward(50):left(60):backward(50)
end

function love.draw()
    line:draw()
    circle:draw()
    rectangle:draw()
end

License

Copyright (c) 2020 Erkam Badın

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].