basis-processing 0.4.2 → 0.4.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/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.4.2"
3
+ s.version = "0.4.3"
4
4
  s.author = "Avishek Sen Gupta"
5
5
  s.email = "avishek.sen.gupta@gmail.com"
6
6
  s.homepage = "http://avishek.net/blog"
data/lib/demo.rb CHANGED
@@ -6,7 +6,7 @@ require 'screen'
6
6
  class Demo < Processing::App
7
7
  app = self
8
8
  def setup
9
- smooth
9
+ # smooth
10
10
  background(0,0,0)
11
11
  color_mode(RGB, 1.0)
12
12
  stroke(1,1,0,1)
@@ -21,7 +21,7 @@ class Demo < Processing::App
21
21
  y_range = ContinuousRange.new({:minimum => 0, :maximum => 300})
22
22
 
23
23
  basis = CoordinateSystem.new(Axis.new(x_basis_vector,x_range), Axis.new(y_basis_vector,y_range), [[4,0],[0,2]], self)
24
- screen_transform = SignedTransform.new({:x => 10, :y => -1}, {:x => 300, :y => 900})
24
+ screen_transform = SignedTransform.new({:x => 1, :y => -1}, {:x => 300, :y => 900})
25
25
  screen = Screen.new(screen_transform, self)
26
26
  screen.draw_axes(basis,10,10)
27
27
  stroke(1,1,0,1)
data/lib/screen.rb CHANGED
@@ -14,8 +14,8 @@ class Screen
14
14
 
15
15
  def draw_ticks(ticks, displacement)
16
16
  ticks.each do |l|
17
- from = @transform.apply(l[:from])
18
- to = @transform.apply(l[:to])
17
+ from = @transform.signed.apply(l[:from])
18
+ to = @transform.signed.apply(l[:to])
19
19
  @artist.line(from[:x],from[:y],to[:x],to[:y])
20
20
  @artist.fill(1)
21
21
  @artist.text(l[:label], to[:x]+displacement[:x], to[:y]+displacement[:y])
data/lib/transform.rb CHANGED
@@ -8,6 +8,10 @@ class Transform
8
8
  def apply(p)
9
9
  { :x => @origin[:x] + p[:x] * @scale[:x], :y => @origin[:y] + p[:y] * @scale[:y]}
10
10
  end
11
+
12
+ def signed
13
+ Transform.new({:x => (@scale[:x]<=>0.0).to_i, :y => (@scale[:y]<=>0.0).to_i}, @origin)
14
+ end
11
15
  end
12
16
 
13
17
  class SignedTransform < Transform
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basis-processing
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Avishek Sen Gupta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-20 00:00:00 Z
18
+ date: 2011-09-20 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Basis provides a set of classes for easily plotting and transforming arbitrary 2D coordinate systems by specifying their basis vectors in Ruby-Processing.