trtl 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/README.md +22 -1
- data/lib/trtl.rb +10 -8
- data/test/helper.rb +1 -1
- data/trtl.gemspec +3 -2
- metadata +23 -11
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80fa5fb101dd5fe7e3ed22055cea60244ab076e5
|
4
|
+
data.tar.gz: f15e874499332c044aa3fd9cfed00bbf75c6587b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b662109d8892ca4533a9e8f0c967caa2a606a1de38f5791f97b83a78d039d1079579ba560cac9631f1e3df33a21fa09d66614a778a86964bebc94d58b6451ae
|
7
|
+
data.tar.gz: 034af7c28de84e94045db0e2d693d6d1c8e556e4935317375c04f9416fc210863ceaa1fa8647901ba8c287f3c859b11ff70ca3f8d99fc1191787b1929fd72208
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,27 @@ IRb:
|
|
43
43
|
Note: Using InteractiveTurtle makes drawing slower as it ensures all graphics
|
44
44
|
are drawn after every action (as necessary for IRb use).
|
45
45
|
|
46
|
+
## Commands
|
47
|
+
|
48
|
+
Only a small number of commands are currently implemented, but they're enough for the major actions:
|
49
|
+
|
50
|
+
* `title(title_name)`
|
51
|
+
* `forward(distance)` - aliased as `fd`
|
52
|
+
* `back(distance)` - aliased as `bk` and `backward`
|
53
|
+
* `left(angle)` - aliased as `lt`
|
54
|
+
* `right(angle)` - aliased as `rt`
|
55
|
+
* `pen_up` - aliased as `pu` and `up` and `penup`
|
56
|
+
* `pen_down` - aliased as `pd` and `down` and `pendown`
|
57
|
+
* `color(color_name)` - aliased as `pencolor`
|
58
|
+
* `move(x, y)` - aliased as `goto`
|
59
|
+
* `position` - aliased as `pos`
|
60
|
+
* `circle(radius, extent = 360, steps = 360)`
|
61
|
+
* `dot(size)` - draws a dot, defaults to a sensible size but you can supply if you want
|
62
|
+
* `is_drawing?`
|
63
|
+
* `width(width_in_pixels)`
|
64
|
+
|
65
|
+
More documentation to come later.
|
66
|
+
|
46
67
|
## Examples
|
47
68
|
|
48
69
|
The examples in the `examples` folder should be reasonably illustrative. If you
|
@@ -52,7 +73,7 @@ try any of them, try `example4.rb` - it renders an awesome looking tree.
|
|
52
73
|
|
53
74
|
## Credits
|
54
75
|
|
55
|
-
* turtle.py for inspiration
|
76
|
+
* turtle.py for inspiration (in the 'Ruby needs this!' sense)
|
56
77
|
* Some of the examples taken from examples for an earlier Ruby turtle found at http://www.rubyquiz.com/quiz104.html
|
57
78
|
|
58
79
|
## Copyright and License
|
data/lib/trtl.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'tk'
|
2
2
|
|
3
3
|
class Trtl
|
4
|
-
VERSION = "0.0.1"
|
5
|
-
|
6
4
|
CANVAS_WIDTH = 800
|
7
5
|
CANVAS_HEIGHT = 600
|
8
6
|
HOME_X = CANVAS_WIDTH / 2
|
@@ -33,10 +31,14 @@ class Trtl
|
|
33
31
|
@canvas
|
34
32
|
end
|
35
33
|
|
34
|
+
def title(title)
|
35
|
+
TkRoot.new(:title => title)
|
36
|
+
end
|
37
|
+
|
36
38
|
def pen_up
|
37
39
|
@drawing = false
|
38
40
|
end
|
39
|
-
|
41
|
+
|
40
42
|
def pen_down
|
41
43
|
@drawing = true
|
42
44
|
end
|
@@ -52,7 +54,7 @@ class Trtl
|
|
52
54
|
def width(width)
|
53
55
|
@width = width
|
54
56
|
end
|
55
|
-
|
57
|
+
|
56
58
|
def forward(amount = 20)
|
57
59
|
new_x = (@x + dx * amount)
|
58
60
|
new_y = (@y + dy * amount)
|
@@ -64,18 +66,18 @@ class Trtl
|
|
64
66
|
new_y = (@y - dy * amount)
|
65
67
|
move(new_x, new_y)
|
66
68
|
end
|
67
|
-
|
69
|
+
|
68
70
|
def move(new_x, new_y)
|
69
71
|
TkcLine.new(canvas, @x, @y, new_x, new_y, :width => @width, :fill => @color) if @drawing
|
70
72
|
@x, @y = new_x, new_y
|
71
73
|
draw
|
72
74
|
end
|
73
|
-
|
75
|
+
|
74
76
|
def right(offset)
|
75
77
|
@heading = (@heading + offset) % 360
|
76
78
|
draw
|
77
79
|
end
|
78
|
-
|
80
|
+
|
79
81
|
def left(offset)
|
80
82
|
@heading = (@heading - offset) % 360
|
81
83
|
draw
|
@@ -144,7 +146,7 @@ class Trtl
|
|
144
146
|
def dx
|
145
147
|
Math.cos(@heading * DEG)
|
146
148
|
end
|
147
|
-
|
149
|
+
|
148
150
|
def dy
|
149
151
|
Math.sin(@heading * DEG)
|
150
152
|
end
|
data/test/helper.rb
CHANGED
data/trtl.gemspec
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "trtl"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "trtl"
|
7
|
-
s.version =
|
6
|
+
s.version = "0.0.2"
|
8
7
|
s.authors = ["Peter Cooper"]
|
9
8
|
s.email = ["git@peterc.org"]
|
10
9
|
s.homepage = "https://github.com/peterc/trtl"
|
@@ -17,4 +16,6 @@ Gem::Specification.new do |s|
|
|
17
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
18
|
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_runtime_dependency 'tk', '~> 0.1'
|
20
21
|
end
|
metadata
CHANGED
@@ -1,16 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trtl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Peter Cooper
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
11
|
+
date: 2017-02-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
14
27
|
description: A Logo / turtle.py style turtle graphics system for Ruby
|
15
28
|
email:
|
16
29
|
- git@peterc.org
|
@@ -18,7 +31,7 @@ executables: []
|
|
18
31
|
extensions: []
|
19
32
|
extra_rdoc_files: []
|
20
33
|
files:
|
21
|
-
- .gitignore
|
34
|
+
- ".gitignore"
|
22
35
|
- Gemfile
|
23
36
|
- LICENSE.md
|
24
37
|
- README.md
|
@@ -35,27 +48,26 @@ files:
|
|
35
48
|
- trtl.gemspec
|
36
49
|
homepage: https://github.com/peterc/trtl
|
37
50
|
licenses: []
|
51
|
+
metadata: {}
|
38
52
|
post_install_message:
|
39
53
|
rdoc_options: []
|
40
54
|
require_paths:
|
41
55
|
- lib
|
42
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
57
|
requirements:
|
45
|
-
- -
|
58
|
+
- - ">="
|
46
59
|
- !ruby/object:Gem::Version
|
47
60
|
version: '0'
|
48
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
62
|
requirements:
|
51
|
-
- -
|
63
|
+
- - ">="
|
52
64
|
- !ruby/object:Gem::Version
|
53
65
|
version: '0'
|
54
66
|
requirements: []
|
55
67
|
rubyforge_project: trtl
|
56
|
-
rubygems_version:
|
68
|
+
rubygems_version: 2.6.8
|
57
69
|
signing_key:
|
58
|
-
specification_version:
|
70
|
+
specification_version: 4
|
59
71
|
summary: Ruby turtle graphics (ideal for use from IRb)
|
60
72
|
test_files:
|
61
73
|
- test/helper.rb
|