basis-processing 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/basis.gemspec +1 -1
- data/lib/demo.rb +2 -2
- data/lib/screen.rb +2 -2
- data/lib/transform.rb +4 -0
- metadata +4 -4
data/basis.gemspec
CHANGED
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 =>
|
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:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
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-
|
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.
|