basis-processing 0.5.2 → 0.5.3

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.
data/README CHANGED
@@ -1,4 +1,4 @@
1
- **NOTE: Starting from version 0.5.1, Basis has been ported to Ruby 1.9.2, because of the kd-tree library dependency. There are no current plans of maintaining Basis compatibility with Ruby 1.8.x.**
1
+ **NOTE: Starting from version 0.5.1, Basis has been ported to Ruby 1.9.2, because of the kd-tree library dependency. Currently, there are no plans of maintaining Basis compatibility with Ruby 1.8.x.**
2
2
 
3
3
  **Basis** provides a set of classes for easily plotting and transforming arbitrary 2D coordinate systems by specifying their basis vectors. Originally developed to work with Ruby-Processing, it now supports any class which supports Processing-like semantics.
4
4
 
data/basis.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = "basis-processing"
3
- s.version = "0.5.2"
3
+ s.version = "0.5.3"
4
4
  s.add_dependency('knnball', '>= 0.0.6')
5
5
  s.author = "Avishek Sen Gupta"
6
6
  s.email = "avishek.sen.gupta@gmail.com"
data/lib/demo.rb CHANGED
@@ -40,7 +40,6 @@ class Demo < Processing::App
40
40
  @basis = CoordinateSystem.new(Axis.new(x_basis_vector,x_range), Axis.new(y_basis_vector,y_range), [[1,0],[0,1]], self)
41
41
  screen_transform = Transform.new({:x => 3, :y => -2}, {:x => 300, :y => 900})
42
42
  @screen = Screen.new(screen_transform, self, @basis)
43
- @screen.join=true
44
43
  @screen.draw_axes(10,10)
45
44
  stroke(1,1,0,1)
46
45
  fill(1,1,0)
data/lib/interactive.rb CHANGED
@@ -5,12 +5,25 @@ module Interactive
5
5
  def self.included(base)
6
6
  base.class_eval do
7
7
  alias :old_setup :setup
8
+ alias :old_draw :draw
8
9
  def setup
9
- puts "LoL"
10
10
  old_setup
11
11
  @index = @screen.build
12
12
  @cache = Cache.new(self).refresh
13
13
  end
14
+
15
+ def draw
16
+ old_draw
17
+ @screen.join = false
18
+ @old_points ||= []
19
+ @points_to_highlight ||= []
20
+ @cache.restore if @old_points.count > 0
21
+ @points_to_highlight.each do |new_rectangle|
22
+ @screen.plot(new_rectangle) {|p| @highlight_block.call(p) if @highlight_block}
23
+ @screen.draw_crosshairs(new_rectangle)
24
+ end
25
+ @old_points = @points_to_highlight
26
+ end
14
27
  end
15
28
  end
16
29
 
@@ -21,6 +34,7 @@ module Interactive
21
34
  original_point = @screen.original(p)
22
35
  closest_point = @index.nearest([original_point[:x], original_point[:y]])
23
36
  closest = @screen.points[closest_point[:id]]
37
+ return if closest.nil?
24
38
  closest_onscreen_point = @screen.transformed(closest)
25
39
  distance = (closest_onscreen_point[:x] - p[:x])**2 + (closest_onscreen_point[:y] - p[:y])**2
26
40
  if distance > 14.0
@@ -33,19 +47,5 @@ module Interactive
33
47
  redraw
34
48
  end
35
49
 
36
- def draw
37
- @screen.join = false
38
- @old_points ||= []
39
- @points_to_highlight ||= []
40
- @cache.restore if @old_points.count > 0
41
- # @old_points.each do |old|
42
- # @screen.plot(old) {|p| @passive_block.call(p) if @passive_block}
43
- # end
44
- @points_to_highlight.each do |new_rectangle|
45
- @screen.plot(new_rectangle) {|p| @highlight_block.call(p) if @highlight_block}
46
- @screen.draw_crosshairs(new_rectangle)
47
- end
48
- @old_points = @points_to_highlight
49
- end
50
50
  end
51
51
 
data/lib/screen.rb CHANGED
@@ -18,7 +18,6 @@ class Screen
18
18
  @points = []
19
19
  @data = []
20
20
  @output = output
21
- p output
22
21
  end
23
22
 
24
23
  def build
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basis-processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: knnball
16
- requirement: &8852080 !ruby/object:Gem::Requirement
16
+ requirement: &20813600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.0.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *8852080
24
+ version_requirements: *20813600
25
25
  description: Basis provides a set of classes for easily plotting and transforming
26
26
  arbitrary 2D coordinate systems by specifying their basis vectors in Ruby-Processing.
27
27
  email: avishek.sen.gupta@gmail.com