courbet 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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['light'] = Light.new(opts)
62
+ @objects['lights'] << Light.new(opts)
62
63
  end
63
64
 
64
65
  def stage
65
- @objects['camera'].render + @objects['light'].render
66
+ @objects['camera'].render + @objects['lights'].map {|l| l.render}.join("\n")
66
67
  end
67
68
  end
68
69
  end
@@ -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
- @template.result(binding)
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
@@ -1,6 +1,6 @@
1
- camera{ ultra_wide_angle
1
+ camera{ <%= type %>
2
2
  angle 75
3
3
  right x*image_width/image_height
4
- location <%= @position.to_pov %>
5
- look_at <%= @watching.to_pov %> }
4
+ location <%= position.to_pov %>
5
+ look_at <%= watching.to_pov %> }
6
6
 
@@ -1,6 +1,7 @@
1
1
  sphere { <%= coords.to_pov %>, <%= @radius %>
2
- texture { pigment { color rgb <%= color.to_pov %> }
2
+ texture { pigment { color rgb <%= color.to_pov %> transmit <%= transmit %> }
3
3
  finish {
4
4
  diffuse 0.9
5
- phong 1.0 }}
5
+ ambient 0.2
6
+ phong 0.2 }}
6
7
  }
@@ -1,3 +1,3 @@
1
1
  module Courbet
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-27 00:00:00.000000000Z
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: