pixo 0.1.4 → 0.2.0

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
1
  ---
2
2
  SHA1:
3
- metadata.gz: a444740a2f108681ab80d667312e292dd4636939
4
- data.tar.gz: 2c029fc83f3daa384909d61f5c08293f1312ac76
3
+ metadata.gz: 5a2ed5c3cd2e91b160038f832a3b282710879b21
4
+ data.tar.gz: 533ea89508d8054cda89981d09dc7a012ba428d4
5
5
  SHA512:
6
- metadata.gz: 64b419177900e6b30a2ccaae9ebdf843f1cbcc5e4c65f2f0a15d078436be7bec0493162155f941ad931999bd7c28ae4168f8d1b4d608752b92057acbe82e3b6c
7
- data.tar.gz: 942e391caa23842fa73e331516a42b7d739fe668ce8a9d33ffa7b01822633bfc5248b95031ae6083a25d717338256ecfd26fcbbaf4640488b7f1608d7276709e
6
+ metadata.gz: 6b3bce155d3ac4418236f4cfc8ee774371bab059cf21f8b8c5a253587b3b2d9eef0a50cb7211ba2a1752cc7fbf892e42bbf94700b65ddc41221bcf19609513c7
7
+ data.tar.gz: 43e9f3a7dd771a5c7b47b94382adfd30f3acaaf6f143f8730e1b3c31508dc200e47e9bf487d6d5034c67d62fe7289c4abed9534a14bbd22e99e8878d2fdea1cd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pixo (0.1.4)
4
+ pixo (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/exe/pixo ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pixo'
4
+
5
+ Pixo::Application.new.run
data/lib/pixo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pixo
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/pixo.rb CHANGED
@@ -1,57 +1,82 @@
1
1
  require "pixo/version"
2
+ require "open3"
3
+ require 'benchmark'
4
+ require 'base64'
2
5
 
3
6
  require File.expand_path('../libpixgem', __FILE__)
4
7
 
5
8
  module Pixo
9
+ class FrameStatus
10
+ attr_accessor :render_ms
11
+ def initialize(render_ms)
12
+ self.render_ms = render_ms
13
+ end
14
+ end
6
15
 
7
- class Application < Pixo::Native::Application
8
- attr_accessor :running
16
+ class Renderer
9
17
 
10
- def initialize()
11
- super
12
- self.running = true
18
+ def run(&block)
19
+ Open3.popen3('bundle exec pixo') do |i, o, e, t|
20
+ while line = o.readline
13
21
 
14
- add_fadecandy(Pixo::Native::FadeCandy.new('localhost', 8))
15
- end
16
-
17
- def run
18
- p active_pattern
19
- while(
20
- running &&
21
- tick(active_pattern))
22
- if (active_pattern.elapsed > 10 * 60)
23
- self.active_pattern = random_pattern
22
+ block.call(Marshal.load(Base64.strict_decode64(line.strip)))
23
+ end
24
24
  end
25
25
  end
26
- close
27
26
  end
28
27
 
28
+ class Application < Pixo::Native::Application
29
+ attr_accessor :running
29
30
 
30
- def patterns
31
- unless @patterns
32
- @patterns = Hash.new
33
- patterns_dir = File.join(File.dirname(__FILE__), "..", 'ext', 'pixo', 'patterns')
34
- Dir.entries(patterns_dir).each do | pattern_file|
35
- next unless pattern_file.end_with?('.glsl')
36
- @patterns[pattern_file] = Pixo::Native::Pattern.new(File.read(File.join(patterns_dir, pattern_file)))
31
+ def initialize()
32
+ super
33
+ self.running = true
34
+
35
+ add_fadecandy(Pixo::Native::FadeCandy.new('localhost', 8))
36
+ end
37
+
38
+ def run
39
+ while(running)
40
+ render_ms = Benchmark.realtime do
41
+ running = tick(active_pattern) && running
42
+ end
43
+
44
+ stats = Pixo::FrameStatus.new(render_ms)
45
+ STDOUT.write(Base64.strict_encode64(Marshal.dump(stats)))
46
+ STDOUT.write($/)
47
+ STDOUT.flush
48
+
49
+ if (active_pattern.elapsed > 1)
50
+ self.active_pattern = random_pattern
51
+ end
37
52
  end
53
+ close
38
54
  end
39
- @patterns
40
- end
41
55
 
42
- def active_pattern
43
- @active_pattern ||= random_pattern
44
- end
45
56
 
46
- def random_pattern
47
- patterns[patterns.keys.sample]
48
- end
57
+ def patterns
58
+ unless @patterns
59
+ @patterns = Hash.new
60
+ patterns_dir = File.join(File.dirname(__FILE__), "..", 'ext', 'pixo', 'patterns')
61
+ Dir.entries(patterns_dir).each do | pattern_file|
62
+ next unless pattern_file.end_with?('.glsl')
63
+ @patterns[pattern_file] = Pixo::Native::Pattern.new(File.read(File.join(patterns_dir, pattern_file)))
64
+ end
65
+ end
66
+ @patterns
67
+ end
49
68
 
50
- def active_pattern=(pattern)
51
- pattern.reset_start
52
- @active_pattern = pattern
53
- end
69
+ def active_pattern
70
+ @active_pattern ||= random_pattern
71
+ end
54
72
 
55
- end
73
+ def random_pattern
74
+ patterns[patterns.keys.sample]
75
+ end
56
76
 
77
+ def active_pattern=(pattern)
78
+ pattern.reset_start
79
+ @active_pattern = pattern
80
+ end
81
+ end
57
82
  end
data/pixo.gemspec CHANGED
@@ -17,12 +17,10 @@ Gem::Specification.new do |spec|
17
17
  spec.extensions << "ext/libpixgem/extconf.rb"
18
18
 
19
19
 
20
- spec.files = (Dir['*'] + Dir['bin/**/*'] + Dir['ext/**/*'] + Dir['lib/**/*'] ).keep_if do |file|
20
+ spec.files = (Dir['*'] + Dir['bin/**/*'] + Dir['exe/**/*'] + Dir['ext/**/*'] + Dir['lib/**/*'] ).keep_if do |file|
21
21
  File.file?(file) && !file.end_with?(".so")
22
22
  end
23
- #spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
- # f.match(%r{^(test|spec|features)/})
25
- #end
23
+
26
24
  spec.bindir = "exe"
27
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
26
  spec.require_paths = ["lib"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Constantine
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-13 00:00:00.000000000 Z
11
+ date: 2017-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,8 @@ dependencies:
55
55
  description: Write a longer description or delete this line.
56
56
  email:
57
57
  - cconstan@gmail.com
58
- executables: []
58
+ executables:
59
+ - pixo
59
60
  extensions:
60
61
  - ext/libpixgem/extconf.rb
61
62
  extra_rdoc_files: []
@@ -68,6 +69,7 @@ files:
68
69
  - Rakefile
69
70
  - bin/console
70
71
  - bin/setup
72
+ - exe/pixo
71
73
  - ext/CMakeLists.txt
72
74
  - ext/libpixgem/extconf.rb
73
75
  - ext/libpixgem/include/opengl.h
@@ -1531,7 +1533,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1531
1533
  version: '0'
1532
1534
  requirements: []
1533
1535
  rubyforge_project:
1534
- rubygems_version: 2.6.13
1536
+ rubygems_version: 2.6.11
1535
1537
  signing_key:
1536
1538
  specification_version: 4
1537
1539
  summary: Write a short summary, because Rubygems requires one.