courbet 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/courbet/camera.rb +15 -0
- data/lib/courbet/create.rb +6 -5
- data/lib/courbet/sphere.rb +9 -2
- data/lib/courbet/templates/camera.erb +3 -3
- data/lib/courbet/templates/sphere.erb +3 -2
- data/lib/courbet/version.rb +1 -1
- metadata +2 -2
data/lib/courbet/camera.rb
CHANGED
@@ -3,11 +3,26 @@ module Courbet
|
|
3
3
|
def initialize opts={}
|
4
4
|
@position = opts[:position]
|
5
5
|
@watching = opts[:watching]
|
6
|
+
@type = opts[:type]
|
6
7
|
file = File.join($templates,'camera.erb')
|
7
8
|
@template = ERB.new File.open(file).read
|
9
|
+
@frame = 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def frame
|
13
|
+
x= @frame
|
14
|
+
@frame += 1
|
15
|
+
return x
|
8
16
|
end
|
9
17
|
|
10
18
|
def render
|
19
|
+
if @position.is_a? Proc
|
20
|
+
position = @position.call(frame)
|
21
|
+
else
|
22
|
+
position = @position
|
23
|
+
end
|
24
|
+
type = @type
|
25
|
+
watching = @watching
|
11
26
|
@template.result(binding)
|
12
27
|
end
|
13
28
|
end
|
data/lib/courbet/create.rb
CHANGED
@@ -3,6 +3,7 @@ module Courbet
|
|
3
3
|
attr_accessor :objects
|
4
4
|
def initialize
|
5
5
|
@objects = {}
|
6
|
+
@objects['lights'] = []
|
6
7
|
@atoms = 0
|
7
8
|
end
|
8
9
|
|
@@ -10,9 +11,9 @@ module Courbet
|
|
10
11
|
@atoms = n
|
11
12
|
end
|
12
13
|
|
13
|
-
def draw atom
|
14
|
+
def draw atom,time,id
|
14
15
|
begin
|
15
|
-
@objects[atom[0]].render atom[1..3].map {|d| d.to_f}
|
16
|
+
@objects[atom[0]].render atom[1..3].map {|d| d.to_f},time,id
|
16
17
|
rescue
|
17
18
|
# $stderr.puts "atom '#{atom[0]}': no design was given for this atom type"
|
18
19
|
end
|
@@ -26,7 +27,7 @@ module Courbet
|
|
26
27
|
ARGF.each do |line|
|
27
28
|
atom = line.chomp.split("\t")
|
28
29
|
if atom.count == 4 and atom[0].length < 2
|
29
|
-
@file.puts draw atom
|
30
|
+
@file.puts draw atom,frame,lineno
|
30
31
|
lineno += 1
|
31
32
|
end
|
32
33
|
|
@@ -58,11 +59,11 @@ module Courbet
|
|
58
59
|
end
|
59
60
|
|
60
61
|
def light opts
|
61
|
-
@objects['
|
62
|
+
@objects['lights'] << Light.new(opts)
|
62
63
|
end
|
63
64
|
|
64
65
|
def stage
|
65
|
-
@objects['camera'].render + @objects['
|
66
|
+
@objects['camera'].render + @objects['lights'].map {|l| l.render}.join("\n")
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
data/lib/courbet/sphere.rb
CHANGED
@@ -3,17 +3,24 @@ module Courbet
|
|
3
3
|
def initialize opts={}
|
4
4
|
@color = opts[:color]
|
5
5
|
@radius = opts[:radius]
|
6
|
+
@transmit = opts[:transmit]
|
6
7
|
file = File.join($templates,'sphere.erb')
|
7
8
|
@template = ERB.new File.open(file).read
|
8
9
|
end
|
9
10
|
|
10
|
-
def render coords
|
11
|
+
def render coords,time,id
|
11
12
|
if @color.is_a? Proc
|
12
13
|
color = @color.call(*coords)
|
13
14
|
else
|
14
15
|
color = @color
|
15
16
|
end
|
16
|
-
|
17
|
+
|
18
|
+
if @transmit.is_a? Proc
|
19
|
+
transmit = @transmit.call(time,id)
|
20
|
+
else
|
21
|
+
transmit = @transmit
|
22
|
+
end
|
23
|
+
@template.result(binding) unless transmit == 1.0
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
data/lib/courbet/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: courbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03
|
12
|
+
date: 2012-04-03 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Turn Molecular Dynamics XYZ files into PovRay files
|
15
15
|
email:
|