prawn_shapes 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2009 Daniel Nelson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ = Shapes library for Prawn
2
+
3
+ Available thus far:
4
+ - star
5
+ - half_star
6
+ - arc
7
+ - pie_slice
8
+ - half_circle
9
+ - quarter_circle
10
+
11
+ = Usage
12
+
13
+ require 'prawn/graphics/star'
14
+
15
+ pdf.star([x, y], :radius => r)
16
+
17
+ require 'prawn/graphics/arc'
18
+
19
+ pdf.arc_around([x, y], :radius => r, :start_angle => 30, :end_angle => 60)
20
+ pdf.pie_slice([x, y], :radius => r, :start_angle => 45, :end_angle => 135)
21
+ pdf.half_circle([x, y], :radius => r, :side => :left)
22
+ pdf.quarter_circle([x, y], :radius => r, :quadrant => 3)
23
+
24
+ The built in prawn magic works:
25
+
26
+ pdf.stroke_star([x, y], :radius => r)
27
+ pdf.fill_star([x, y], :radius => r)
28
+ pdf.fill_and_stroke_star([x, y], :radius => r)
29
+
30
+ See the examples directory for further usage examples.
31
+
32
+ = Examples
33
+
34
+ stars: http://mindlev.wordpress.com/files/2009/12/star.pdf
35
+
36
+ arcs and pies: http://mindlev.wordpress.com/files/2009/12/arc1.pdf
37
+
38
+ = Changelog
39
+
40
+ 2009-12-15 - renamed semi_circle to half_circle because it seems more of a kind with quarter_circle
41
+
42
+ 2011-02-14 - fixed syntax for Ruby 1.9. incorporated Bundler
43
+
44
+ 2011-04-05 - added gemspec and published as prawn_shapes. requires Prawn 0.11.1
@@ -0,0 +1,27 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.setup
4
+
5
+ require "rake"
6
+ require "rake/testtask"
7
+
8
+ task :default => [:test]
9
+
10
+ desc "Run all tests, test-spec, mocha, and pdf-reader required"
11
+ Rake::TestTask.new do |test|
12
+ # test.ruby_opts << "-w" # .should == true triggers a lot of warnings
13
+ test.libs << "spec"
14
+ test.test_files = Dir[ "spec/*_spec.rb" ]
15
+ test.verbose = true
16
+ end
17
+
18
+ desc "run all examples"
19
+ task :examples do
20
+ mkdir_p "output"
21
+ examples = Dir["examples/**/*.rb"]
22
+ t = Time.now
23
+ puts "Running Examples"
24
+ examples.each { |file| `ruby -Ilib #{file}` }
25
+ puts "Ran in #{Time.now - t} s"
26
+ `mv *.pdf output`
27
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'prawn'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+
6
+ Prawn.debug = true
@@ -0,0 +1,131 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", ".."))
2
+ require 'examples/example_helper'
3
+ require 'prawn_shapes/arc'
4
+
5
+ Prawn::Document.generate("arc.pdf") do
6
+ radius = 75
7
+ center = [bounds.width * 0.25, bounds.height * 0.85]
8
+ self.fill_color = 'ddddff'
9
+ fill_pie_slice(center,
10
+ :radius => radius,
11
+ :start_angle => 30,
12
+ :end_angle => 110)
13
+ self.fill_color = 'ffdddd'
14
+ fill_pie_slice(center,
15
+ :radius => radius,
16
+ :start_angle => 110,
17
+ :end_angle => 130)
18
+ self.fill_color = 'ddffdd'
19
+ fill_pie_slice(center,
20
+ :radius => radius,
21
+ :start_angle => 130,
22
+ :end_angle => 30)
23
+
24
+ self.stroke_color = '0000ff'
25
+ stroke_arc_around(center,
26
+ :radius => radius,
27
+ :start_angle => 30,
28
+ :end_angle => 110)
29
+ self.stroke_color = 'ff0000'
30
+ stroke_arc_around(center,
31
+ :radius => radius,
32
+ :start_angle => 110,
33
+ :end_angle => 130)
34
+ self.stroke_color = '00ff00'
35
+ stroke_arc_around(center,
36
+ :radius => radius,
37
+ :start_angle => 130,
38
+ :end_angle => 30)
39
+
40
+
41
+ center = [bounds.width * 0.75, bounds.height * 0.85]
42
+ self.stroke_color = '7777777'
43
+ self.fill_color = 'ddddff'
44
+ fill_and_stroke_pie_slice(center,
45
+ :radius => radius,
46
+ :start_angle => 30,
47
+ :end_angle => 110)
48
+ self.fill_color = 'ffdddd'
49
+ fill_and_stroke_pie_slice(center,
50
+ :radius => radius,
51
+ :start_angle => 110,
52
+ :end_angle => 130)
53
+ self.fill_color = 'ddffdd'
54
+ fill_and_stroke_pie_slice(center,
55
+ :radius => radius,
56
+ :start_angle => 130,
57
+ :end_angle => 30)
58
+
59
+
60
+ ####### Semi-Circles
61
+ center = [bounds.width * 0.25, bounds.height * 0.60]
62
+
63
+ self.fill_color = 'ddddff'
64
+ fill_half_circle(center, :radius => radius, :side => :left)
65
+ self.fill_color = 'ffdddd'
66
+ fill_half_circle(center, :radius => radius, :side => :right)
67
+
68
+ self.stroke_color = '0000ff'
69
+ stroke_half_circle(center, :radius => radius, :side => :left)
70
+ self.stroke_color = 'ff0000'
71
+ stroke_half_circle(center, :radius => radius, :side => :right)
72
+ ####### end:Semi-Circles
73
+
74
+ ####### Quarter-Circles
75
+ center = [bounds.width * 0.75, bounds.height * 0.60]
76
+
77
+ self.fill_color = 'ddddff'
78
+ fill_quarter_circle(center, :radius => radius, :quadrant => 1)
79
+ self.fill_color = 'ffdddd'
80
+ fill_quarter_circle(center, :radius => radius, :quadrant => 2)
81
+ self.fill_color = 'ddffdd'
82
+ fill_quarter_circle(center, :radius => radius, :quadrant => 3)
83
+ self.fill_color = 'ddffff'
84
+ fill_quarter_circle(center, :radius => radius, :quadrant => 4)
85
+
86
+ self.stroke_color = '0000ff'
87
+ stroke_quarter_circle(center, :radius => radius, :quadrant => 1)
88
+ self.stroke_color = 'ff0000'
89
+ stroke_quarter_circle(center, :radius => radius, :quadrant => 2)
90
+ self.stroke_color = '00ff00'
91
+ stroke_quarter_circle(center, :radius => radius, :quadrant => 3)
92
+ self.stroke_color = '00ffff'
93
+ stroke_quarter_circle(center, :radius => radius, :quadrant => 4)
94
+
95
+ ####### end:Quarter-Circles
96
+
97
+
98
+ self.fill_color = '333333'
99
+ text_box('Notice the difference in stroking when ' +
100
+ 'using stroke_ versus fill_and_stroke:',
101
+ :at => [0, bounds.height * 0.30 + radius + 20],
102
+ :align => :center)
103
+
104
+ center = [bounds.width * 0.25, bounds.height * 0.30]
105
+ self.fill_color = 'ddddff'
106
+ stroke_quarter_circle(center,
107
+ :radius => radius,
108
+ :quadrant => 1)
109
+
110
+ center = [bounds.width * 0.75, bounds.height * 0.30]
111
+ self.fill_color = 'ffffff'
112
+ fill_and_stroke_quarter_circle(center,
113
+ :radius => radius,
114
+ :quadrant => 1)
115
+
116
+
117
+
118
+
119
+ self.fill_color = '333333'
120
+ text_box('If you want to stroke both sides when stroking ' +
121
+ 'include :stroke_both_sides => true',
122
+ :at => [0, bounds.height * 0.15 + radius + 20],
123
+ :align => :center)
124
+
125
+ center = [bounds.width * 0.5, bounds.height * 0.15]
126
+ stroke_quarter_circle(center,
127
+ :radius => radius,
128
+ :quadrant => 1,
129
+ :stroke_both_sides => true)
130
+
131
+ end
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", ".."))
2
+ require 'examples/example_helper'
3
+ require 'prawn_shapes/star'
4
+
5
+ Prawn::Document.generate("star.pdf") do
6
+ self.stroke_color = '0000ff'
7
+ stroke_star([bounds.width / 2, bounds.height * 0.75], :radius => 72)
8
+ self.fill_color = '99ff99'
9
+ fill_half_star([bounds.width / 2, bounds.height / 2],
10
+ :radius => 72, :side => :left)
11
+ self.fill_color = '9999ff'
12
+ fill_half_star([bounds.width / 2, bounds.height / 2],
13
+ :radius => 72, :side => :right)
14
+ fill_and_stroke_star([bounds.width / 2, bounds.height * 0.25], :radius => 72)
15
+ end
@@ -0,0 +1,2 @@
1
+ require "prawn_shapes/arc.rb"
2
+ require "prawn_shapes/star.rb"
@@ -0,0 +1,205 @@
1
+ module Prawn
2
+ module Graphics
3
+ # options must include :radius and :side
4
+ # side is either :left or :right
5
+ # see pie_slice for explanation of optional
6
+ # :stroke_both_sides option
7
+ #
8
+ def half_circle(center, options)
9
+ case options[:side]
10
+ when :left
11
+ start_angle = 90
12
+ end_angle = 270
13
+ when :right
14
+ start_angle = 270
15
+ end_angle = 90
16
+ end
17
+ pie_slice(center,
18
+ :radius => options[:radius],
19
+ :start_angle => start_angle,
20
+ :end_angle => end_angle,
21
+ :stroke_both_sides => options[:stroke_both_sides])
22
+ end
23
+
24
+ # options must include :radius and :quadrant
25
+ # quadrant is 1, 2, 3, or 4
26
+ # see pie_slice for explanation of optional
27
+ # :stroke_both_sides option
28
+ #
29
+ def quarter_circle(center, options)
30
+ case options[:quadrant]
31
+ when 1
32
+ start_angle = 0
33
+ end_angle = 90
34
+ when 2
35
+ start_angle = 90
36
+ end_angle = 180
37
+ when 3
38
+ start_angle = 180
39
+ end_angle = 270
40
+ when 4
41
+ start_angle = 270
42
+ end_angle = 360
43
+ end
44
+ pie_slice(center,
45
+ :radius => options[:radius],
46
+ :start_angle => start_angle,
47
+ :end_angle => end_angle,
48
+ :stroke_both_sides => options[:stroke_both_sides])
49
+ end
50
+
51
+ # options must include :radius, :start_angle, and :end_angle
52
+ # startAngle and endAngle are in degrees
53
+ # if an optional :stroke_both_sides option is true, then both
54
+ # sides of the slice will be included for stroking. the default is
55
+ # to just stroke one side since this will tend to be used to build
56
+ # up an entire circle, and if both sides were stroked, then we
57
+ # would get double-stroked lines where two pie slices shared a
58
+ # (not usually noticeable, but would be if transparency were used)
59
+ #
60
+ # 0 degrees is directly right and 90 degrees is straight up
61
+ # arc will be drawn counterclockwise from startAngle to endAngle
62
+ #
63
+ def pie_slice(center, options)
64
+ vertices = arc_vertices(center, options)
65
+ vertices.unshift(:point => center)
66
+ if options[:stroke_both_sides]
67
+ closed_curve(vertices)
68
+ else
69
+ open_curve(vertices)
70
+ end
71
+ end
72
+
73
+ # options must include :radius, :start_angle, and :end_angle
74
+ # startAngle and endAngle are in degrees
75
+ #
76
+ # 0 degrees is directly right and 90 degrees is straight up
77
+ # arc will be drawn counterclockwise from startAngle to endAngle
78
+ #
79
+ def arc_around(center, options)
80
+ open_curve(arc_vertices(center, options))
81
+ end
82
+
83
+ # vertices is an array of hashes containing :vertex and optional
84
+ # :handle1 and :handle2 elements
85
+ def open_curve(vertices)
86
+ return if vertices.empty?
87
+ vertices = vertices.dup
88
+ origin = vertices.shift
89
+ move_to(origin[:point])
90
+ previous_handle2 = origin[:handle2]
91
+ vertices.each do |vertex|
92
+ curve_to(vertex[:point],
93
+ :bounds => [previous_handle2 || vertex[:point],
94
+ vertex[:handle1] || vertex[:point]])
95
+ previous_handle2 = vertex[:handle2]
96
+ end
97
+ end
98
+
99
+ # vertices is an array of hashes containing :vertex and optional
100
+ # :handle1 and :handle2 elements
101
+ def closed_curve(vertices)
102
+ return if vertices.empty?
103
+ vertices = vertices.dup
104
+ origin = vertices.shift
105
+ move_to(origin[:point])
106
+ previous_handle2 = origin[:handle2]
107
+ vertices.each do |vertex|
108
+ curve_to(vertex[:point],
109
+ :bounds => [previous_handle2 || vertex[:point],
110
+ vertex[:handle1] || vertex[:point]])
111
+ previous_handle2 = vertex[:handle2]
112
+ end
113
+ curve_to(origin[:point],
114
+ :bounds => [previous_handle2 || origin[:point],
115
+ origin[:handle1] || origin[:point]])
116
+ end
117
+
118
+ private
119
+
120
+ def arc_vertices(center, options)
121
+ radius = options[:radius]
122
+ start_degrees = options[:start_angle]
123
+ end_degrees = options[:end_angle]
124
+ return if start_degrees == end_degrees
125
+
126
+ overall_start_angle = (start_degrees % 360.0).to_radians
127
+ overall_end_angle = (end_degrees % 360.0).to_radians
128
+
129
+ # if the angles are now equal, when they weren't before, then
130
+ # they describe an entire circle
131
+ return circle_at(center, :radius => radius) if overall_start_angle == overall_end_angle
132
+
133
+ overall_end_angle = overall_end_angle + 2.0 * Math::PI if overall_end_angle < overall_start_angle
134
+
135
+ delta = overall_end_angle - overall_start_angle
136
+ quadrants = (delta / (Math::PI * 0.5)).ceil
137
+
138
+ vertices = []
139
+ quadrants.times do |i|
140
+ start_angle = overall_start_angle + Math::PI * 0.5 * i
141
+
142
+ if i == quadrants - 1 then end_angle = overall_end_angle
143
+ else end_angle = start_angle + Math::PI * 0.5
144
+ end
145
+
146
+ delta = end_angle - start_angle
147
+ handle_multiplier = KAPPA * delta / (Math::PI * 0.5) * radius
148
+
149
+ # negate the angles so as to get the stated orientation of angles
150
+ # start_angle = -start_angle
151
+ # end_angle = -end_angle
152
+
153
+ vertex = {}
154
+ point = [Math.cos(start_angle), Math.sin(start_angle)]
155
+ vertex[:point] = [center[0] + radius * point[0],
156
+ center[1] + radius * point[1]]
157
+ handle = point.unit_perpendicular_vector(:counter_clockwise => false)
158
+ vertex[:handle2] = [vertex[:point][0] + handle_multiplier * handle[0],
159
+ vertex[:point][1] + handle_multiplier * handle[1]]
160
+
161
+ #fill_circle_at(center, :radius => 10)
162
+ #fill_circle_at(vertex[:point], :radius => 10)
163
+ #stroke_circle_at(vertex[:handle2], :radius => 10)
164
+ # stroke_line(vertex[:point], vertex[:handle1])
165
+ vertices << vertex
166
+
167
+ vertex = {}
168
+ point = [Math.cos(end_angle), Math.sin(end_angle)]
169
+ vertex[:point] = [center[0] + radius * point[0],
170
+ center[1] + radius * point[1]]
171
+ handle = point.unit_perpendicular_vector(:counter_clockwise => true)
172
+ vertex[:handle1] = [vertex[:point][0] + handle_multiplier * handle[0],
173
+ vertex[:point][1] + handle_multiplier * handle[1]]
174
+ #fill_circle_at(vertex[:point], :radius => 10)
175
+ #fill_and_stroke_circle_at(vertex[:handle1], :radius => 10)
176
+ # stroke_line(vertex[:point], vertex[:handle2])
177
+ vertices << vertex
178
+ end
179
+ vertices
180
+ end
181
+ end
182
+ end
183
+
184
+ class Numeric
185
+ def to_radians
186
+ self * 2.0 * Math::PI / 360.0
187
+ end
188
+ end
189
+
190
+ class Array
191
+ def unit_vector
192
+ denominator = Math.sqrt(self[0] * self[0] + self[1] * self[1])
193
+ return self if denominator == 0.0
194
+ [self[0] / denominator, self[1] / denominator]
195
+ end
196
+
197
+ # if :counter_clockwise => true option, then return a new vector
198
+ # that points 90 degrees counterlockwise of aVector with a magnitude
199
+ # of 1.0, otherwise return a new vector that points 90 degrees
200
+ # clockwise of aVector with a magnitude of 1.0
201
+ def unit_perpendicular_vector(options={})
202
+ return [self[1], -self[0]].unit_vector if options[:counter_clockwise]
203
+ [-self[1], self[0]].unit_vector
204
+ end
205
+ end
@@ -0,0 +1,40 @@
1
+ module Prawn
2
+ module Graphics
3
+ def star(point, options)
4
+ x, y = point
5
+ polygon(*star_points(point, options))
6
+ end
7
+
8
+ def half_star(point, options)
9
+ points = star_points(point, options)
10
+ case options[:side]
11
+ when :left
12
+ points.slice!(1..4)
13
+ when :right
14
+ points.slice!(6..9)
15
+ end
16
+ polygon(*points)
17
+ end
18
+
19
+ private
20
+
21
+ # radius is the horizontal half-width of the star (the star is the hand-drawn type that looks more natural to the eye, so it does not fit perfectly into a circle)
22
+ def star_points(point, options)
23
+ x, y = point
24
+ radius = options[:radius]
25
+ y = y + radius * 0.05
26
+ points = []
27
+ points << [x, y + radius * 0.9]
28
+ points << [x + 0.25 * radius, y + 0.2 * radius]
29
+ points << [x + radius, y + 0.2 * radius]
30
+ points << [x + 0.4 * radius, y - 0.2 * radius]
31
+ points << [x + 0.7 * radius, y - 1.0 * radius]
32
+ points << [x, y - 0.5 * radius]
33
+ points << [x - 0.7 * radius, y - 1.0 * radius]
34
+ points << [x - 0.4 * radius, y - 0.2 * radius]
35
+ points << [x - radius, y + 0.2 * radius]
36
+ points << [x - 0.25 * radius, y + 0.2 * radius]
37
+ points
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,27 @@
1
+ # Version numbering: http://wiki.github.com/sandal/prawn/development-roadmap
2
+ PRAWN_SHAPES_VERSION = "0.11.1"
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "prawn_shapes"
6
+ spec.version = PRAWN_SHAPES_VERSION
7
+ spec.platform = Gem::Platform::RUBY
8
+ spec.summary = "Additional vector shapes for Prawn"
9
+ spec.files = Dir.glob("{examples,lib,spec}/**/**/*") +
10
+ ["Rakefile", "prawn_shapes.gemspec"]
11
+ spec.require_path = "lib"
12
+ spec.required_ruby_version = '>= 1.8.7'
13
+ spec.required_rubygems_version = ">= 1.3.6"
14
+
15
+ spec.test_files = Dir[ "spec/*_spec.rb" ]
16
+ spec.has_rdoc = true
17
+ spec.extra_rdoc_files = %w{README.rdoc LICENSE}
18
+ spec.rdoc_options << '--title' << 'Prawn Oval Text Documentation' <<
19
+ '--main' << 'README.rdoc' << '-q'
20
+ spec.authors = ["Daniel Nelson"]
21
+ spec.email = ["dnelson@bluejade.com"]
22
+ spec.add_dependency('prawn', '>=0.11.1')
23
+ spec.homepage = "https://github.com/Bluejade/prawn-shapes"
24
+ spec.description = <<END_DESC
25
+ Adds additional vector shapes to Prawn
26
+ END_DESC
27
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
3
+
4
+ require 'prawn_shapes/arc'
5
+
6
+ describe 'Graphics#pie_slice' do
7
+ it 'should work' do
8
+ create_pdf
9
+ @pdf.pie_slice([100, 100], :radius => 50,
10
+ :start_angle => 0, :end_angle => 90)
11
+ curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
12
+ curve.coords.length.should > 0
13
+ end
14
+ end
15
+
16
+ describe 'Graphics#arc_around' do
17
+ it 'should work' do
18
+ create_pdf
19
+ @pdf.arc_around([100, 100], :radius => 50,
20
+ :start_angle => 0, :end_angle => 90)
21
+ curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
22
+ curve.coords.length.should > 0
23
+ end
24
+ end
25
+
26
+ describe 'Graphics#half_circle' do
27
+ it 'should work' do
28
+ create_pdf
29
+ @pdf.half_circle([100, 100], :radius => 50, :side => :left)
30
+ curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
31
+ curve.coords.length.should > 0
32
+ end
33
+ end
34
+
35
+ describe 'Graphics#quarter_circle' do
36
+ it 'should work' do
37
+ create_pdf
38
+ @pdf.quarter_circle([100, 100], :radius => 50, :quadrant => 2)
39
+ curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
40
+ curve.coords.length.should > 0
41
+ end
42
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+ Bundler.setup
6
+
7
+ require "prawn"
8
+ require "test/spec"
9
+ require "mocha"
10
+ require "pdf/reader"
11
+ require "pdf/inspector"
12
+
13
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
14
+
15
+
16
+
17
+ Prawn.debug = true
18
+
19
+ def create_pdf(klass=Prawn::Document)
20
+ @pdf = klass.new(:left_margin => 0,
21
+ :right_margin => 0,
22
+ :top_margin => 0,
23
+ :bottom_margin => 0)
24
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
3
+
4
+ require 'prawn_shapes/star'
5
+
6
+ describe 'Graphics#star' do
7
+ it 'should work' do
8
+ create_pdf
9
+ @pdf.star([100, 100], :radius => 50)
10
+ line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
11
+ line_drawing.points.length.should == 11
12
+ end
13
+ end
14
+
15
+ describe 'Graphics#half_star' do
16
+ it ':left side should work' do
17
+ create_pdf
18
+ @pdf.half_star([100, 100], :radius => 50, :side => :left)
19
+ line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
20
+ line_drawing.points.length.should == 7
21
+ end
22
+ it ':right side should work' do
23
+ create_pdf
24
+ @pdf.half_star([100, 100], :radius => 50, :side => :right)
25
+ line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
26
+ line_drawing.points.length.should == 7
27
+ end
28
+ end
29
+
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prawn_shapes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Nelson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-04-05 00:00:00.000000000 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: prawn
17
+ requirement: &80716660 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.11.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *80716660
26
+ description: ! ' Adds additional vector shapes to Prawn
27
+
28
+ '
29
+ email:
30
+ - dnelson@bluejade.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files:
34
+ - README.rdoc
35
+ - LICENSE
36
+ files:
37
+ - examples/example_helper.rb
38
+ - examples/graphics/star.rb
39
+ - examples/graphics/arc.rb
40
+ - lib/prawn_shapes.rb
41
+ - lib/prawn_shapes/star.rb
42
+ - lib/prawn_shapes/arc.rb
43
+ - spec/spec_helper.rb
44
+ - spec/star_spec.rb
45
+ - spec/arc_spec.rb
46
+ - Rakefile
47
+ - prawn_shapes.gemspec
48
+ - README.rdoc
49
+ - LICENSE
50
+ has_rdoc: true
51
+ homepage: https://github.com/Bluejade/prawn-shapes
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --title
56
+ - Prawn Oval Text Documentation
57
+ - --main
58
+ - README.rdoc
59
+ - -q
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: 1.8.7
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: 1.3.6
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 1.5.2
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: Additional vector shapes for Prawn
80
+ test_files:
81
+ - spec/star_spec.rb
82
+ - spec/arc_spec.rb