peter_pan 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 692af1cd2a9e3475428ba3ea1a3b432ad130b762
4
- data.tar.gz: 187e9b546dec65a4fbd4d380aaeb3dfde279d396
5
- SHA512:
6
- metadata.gz: 767b95aafa0fea9912984b6265fe34fee6157da042dcbf8bd16c370b3b4a239e3d5d712219590c53f9fe7e07a53c5e3699122139e1b048549451378c810201ba
7
- data.tar.gz: 99af0967d7d0b82ce6f339b87e19644007db8dd88236a7784c9c83c52f082e690e362884f392e2ff33461552fd91bc71272ab1d03edf6d17176c03807cbba183
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 32dacbc0c05b114896f17cdcc1bae4f34be30ebb
4
+ data.tar.gz: 39d8c536659d1a6cb8646fb244f20f94858f2e58
5
+ SHA512:
6
+ metadata.gz: 08d0925b4cc12dfe91b09b6ec9c3a87be9c872f3d5633ba2ed48202991ce46672ef1110d74b47e1ad897918d48078cc4e478e8dbc2e48d5c6a53ab9628d30813
7
+ data.tar.gz: 54457998b07f238e54e25ab7fba97596fd09aecbebfde19f2f94c83b0493525ad85f054d75036f81e87d32ddf28a4d8775a1c49f040a9e802f91d6eff8aa2f45
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in peter_pan.gemspec
4
4
  gemspec
5
+
6
+ gem 'dream-cheeky-led', '>=0.0.1.pre2'
data/README.md CHANGED
@@ -1,46 +1,42 @@
1
- ## Peter Pan - a Ruby gem providing a virtual screen buffer with viewport panning. For the Dream Cheeky LED sign and others.
1
+ ### Peter Pan - a Ruby gem providing a virtual screen buffer with viewport panning. For the Dream Cheeky LED sign and others, also works just fine with computer screen.
2
2
 
3
3
  Peter Pan gives you a large, virtual text frame buffer and a virtual
4
4
  viewport you can move around over it. You can plot points or draw text in the
5
5
  buffer and scroll the viewport over it to simulate scrolling text or scrolling
6
6
  graphics.
7
7
 
8
- It was written to make it easier to get text on the Dream Cheeky LED sign, but
9
- it'll work for any thing that that accepts a formatted text string as input.
8
+ ![Animated image of words panning over an LED display](https://github.com/xunker/peter_pan/raw/master/panning_text_example.gif)
10
9
 
11
- The dream-cheeky-led gem (https://github.com/Aupajo/dream-cheeky-led) is not a
12
- dependency, but it can be used in conjunction with this gem to get scrolling
13
- text and graphics on your Dream Cheeky LED sign.
10
+ It was written to make it easier to get text on the Dream Cheeky LED sign, but
11
+ it'll work for any thing that that accepts a formatted text string as input. It
12
+ will also work just fine on your computer screen.
14
13
 
15
- This gem uses the "transpo" font from Lewis Clayton's dcled_ruby project
16
- (https://github.com/Lewis-Clayton/dcled_ruby).
14
+ This gem uses the "transpo" font from Lewis Clayton's [dcled_ruby](https://github.com/Lewis-Clayton/dcled_ruby) project.
17
15
 
18
16
  ## Installation
19
17
 
20
- Install normally:
18
+ Install normally: `$ gem install peter_pan`
21
19
 
22
- $ gem install peter_pan
20
+ And then require it normally: `require 'peter_pan'`
23
21
 
24
- And then require it normally:
22
+ To write to a Dream Cheeky LED sign using `examples/*.rb`, also
23
+ install the most current version of the [dream-cheeky-led](https://github.com/Aupajo/dream-cheeky-led) gem:
25
24
 
26
- ```ruby
27
- require 'peter_pan'
25
+ ```shell
26
+ $ gem install dream-cheeky-led --pre
28
27
  ```
29
28
 
30
- To write to a Dream Cheeky LED sign using `examples/dream_cheeky.rb`, also
31
- install the dream-cheeky-led gem:
32
-
33
- $ gem install dream-cheeky-led --pre
29
+ If you are using Bundler to install the dependencies, version "0.0.1.pre2" or
30
+ greater will be installed automatically
34
31
 
35
32
  ## Examples
36
33
 
37
- There are basic examples in the `examples/` directory:
34
+ There are basic examples in the `examples/` directory that illustrate basic
35
+ concepts of drawing text to the buffer and panning the viewport over the it.
38
36
 
39
- dream_cheeky.rb: write to a USB Dream Cheeky Sign
40
- to_screen.rb: write to the screen
41
-
42
- These examples show the basic concepts of drawing text to the buffer and
43
- panning the viewport over the buffer.
37
+ * `bouncer_dream_cheeky.rb` - A pixel that bounces around the Dream Cheeky LED sign.
38
+ * `pan_dream_cheeky.rb` - Pans the Dream Cheeky LED sign over a larger virtual buffer.
39
+ * `pan_to_screen.rb` - Same as _pan_dream_cheeky.rb_, but outputs to screen -- no Dream Cheeky LED sign required!
44
40
 
45
41
  ## Usage
46
42
 
@@ -148,10 +144,10 @@ To print the buffer and viewport without the ascii-art borders, replace
148
144
  > p = PeterPan.new( viewport_width: 5, viewport_height: 5 )
149
145
  > p.write(0, 0, "Hello.")
150
146
  > puts p.show_viewport(5,0)
151
-
152
-
147
+
148
+
153
149
  ***
154
- *
150
+ *
155
151
  ****
156
152
  ```
157
153
 
@@ -160,8 +156,29 @@ without the enclosing border.
160
156
 
161
157
  ### Animated panning the viewport
162
158
 
163
- Please see the examples in `examples/`.
159
+ Check out `examples/pan_dream_cheeky.rb` and `examples/pan_to_screen.rb` to see
160
+ how to animate the movement of the viewport over the buffer.
161
+
162
+ [This animated image](https://github.com/xunker/peter_pan/raw/master/panning_text_example.gif) shows how `examples/pan_dream_cheeky.rb` looks when running on an actual Dream Cheeky LED sign.
164
163
 
165
164
  ## Documentation
166
165
 
167
- TODO: add link to RDOC here.
166
+ Detailed docs available [at rubydoc.org](http://rubydoc.org/github/xunker/peter_pan/master/frames)
167
+
168
+
169
+ ## Source
170
+
171
+ Source lives on Github: [xunker/peter_pan](https://github.com/xunker/peter_pan).
172
+
173
+ ## Contributing
174
+
175
+ You'll notice there are no tests in this repo, and that's my fault. That means
176
+ that if you'd like to make some changes or fix some bug, you don't need to
177
+ write tests if you don't want to! Yay!
178
+
179
+ Here's the process if you'd like to contribute:
180
+
181
+ * Fork the repo.
182
+ * Make your changes. If you can, please make your changes in a topic branch, not master.
183
+ * Test your changes as well as you can. I'll believe you if you say you did.
184
+ * Make a pull request.
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Makes a virtual "ball" bounce around the screen. Uses the peter_pan gem and
4
+ # dream-cheeky-led gem (https://github.com/Aupajo/dream-cheeky-led).
5
+ require 'peter_pan'
6
+ require 'dream-cheeky/led'
7
+
8
+ message_board = DreamCheeky::LEDMessageBoard.first
9
+
10
+ height = 7
11
+ width = 21
12
+
13
+ p = PeterPan.new(
14
+ viewport_width: width,
15
+ viewport_height: height,
16
+ buffer_width: width,
17
+ buffer_height: height
18
+ )
19
+
20
+ position_x = rand(6)
21
+ position_y = rand(20)
22
+
23
+ direction_x = 1
24
+ direction_y = 1
25
+
26
+ buffer = []
27
+ height.times do
28
+ buffer << []
29
+ width.times do
30
+ buffer.last << 0
31
+ end
32
+ end
33
+ loop do
34
+ buffer.each_with_index do |bx, i|
35
+ buffer[i] = bx.map{|v| v -= 1 if v > 0; v}
36
+ end
37
+
38
+ direction_x = -1 if position_x >= (height-1)
39
+ direction_y = -1 if position_y >= (width-1)
40
+ direction_x = 1 if position_x <= 0
41
+ direction_y = 1 if position_y <= 0
42
+
43
+ position_x += direction_x
44
+ position_y += direction_y
45
+
46
+ buffer[position_x][position_y] = 8
47
+
48
+ buffer.each_with_index do |bx, i|
49
+ # puts bx.map{|v|(v == 0 ? ' ' : v)}.join
50
+ bx.each_with_index do |by, ii|
51
+ p.plot(ii,i, (by > 0 ? by : ' '))
52
+ end
53
+ end
54
+ puts p.show_buffer
55
+
56
+ message_board.draw(p.show_buffer)
57
+
58
+ # message_board.draw_pixels(buffer)
59
+ # message_board.draw_pixels(buffer.map{|b|b.map{|v|(v>0?1:0)}})
60
+ sleep 0.04
61
+ print "\e[2J\e[f" # clear screen
62
+ end
@@ -11,7 +11,7 @@ require 'yaml'
11
11
  class PeterPan
12
12
  attr_reader :viewport_width, :viewport_height, :empty_point_character
13
13
 
14
- VERSION = "1.0.0"
14
+ VERSION = "1.0.1"
15
15
 
16
16
  # Possible Options:
17
17
  #
@@ -155,7 +155,7 @@ class PeterPan
155
155
  # clears everything out of the buffer.
156
156
  # By default, sets the buffer dimensions to 0x0. Optionally, you can pass
157
157
  # :width and :height args and the buffer dimentions will be set accordingly.
158
- # By default the buffer will be filled with space character, but you can
158
+ # By default the buffer will be filled with space character, but you can
159
159
  # set the char to be used by passing :clear_with
160
160
  def clear_buffer!(opts={})
161
161
  opts = { :width => 0, :height => 0, :clear_with => @empty_point_character }.merge(opts)
@@ -171,7 +171,7 @@ class PeterPan
171
171
 
172
172
  # returns a data structure representing the current font used by #write.
173
173
  def font
174
- @font ||= YAML.load(File.new("./fonts/#{@font_name}.yml").read)
174
+ @font ||= YAML.load(File.new("#{Gem.loaded_specs['peter_pan'].full_gem_path}/fonts/#{@font_name}.yml").read)
175
175
  end
176
176
 
177
177
  private
@@ -192,7 +192,7 @@ private
192
192
  (by.size-1).upto(buffer_width-1) do |i|
193
193
  by[i] = @empty_point_character
194
194
  end
195
- end
195
+ end
196
196
  end
197
197
 
198
198
  buffer_changed!
@@ -13,11 +13,11 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/xunker/peter_pan"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($/).reject{|fn| fn =~ /\.gif$/}
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rake", "~> 0"
23
23
  end
metadata CHANGED
@@ -1,79 +1,85 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: peter_pan
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Matthew Nielsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2014-02-05 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: "1.3"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
22
20
  type: :development
23
- version_requirements: *id001
24
- - !ruby/object:Gem::Dependency
25
- name: rake
26
21
  prerelease: false
27
- requirement: &id002 !ruby/object:Gem::Requirement
28
- requirements:
29
- - &id003
30
- - ">="
31
- - !ruby/object:Gem::Version
32
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
33
34
  type: :development
34
- version_requirements: *id002
35
- description: A virtual screen buffer with viewport panning. For the Dream Cheeky LED sign and others.
36
- email:
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A virtual screen buffer with viewport panning. For the Dream Cheeky LED
42
+ sign and others.
43
+ email:
37
44
  - xunker@pyxidis.org
38
45
  executables: []
39
-
40
46
  extensions: []
41
-
42
47
  extra_rdoc_files: []
43
-
44
- files:
45
- - .gitignore
48
+ files:
49
+ - ".gitignore"
46
50
  - Gemfile
47
51
  - LICENSE.txt
48
52
  - README.md
49
53
  - Rakefile
50
- - examples/dream_cheeky.rb
51
- - examples/to_screen.rb
54
+ - examples/bouncer_dream_cheeky.rb
55
+ - examples/pan_dream_cheeky.rb
56
+ - examples/pan_to_screen.rb
52
57
  - fonts/transpo.yml
53
58
  - lib/peter_pan.rb
54
59
  - peter_pan.gemspec
55
60
  homepage: https://github.com/xunker/peter_pan
56
- licenses:
61
+ licenses:
57
62
  - MIT
58
63
  metadata: {}
59
-
60
64
  post_install_message:
61
65
  rdoc_options: []
62
-
63
- require_paths:
66
+ require_paths:
64
67
  - lib
65
- required_ruby_version: !ruby/object:Gem::Requirement
66
- requirements:
67
- - *id003
68
- required_rubygems_version: !ruby/object:Gem::Requirement
69
- requirements:
70
- - *id003
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
71
78
  requirements: []
72
-
73
79
  rubyforge_project:
74
- rubygems_version: 2.0.13
80
+ rubygems_version: 2.2.2
75
81
  signing_key:
76
82
  specification_version: 4
77
- summary: A virtual screen buffer with viewport panning. For the Dream Cheeky LED sign and others.
83
+ summary: A virtual screen buffer with viewport panning. For the Dream Cheeky LED sign
84
+ and others.
78
85
  test_files: []
79
-