All Projects → peterc → trtl

peterc / trtl

Licence: MIT License
Tk-powered Ruby turtle graphics

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to trtl

TortoiseGraphics
A turtle graphics (a key feature of the Logo ) engine written in Swift.
Stars: ✭ 81 (+24.62%)
Mutual labels:  logo, turtle-graphics
simple-icons-pdf
PDF icons for popular brands
Stars: ✭ 16 (-75.38%)
Mutual labels:  logo
designs
Blockstack designs
Stars: ✭ 26 (-60%)
Mutual labels:  logo
ChannelFiles
Miscellaneous TFL/LL YouTube channel files.
Stars: ✭ 12 (-81.54%)
Mutual labels:  logo
RideShare-Trip-Stats
Chrome Extension to visualize your uber trip statistics
Stars: ✭ 61 (-6.15%)
Mutual labels:  logo
ont-api
ONT-API (OWL-API over Apache Jena)
Stars: ✭ 20 (-69.23%)
Mutual labels:  turtle
rio
RDF parsers library
Stars: ✭ 56 (-13.85%)
Mutual labels:  turtle
Logo
Logo Tiger Enterprise Özel Raporlar, Tablo ve View Açıklamaları
Stars: ✭ 73 (+12.31%)
Mutual labels:  logo
CryptoLogos
Hundreds of crypto logos simply named by their normalized contract address
Stars: ✭ 14 (-78.46%)
Mutual labels:  logo
glimmer-dsl-tk
Glimmer DSL for Tk (Ruby Tk Desktop Development GUI Library)
Stars: ✭ 26 (-60%)
Mutual labels:  tk
rdfshape-api
API for validating and transforming RDF, ShEx, SHACL and more.
Stars: ✭ 31 (-52.31%)
Mutual labels:  turtle
Dj-Engine
A Dj Hero 2 Clone for PC :)
Stars: ✭ 41 (-36.92%)
Mutual labels:  logo
svg-music-logos
🎧 A collection of logos and symbols from bands, musicians and related in SVG
Stars: ✭ 30 (-53.85%)
Mutual labels:  logo
server-media
This repository collects icons, logos & information about game servers.
Stars: ✭ 29 (-55.38%)
Mutual labels:  logo
python-gui-demos
This repo contains the basic demonstration of python gui
Stars: ✭ 31 (-52.31%)
Mutual labels:  tk
FloweringTree
Plain, old and simple Flowering Tree Class
Stars: ✭ 108 (+66.15%)
Mutual labels:  turtle
aframe-lsystem-component
L-System/LSystem component for A-Frame to draw 3D turtle graphics. Using Lindenmayer as backend.
Stars: ✭ 33 (-49.23%)
Mutual labels:  turtle-graphics
WebRtcShitBlt
client side WebRTC lib to add an image / watermark on the MediaSource
Stars: ✭ 19 (-70.77%)
Mutual labels:  logo
libre-logos
A collection of free logos for open source projects
Stars: ✭ 131 (+101.54%)
Mutual labels:  logo
branding
Our logos, and other branding material
Stars: ✭ 31 (-52.31%)
Mutual labels:  logo

2020 UPDATE: Due to tk being removed from the Ruby standard library and due to changes on macOS (which I primarily use), this library is no longer as easy to use for beginners as it once was. If you can come up with solutions to resolve this issue, I am all ears.

2021 UPDATE: I have not had to time to spend updating this project but some kind people in the issue tracker have suggestions on installing Tk in the modern age. See #5 (comment)

Trtl - Simple Ruby Turtle Graphics

Installation

gem install trtl

Description

Trtl is a simple 'turtle' system inspired by Python's turtle.py. It provides simple turtle drawing capabilities in Ruby, even if you're just at an IRB prompt. It leans on Tk (which used to be in Ruby's standard library but is now an external gem).

Usage

If Trtl detects you're in an IRb or Pry session, it'll automatically make turtle methods available directly at the prompt. For example:

$ irb
> require 'trtl'
> forward 100
# At this point, a window appears with the turtle

If you wish to use Trtl from a regular Ruby script, you have a few options. You can create a Trtl instance and use it directly:

require 'trtl'
t = Trtl.new
10.times { t.left(24); t.forward(30); t.ensure_drawn }
t.wait

You can use Trtl's run method to use it in a more interactive fashion:

Trtl.new.run { 10.times { left(24); forward(30); ensure_drawn } }

Or you can include InteractiveTurtle and get a similar effect as if you were in IRb:

include InteractiveTurtle
10.times { left(24); forward(30) }

Note: Using InteractiveTurtle makes drawing slower as it ensures all graphics are drawn after every action (as necessary for IRb use).

Commands

Only a small number of commands are currently implemented, but they're enough for the major actions:

  • title(title_name)
  • forward(distance) - aliased as fd
  • back(distance) - aliased as bk and backward
  • left(angle) - aliased as lt
  • right(angle) - aliased as rt
  • pen_up - aliased as pu and up and penup
  • pen_down - aliased as pd and down and pendown
  • color(color_name) - aliased as pencolor
  • move(x, y) - aliased as goto
  • position - aliased as pos
  • circle(radius, extent = 360, steps = 360)
  • dot(size) - draws a dot, defaults to a sensible size but you can supply if you want
  • is_drawing?
  • width(width_in_pixels)

Examples

The examples in the examples folder should be reasonably illustrative. If you try any of them, try example4.rb - it renders an awesome looking tree.

tree

Credits

Copyright and License

Copyright (c) 2012-2017 Peter Cooper (other than minor parts of some samples.)

MIT licensed. See LICENSE.md

  graph TD;
      A-->B;
      A-->C;
      B-->D;
      C-->D;
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].