basis-processing 0.4.3 → 0.4.4
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 +1 -1
- data/lib/coordinate_system.rb +0 -10
- data/lib/demo.rb +6 -4
- data/lib/screen.rb +10 -2
- metadata +3 -3
data/basis.gemspec
CHANGED
data/lib/coordinate_system.rb
CHANGED
@@ -40,20 +40,10 @@ class CoordinateSystem
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def tick_vectors
|
43
|
-
unnormalised_vectors =
|
44
43
|
{
|
45
44
|
:x_tick_vector => MatrixOperations::into2Dx1D(rotation(-90),@x_basis_vector),
|
46
45
|
:y_tick_vector => MatrixOperations::into2Dx1D(rotation(90),@y_basis_vector)
|
47
46
|
}
|
48
|
-
{
|
49
|
-
:x_tick_vector => normal(unnormalised_vectors[:x_tick_vector]),
|
50
|
-
:y_tick_vector => normal(unnormalised_vectors[:y_tick_vector])
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
def normal(vector)
|
55
|
-
magnitude = sqrt(vector[:x]**2 + vector[:y]**2)
|
56
|
-
{:x => 5*vector[:x]/magnitude, :y => 5*vector[:y]/magnitude}
|
57
47
|
end
|
58
48
|
|
59
49
|
def sum(v1, v2)
|
data/lib/demo.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
Gem.clear_paths
|
3
|
+
ENV['GEM_HOME'] = '/home/avishek/jruby/jruby-1.6.3/lib/ruby/gems/1.8'
|
4
|
+
ENV['GEM_PATH'] = '/home/avishek/jruby/jruby-1.6.3/lib/ruby/gems/1.8'
|
5
|
+
|
6
|
+
require 'basis_processing'
|
5
7
|
|
6
8
|
class Demo < Processing::App
|
7
9
|
app = self
|
data/lib/screen.rb
CHANGED
@@ -14,14 +14,22 @@ class Screen
|
|
14
14
|
|
15
15
|
def draw_ticks(ticks, displacement)
|
16
16
|
ticks.each do |l|
|
17
|
-
from = @transform.
|
18
|
-
to = @transform.
|
17
|
+
from = @transform.apply(l[:from])
|
18
|
+
to = @transform.apply(l[:to])
|
19
|
+
tick_vector = normal(from, to)
|
20
|
+
to = {:x => from[:x] + tick_vector[:x], :y => from[:y] + tick_vector[:y]}
|
19
21
|
@artist.line(from[:x],from[:y],to[:x],to[:y])
|
20
22
|
@artist.fill(1)
|
21
23
|
@artist.text(l[:label], to[:x]+displacement[:x], to[:y]+displacement[:y])
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
27
|
+
def normal(from, to)
|
28
|
+
vector = {:x => to[:x] - from[:x], :y => to[:y] - from[:y]}
|
29
|
+
magnitude = sqrt(vector[:x]**2 + vector[:y]**2)
|
30
|
+
{:x => 5*vector[:x]/magnitude, :y => 5*vector[:y]/magnitude}
|
31
|
+
end
|
32
|
+
|
25
33
|
def draw_axes(basis, x_interval, y_interval)
|
26
34
|
f = @artist.createFont("Georgia", 24, true);
|
27
35
|
@artist.text_font(f,16)
|
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:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 4
|
10
|
+
version: 0.4.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Avishek Sen Gupta
|