text2path 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +11 -1
- data/lib/text2path/glyph.rb +1 -3
- data/lib/text2path/svg_font.rb +13 -3
- data/lib/text2path/version.rb +1 -1
- metadata +2 -47
- data/lib/ext/savage/LICENSE +0 -20
- data/lib/ext/savage/README.rdoc +0 -108
- data/lib/ext/savage/Rakefile +0 -39
- data/lib/ext/savage/VERSION +0 -1
- data/lib/ext/savage/lib/savage.rb +0 -3
- data/lib/ext/savage/lib/savage/direction.rb +0 -42
- data/lib/ext/savage/lib/savage/direction_proxy.rb +0 -19
- data/lib/ext/savage/lib/savage/directions/arc_to.rb +0 -29
- data/lib/ext/savage/lib/savage/directions/close_path.rb +0 -18
- data/lib/ext/savage/lib/savage/directions/coordinate_target.rb +0 -17
- data/lib/ext/savage/lib/savage/directions/cubic_curve_to.rb +0 -40
- data/lib/ext/savage/lib/savage/directions/horizontal_to.rb +0 -19
- data/lib/ext/savage/lib/savage/directions/line_to.rb +0 -15
- data/lib/ext/savage/lib/savage/directions/move_to.rb +0 -15
- data/lib/ext/savage/lib/savage/directions/point_target.rb +0 -17
- data/lib/ext/savage/lib/savage/directions/quadratic_curve_to.rb +0 -44
- data/lib/ext/savage/lib/savage/directions/vertical_to.rb +0 -19
- data/lib/ext/savage/lib/savage/parser.rb +0 -108
- data/lib/ext/savage/lib/savage/path.rb +0 -50
- data/lib/ext/savage/lib/savage/sub_path.rb +0 -54
- data/lib/ext/savage/lib/savage/transformable.rb +0 -48
- data/lib/ext/savage/lib/savage/utils.rb +0 -7
- data/lib/ext/savage/savage.gemspec +0 -80
- data/lib/ext/savage/spec/savage/directions/arc_to_spec.rb +0 -97
- data/lib/ext/savage/spec/savage/directions/close_path_spec.rb +0 -30
- data/lib/ext/savage/spec/savage/directions/cubic_curve_to_spec.rb +0 -146
- data/lib/ext/savage/spec/savage/directions/horizontal_to_spec.rb +0 -10
- data/lib/ext/savage/spec/savage/directions/line_to_spec.rb +0 -10
- data/lib/ext/savage/spec/savage/directions/move_to_spec.rb +0 -10
- data/lib/ext/savage/spec/savage/directions/point_spec.rb +0 -12
- data/lib/ext/savage/spec/savage/directions/quadratic_curve_spec.rb +0 -123
- data/lib/ext/savage/spec/savage/directions/vertical_to_spec.rb +0 -10
- data/lib/ext/savage/spec/savage/parser_spec.rb +0 -250
- data/lib/ext/savage/spec/savage/path_spec.rb +0 -105
- data/lib/ext/savage/spec/savage/sub_path_spec.rb +0 -195
- data/lib/ext/savage/spec/savage/transformable_spec.rb +0 -62
- data/lib/ext/savage/spec/savage_spec.rb +0 -5
- data/lib/ext/savage/spec/shared/command.rb +0 -13
- data/lib/ext/savage/spec/shared/coordinate_target.rb +0 -36
- data/lib/ext/savage/spec/shared/direction.rb +0 -29
- data/lib/ext/savage/spec/shared/point_target.rb +0 -45
- data/lib/ext/savage/spec/spec_helper.rb +0 -36
- data/libpeerconnection.log +0 -0
- data/out.svg +0 -1
- data/test.rb +0 -6
@@ -1,80 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "savage"
|
8
|
-
s.version = "1.2.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jeremy Holland"]
|
12
|
-
s.date = "2013-01-10"
|
13
|
-
s.description = "A little gem for extracting and manipulating SVG vector path data."
|
14
|
-
s.email = "jeremy@jeremypholland.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".rspec",
|
22
|
-
"LICENSE",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/savage.rb",
|
27
|
-
"lib/savage/direction.rb",
|
28
|
-
"lib/savage/direction_proxy.rb",
|
29
|
-
"lib/savage/directions/arc_to.rb",
|
30
|
-
"lib/savage/directions/close_path.rb",
|
31
|
-
"lib/savage/directions/coordinate_target.rb",
|
32
|
-
"lib/savage/directions/cubic_curve_to.rb",
|
33
|
-
"lib/savage/directions/horizontal_to.rb",
|
34
|
-
"lib/savage/directions/line_to.rb",
|
35
|
-
"lib/savage/directions/move_to.rb",
|
36
|
-
"lib/savage/directions/point_target.rb",
|
37
|
-
"lib/savage/directions/quadratic_curve_to.rb",
|
38
|
-
"lib/savage/directions/vertical_to.rb",
|
39
|
-
"lib/savage/parser.rb",
|
40
|
-
"lib/savage/path.rb",
|
41
|
-
"lib/savage/sub_path.rb",
|
42
|
-
"lib/savage/utils.rb",
|
43
|
-
"savage.gemspec",
|
44
|
-
"spec/savage/directions/arc_to_spec.rb",
|
45
|
-
"spec/savage/directions/close_path_spec.rb",
|
46
|
-
"spec/savage/directions/cubic_curve_to_spec.rb",
|
47
|
-
"spec/savage/directions/horizontal_to_spec.rb",
|
48
|
-
"spec/savage/directions/line_to_spec.rb",
|
49
|
-
"spec/savage/directions/move_to_spec.rb",
|
50
|
-
"spec/savage/directions/point_spec.rb",
|
51
|
-
"spec/savage/directions/quadratic_curve_spec.rb",
|
52
|
-
"spec/savage/directions/vertical_to_spec.rb",
|
53
|
-
"spec/savage/parser_spec.rb",
|
54
|
-
"spec/savage/path_spec.rb",
|
55
|
-
"spec/savage/sub_path_spec.rb",
|
56
|
-
"spec/savage_spec.rb",
|
57
|
-
"spec/shared/command.rb",
|
58
|
-
"spec/shared/coordinate_target.rb",
|
59
|
-
"spec/shared/direction.rb",
|
60
|
-
"spec/shared/point_target.rb",
|
61
|
-
"spec/spec_helper.rb"
|
62
|
-
]
|
63
|
-
s.homepage = "http://github.com/awebneck/savage"
|
64
|
-
s.require_paths = ["lib"]
|
65
|
-
s.rubygems_version = "1.8.24"
|
66
|
-
s.summary = "A little library to manipulate SVG path data"
|
67
|
-
|
68
|
-
if s.respond_to? :specification_version then
|
69
|
-
s.specification_version = 3
|
70
|
-
|
71
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
72
|
-
s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
|
73
|
-
else
|
74
|
-
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
75
|
-
end
|
76
|
-
else
|
77
|
-
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
include Savage::Directions
|
4
|
-
|
5
|
-
describe ArcTo do
|
6
|
-
def dir_class; ArcTo; end
|
7
|
-
def create_relative; ArcTo.new(100,200,300,true,false,400,500,false); end
|
8
|
-
def command_code; 'a'; end
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
@dir = dir_class.new(100,200,300,true,false,400,500)
|
12
|
-
end
|
13
|
-
|
14
|
-
include Command
|
15
|
-
it_behaves_like 'Direction'
|
16
|
-
|
17
|
-
it 'should have a target' do
|
18
|
-
@dir.respond_to?(:target).should == true
|
19
|
-
@dir.target.class.should == Point
|
20
|
-
end
|
21
|
-
it 'should have a radius' do
|
22
|
-
@dir.respond_to?(:radius).should == true
|
23
|
-
@dir.radius.class.should == Point
|
24
|
-
end
|
25
|
-
it 'should have a large arc based on the constructor argument' do
|
26
|
-
@dir.respond_to?(:large_arc).should == true
|
27
|
-
@dir.large_arc.should == true
|
28
|
-
end
|
29
|
-
it 'should have a sweep based on the constructor argument' do
|
30
|
-
@dir.respond_to?(:sweep).should == true
|
31
|
-
@dir.sweep.should == false
|
32
|
-
end
|
33
|
-
it 'should have a rotation based on the constructor arugment' do
|
34
|
-
@dir.respond_to?(:rotation).should == true
|
35
|
-
@dir.rotation.should == 300
|
36
|
-
end
|
37
|
-
it 'should have an accessible target x, based on the constructor argument' do
|
38
|
-
@dir.target.x.should == 400
|
39
|
-
end
|
40
|
-
it 'should have an accessible target y, based on the constructor argument' do
|
41
|
-
@dir.target.y.should == 500
|
42
|
-
end
|
43
|
-
it 'should have an accessible x radius, based on the constructor argument' do
|
44
|
-
@dir.radius.x.should == 100
|
45
|
-
end
|
46
|
-
it 'should have an accessible y radius, based on the constructor argument' do
|
47
|
-
@dir.radius.y.should == 200
|
48
|
-
end
|
49
|
-
it 'should be constructed with at least x and y radii, rotation, large arc, sweep, and target x and y parameters' do
|
50
|
-
lambda { dir_class.new }.should raise_error
|
51
|
-
lambda { dir_class.new 45 }.should raise_error
|
52
|
-
lambda { dir_class.new 45, 50 }.should raise_error
|
53
|
-
lambda { dir_class.new 45, 50, 60 }.should raise_error
|
54
|
-
lambda { dir_class.new 45, 50, 60, true }.should raise_error
|
55
|
-
lambda { dir_class.new 45, 50, 60, true, true }.should raise_error
|
56
|
-
lambda { dir_class.new 45, 50, 60, true, true, 100 }.should raise_error
|
57
|
-
lambda { dir_class.new 45, 50, 60, true, true, 100, 200 }.should_not raise_error
|
58
|
-
end
|
59
|
-
it 'should be relative if constructed with a false eighth parameter' do
|
60
|
-
direction = dir_class.new 45, 50, 60, true, true, 100, 200, false
|
61
|
-
direction.absolute?.should == false
|
62
|
-
end
|
63
|
-
it 'should be absolute if constructed with a true eighth parameter' do
|
64
|
-
direction = dir_class.new 45, 50, 60, true, true, 100, 200, true
|
65
|
-
direction.absolute?.should == true
|
66
|
-
end
|
67
|
-
it 'should be absolute if constructed with only seven parameters' do
|
68
|
-
direction = dir_class.new 45, 50, 60, true, true, 100, 200
|
69
|
-
direction.absolute?.should == true
|
70
|
-
end
|
71
|
-
describe '#to_command' do
|
72
|
-
it 'should have exactly 7 numerical parameters' do
|
73
|
-
extract_coordinates(@dir.to_command).length.should == 7
|
74
|
-
end
|
75
|
-
it 'should show the provided x radius value as the first parameter' do
|
76
|
-
extract_coordinates(@dir.to_command)[0].should == 100
|
77
|
-
end
|
78
|
-
it 'should show the provided y radius value as the second parameter' do
|
79
|
-
extract_coordinates(@dir.to_command)[1].should == 200
|
80
|
-
end
|
81
|
-
it 'should show the provided rotation value as the third parameter' do
|
82
|
-
extract_coordinates(@dir.to_command)[2].should == 300
|
83
|
-
end
|
84
|
-
it 'should show the integer interpretation of the provided large arc value as the fourth parameter' do
|
85
|
-
extract_coordinates(@dir.to_command)[3].should == 1
|
86
|
-
end
|
87
|
-
it 'should show the integer interpretation of the provided sweep value as the fifth parameter' do
|
88
|
-
extract_coordinates(@dir.to_command)[4].should == 0
|
89
|
-
end
|
90
|
-
it 'should show the provided target x value as the sixth parameter' do
|
91
|
-
extract_coordinates(@dir.to_command)[5].should == 400
|
92
|
-
end
|
93
|
-
it 'should show the provided target y value as the seventh parameter' do
|
94
|
-
extract_coordinates(@dir.to_command)[6].should == 500
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
include Savage::Directions
|
4
|
-
|
5
|
-
describe ClosePath do
|
6
|
-
before :each do
|
7
|
-
@dir = ClosePath.new()
|
8
|
-
end
|
9
|
-
def create_relative; ClosePath.new(false); end
|
10
|
-
def command_code; 'z'; end
|
11
|
-
include Command
|
12
|
-
it_behaves_like 'Direction'
|
13
|
-
it 'should be constructed with with either no parameters or a single boolean parameter' do
|
14
|
-
lambda { ClosePath.new }.should_not raise_error
|
15
|
-
lambda { ClosePath.new true }.should_not raise_error
|
16
|
-
lambda { ClosePath.new 45, 50 }.should raise_error
|
17
|
-
end
|
18
|
-
it 'should be relative if constructed with a false parameter' do
|
19
|
-
direction = ClosePath.new(false)
|
20
|
-
direction.absolute?.should == false
|
21
|
-
end
|
22
|
-
it 'should be absolute if constructed with a false parameter' do
|
23
|
-
direction = ClosePath.new(true)
|
24
|
-
direction.absolute?.should == true
|
25
|
-
end
|
26
|
-
it 'should be absolute if constructed with no parameters' do
|
27
|
-
direction = ClosePath.new()
|
28
|
-
direction.absolute?.should == true
|
29
|
-
end
|
30
|
-
end
|
@@ -1,146 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
include Savage::Directions
|
4
|
-
|
5
|
-
describe CubicCurveTo do
|
6
|
-
def dir_class; CubicCurveTo; end
|
7
|
-
def create_relative; CubicCurveTo.new(100,200,300,400,500,600,false); end
|
8
|
-
def command_code; 'c'; end
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
@dir = dir_class.new(100,200,300,400,500,600)
|
12
|
-
end
|
13
|
-
|
14
|
-
include Command
|
15
|
-
it_behaves_like 'Direction'
|
16
|
-
|
17
|
-
it 'should have a target' do
|
18
|
-
@dir.respond_to?(:target).should == true
|
19
|
-
@dir.target.class.should == Point
|
20
|
-
end
|
21
|
-
it 'should have a control point' do
|
22
|
-
@dir.respond_to?(:control).should == true
|
23
|
-
@dir.control.class.should == Point
|
24
|
-
end
|
25
|
-
it 'should have an accessible target x, based on the constructor argument' do
|
26
|
-
@dir.target.x.should == 500
|
27
|
-
end
|
28
|
-
it 'should have an accessible target y, based on the constructor argument' do
|
29
|
-
@dir.target.y.should == 600
|
30
|
-
end
|
31
|
-
it 'should have an accessible second control x, based on the constructor argument' do
|
32
|
-
@dir.control_2.x.should == 300
|
33
|
-
end
|
34
|
-
it 'should have an accessible second control y, based on the constructor argument' do
|
35
|
-
@dir.control_2.y.should == 400
|
36
|
-
end
|
37
|
-
context 'when in verbose format' do
|
38
|
-
it 'should be constructed with at least target x and y, control 1 x and y, and control 2 x and y parameters' do
|
39
|
-
lambda { dir_class.new }.should raise_error
|
40
|
-
lambda { dir_class.new 45 }.should raise_error
|
41
|
-
lambda { dir_class.new 45, 50 }.should raise_error
|
42
|
-
lambda { dir_class.new 45, 50, 60 }.should raise_error
|
43
|
-
lambda { dir_class.new 45, 50, 60, 70, 80 }.should raise_error
|
44
|
-
lambda { dir_class.new 45, 50, 60, 70, 80, 90 }.should_not raise_error
|
45
|
-
lambda { dir_class.new 45, 50, 60, 70, 80, 90, true }.should_not raise_error
|
46
|
-
end
|
47
|
-
it 'should be relative if constructed with a false seventh parameter' do
|
48
|
-
direction = dir_class.new 45, 50, 60, 70, 80, 90, false
|
49
|
-
direction.absolute?.should == false
|
50
|
-
end
|
51
|
-
it 'should be absolute if constructed with a true seventh parameter' do
|
52
|
-
direction = dir_class.new 45, 50, 60, 70, 80, 90, true
|
53
|
-
direction.absolute?.should == true
|
54
|
-
end
|
55
|
-
it 'should be absolute if constructed with only six parameters' do
|
56
|
-
direction = dir_class.new 45, 50, 60, 70, 80, 90
|
57
|
-
direction.absolute?.should == true
|
58
|
-
end
|
59
|
-
it 'should have an accessible first control x, based on the constructor argument' do
|
60
|
-
@dir.control_1.x.should == 100
|
61
|
-
end
|
62
|
-
it 'should have an accessible first control y, based on the constructor argument' do
|
63
|
-
@dir.control_1.y.should == 200
|
64
|
-
end
|
65
|
-
describe '#to_command' do
|
66
|
-
it 'should start with a lower-case c when not absolute' do
|
67
|
-
extract_command(CubicCurveTo.new(100,200,300,400,500,600,false).to_command).should == 'c'
|
68
|
-
end
|
69
|
-
it 'should start with a capital C when absolute' do
|
70
|
-
extract_command(@dir.to_command).should == 'C'
|
71
|
-
end
|
72
|
-
it 'should have exactly 6 numerical parameters' do
|
73
|
-
extract_coordinates(@dir.to_command).length.should == 6
|
74
|
-
end
|
75
|
-
it 'should show the provided first control X value as the first parameter' do
|
76
|
-
extract_coordinates(@dir.to_command)[0].should == 100
|
77
|
-
end
|
78
|
-
it 'should show the provided first control Y value as the second parameter' do
|
79
|
-
extract_coordinates(@dir.to_command)[1].should == 200
|
80
|
-
end
|
81
|
-
it 'should show the provided second control X value as the third parameter' do
|
82
|
-
extract_coordinates(@dir.to_command)[2].should == 300
|
83
|
-
end
|
84
|
-
it 'should show the provided second control Y value as the fourth parameter' do
|
85
|
-
extract_coordinates(@dir.to_command)[3].should == 400
|
86
|
-
end
|
87
|
-
it 'should show the provided target X value as the fifth parameter' do
|
88
|
-
extract_coordinates(@dir.to_command)[4].should == 500
|
89
|
-
end
|
90
|
-
it 'should show the provided target Y value as the sixth parameter' do
|
91
|
-
extract_coordinates(@dir.to_command)[5].should == 600
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
context 'when in shorthand format' do
|
96
|
-
before :each do
|
97
|
-
@dir = CubicCurveTo.new(100,200,300,400)
|
98
|
-
end
|
99
|
-
it 'should be constructed with at least target x and y parameters' do
|
100
|
-
lambda { dir_class.new }.should raise_error
|
101
|
-
lambda { dir_class.new 45 }.should raise_error
|
102
|
-
lambda { dir_class.new 45, 50 }.should raise_error
|
103
|
-
lambda { dir_class.new 45, 50, 60 }.should raise_error
|
104
|
-
lambda { dir_class.new 45, 50, 60, 70 }.should_not raise_error
|
105
|
-
lambda { dir_class.new 45, 50, 60, 70, true }.should_not raise_error
|
106
|
-
end
|
107
|
-
it 'should be relative if constructed with a false third parameter' do
|
108
|
-
direction = dir_class.new 45, 50, 60, 70, false
|
109
|
-
direction.absolute?.should == false
|
110
|
-
end
|
111
|
-
it 'should be absolute if constructed with a true third parameter' do
|
112
|
-
direction = dir_class.new 45, 50, 60, 70, true
|
113
|
-
direction.absolute?.should == true
|
114
|
-
end
|
115
|
-
it 'should be absolute if constructed with only two parameters' do
|
116
|
-
direction = dir_class.new 45, 50, 60, 70
|
117
|
-
direction.absolute?.should == true
|
118
|
-
end
|
119
|
-
it 'should have an nil first control, based on the constructor argument' do
|
120
|
-
@dir.control_1.should == nil
|
121
|
-
end
|
122
|
-
describe '#to_command' do
|
123
|
-
it 'should start with a lower-case s when not absolute' do
|
124
|
-
extract_command(CubicCurveTo.new(100,200,300,400,false).to_command).should == 's'
|
125
|
-
end
|
126
|
-
it 'should start with a capital S when absolute' do
|
127
|
-
extract_command(@dir.to_command).should == 'S'
|
128
|
-
end
|
129
|
-
it 'should have exactly 2 numerical parameters' do
|
130
|
-
extract_coordinates(@dir.to_command).length.should == 4
|
131
|
-
end
|
132
|
-
it 'should show the provided second control X value as the first parameter' do
|
133
|
-
extract_coordinates(@dir.to_command)[0].should == 100
|
134
|
-
end
|
135
|
-
it 'should show the provided second control Y value as the second parameter' do
|
136
|
-
extract_coordinates(@dir.to_command)[1].should == 200
|
137
|
-
end
|
138
|
-
it 'should show the provided target X value as the third parameter' do
|
139
|
-
extract_coordinates(@dir.to_command)[2].should == 300
|
140
|
-
end
|
141
|
-
it 'should show the provided target Y value as the fourth parameter' do
|
142
|
-
extract_coordinates(@dir.to_command)[3].should == 400
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
include Savage::Directions
|
4
|
-
|
5
|
-
describe HorizontalTo do
|
6
|
-
def dir_class; HorizontalTo; end
|
7
|
-
def create_relative; HorizontalTo.new(100,false); end
|
8
|
-
def command_code; 'h'; end
|
9
|
-
it_behaves_like 'CoordinateTarget'
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
include Savage::Directions
|
4
|
-
|
5
|
-
describe LineTo do
|
6
|
-
def dir_class; LineTo; end
|
7
|
-
def create_relative; LineTo.new(100,200,false); end
|
8
|
-
def command_code; 'l'; end
|
9
|
-
it_behaves_like 'PointTarget'
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
include Savage::Directions
|
4
|
-
|
5
|
-
describe MoveTo do
|
6
|
-
def dir_class; MoveTo; end
|
7
|
-
def create_relative; MoveTo.new(100,200,false); end
|
8
|
-
def command_code; 'm'; end
|
9
|
-
it_behaves_like 'PointTarget'
|
10
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
include Savage::Directions
|
4
|
-
|
5
|
-
describe Point do
|
6
|
-
it 'should have an x' do
|
7
|
-
Point.new.respond_to?(:x).should == true;
|
8
|
-
end
|
9
|
-
it 'should have an y' do
|
10
|
-
Point.new.respond_to?(:y).should == true;
|
11
|
-
end
|
12
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
include Savage::Directions
|
4
|
-
|
5
|
-
describe QuadraticCurveTo do
|
6
|
-
def dir_class; QuadraticCurveTo; end
|
7
|
-
def create_relative; QuadraticCurveTo.new(100,200,300,400,false); end
|
8
|
-
def command_code; 'q'; end
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
@dir = dir_class.new(100,200,300,400)
|
12
|
-
end
|
13
|
-
|
14
|
-
include Command
|
15
|
-
it_behaves_like 'Direction'
|
16
|
-
|
17
|
-
it 'should have a target' do
|
18
|
-
@dir.respond_to?(:target).should == true
|
19
|
-
@dir.target.class.should == Point
|
20
|
-
end
|
21
|
-
it 'should have a control point' do
|
22
|
-
@dir.respond_to?(:control).should == true
|
23
|
-
@dir.control.class.should == Point
|
24
|
-
end
|
25
|
-
it 'should have an accessible target x, based on the constructor argument' do
|
26
|
-
@dir.target.x.should == 300
|
27
|
-
end
|
28
|
-
it 'should have an accessible target y, based on the constructor argument' do
|
29
|
-
@dir.target.y.should == 400
|
30
|
-
end
|
31
|
-
context 'when in verbose format' do
|
32
|
-
it 'should be constructed with at least target x and y and control x and y parameters' do
|
33
|
-
lambda { dir_class.new }.should raise_error
|
34
|
-
lambda { dir_class.new 45 }.should raise_error
|
35
|
-
lambda { dir_class.new 45, 50, 60 }.should raise_error
|
36
|
-
lambda { dir_class.new 45, 50, 60, 70 }.should_not raise_error
|
37
|
-
lambda { dir_class.new 45, 50, 60, 70, true }.should_not raise_error
|
38
|
-
end
|
39
|
-
it 'should be relative if constructed with a false fifth parameter' do
|
40
|
-
direction = dir_class.new 45, 50, 60, 70, false
|
41
|
-
direction.absolute?.should == false
|
42
|
-
end
|
43
|
-
it 'should be absolute if constructed with a true fifth parameter' do
|
44
|
-
direction = dir_class.new 45, 50, 60, 70, true
|
45
|
-
direction.absolute?.should == true
|
46
|
-
end
|
47
|
-
it 'should be absolute if constructed with only four parameters' do
|
48
|
-
direction = dir_class.new 45, 50, 60, 70
|
49
|
-
direction.absolute?.should == true
|
50
|
-
end
|
51
|
-
it 'should have an accessible first control x, based on the constructor argument' do
|
52
|
-
@dir.control.x.should == 100
|
53
|
-
end
|
54
|
-
it 'should have an accessible first control y, based on the constructor argument' do
|
55
|
-
@dir.control.y.should == 200
|
56
|
-
end
|
57
|
-
describe '#to_command' do
|
58
|
-
it 'should start with a lower-case q when not absolute' do
|
59
|
-
extract_command(QuadraticCurveTo.new(100,200,300,400,false).to_command).should == 'q'
|
60
|
-
end
|
61
|
-
it 'should start with a capital Q when absolute' do
|
62
|
-
extract_command(@dir.to_command).should == 'Q'
|
63
|
-
end
|
64
|
-
it 'should have exactly 4 numerical parameters' do
|
65
|
-
extract_coordinates(@dir.to_command).length.should == 4
|
66
|
-
end
|
67
|
-
it 'should show the provided control X value as the first parameter' do
|
68
|
-
extract_coordinates(@dir.to_command)[0].should == 100
|
69
|
-
end
|
70
|
-
it 'should show the provided control Y value as the second parameter' do
|
71
|
-
extract_coordinates(@dir.to_command)[1].should == 200
|
72
|
-
end
|
73
|
-
it 'should show the provided target X value as the third parameter' do
|
74
|
-
extract_coordinates(@dir.to_command)[2].should == 300
|
75
|
-
end
|
76
|
-
it 'should show the provided target Y value as the fourth parameter' do
|
77
|
-
extract_coordinates(@dir.to_command)[3].should == 400
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
context 'when in shorthand format' do
|
82
|
-
before :each do
|
83
|
-
@dir = QuadraticCurveTo.new(100,200)
|
84
|
-
end
|
85
|
-
it 'should be constructed with at least target x and y parameters' do
|
86
|
-
lambda { dir_class.new }.should raise_error
|
87
|
-
lambda { dir_class.new 45 }.should raise_error
|
88
|
-
lambda { dir_class.new 45, 50 }.should_not raise_error
|
89
|
-
end
|
90
|
-
it 'should be relative if constructed with a false third parameter' do
|
91
|
-
direction = dir_class.new 45, 50, false
|
92
|
-
direction.absolute?.should == false
|
93
|
-
end
|
94
|
-
it 'should be absolute if constructed with a true third parameter' do
|
95
|
-
direction = dir_class.new 45, 50, true
|
96
|
-
direction.absolute?.should == true
|
97
|
-
end
|
98
|
-
it 'should be absolute if constructed with only two parameters' do
|
99
|
-
direction = dir_class.new 45, 50
|
100
|
-
direction.absolute?.should == true
|
101
|
-
end
|
102
|
-
it 'should have an nil control, based on the constructor argument' do
|
103
|
-
@dir.control.should == nil
|
104
|
-
end
|
105
|
-
describe '#to_command' do
|
106
|
-
it 'should start with a lower-case t when not absolute' do
|
107
|
-
extract_command(QuadraticCurveTo.new(100,200,false).to_command).should == 't'
|
108
|
-
end
|
109
|
-
it 'should start with a capital T when absolute' do
|
110
|
-
extract_command(@dir.to_command).should == 'T'
|
111
|
-
end
|
112
|
-
it 'should have exactly 2 numerical parameters' do
|
113
|
-
extract_coordinates(@dir.to_command).length.should == 2
|
114
|
-
end
|
115
|
-
it 'should show the provided target X value as the first parameter' do
|
116
|
-
extract_coordinates(@dir.to_command)[0].should == 100
|
117
|
-
end
|
118
|
-
it 'should show the provided target Y value as the second parameter' do
|
119
|
-
extract_coordinates(@dir.to_command)[1].should == 200
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|