prawn_shapes 0.11.1 → 1.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b6d06f27c7a246ee94e8f1e57b4500820170085
4
+ data.tar.gz: 85e0821e27fa8d32d6e6f4637725bac7bae07933
5
+ SHA512:
6
+ metadata.gz: 657e634fec05c8036a2f5c7c3f332340aa64efbdb7b829470fb16bab8fc1a0a3cd6de7961cdaef8f5bc73238d5b5a25b9f5e098a55a1833c8d1d9e3e09b89f5f
7
+ data.tar.gz: 36f5c9abc5d0ed22edfb669ac00a69ff22fa943e4ff78a5e32ae2c90a984ddc13b9a0c641c4e04b6cda09f567cb22a1e6e6dc9acf8f7835f6ef97a1130af6a79
data/README.rdoc CHANGED
@@ -10,11 +10,13 @@ Available thus far:
10
10
 
11
11
  = Usage
12
12
 
13
- require 'prawn/graphics/star'
13
+ Install the prawn_shapes gem, then:
14
14
 
15
- pdf.star([x, y], :radius => r)
15
+ require 'prawn_shapes'
16
+
17
+ And:
16
18
 
17
- require 'prawn/graphics/arc'
19
+ pdf.star([x, y], :radius => r)
18
20
 
19
21
  pdf.arc_around([x, y], :radius => r, :start_angle => 30, :end_angle => 60)
20
22
  pdf.pie_slice([x, y], :radius => r, :start_angle => 45, :end_angle => 135)
@@ -31,9 +33,9 @@ See the examples directory for further usage examples.
31
33
 
32
34
  = Examples
33
35
 
34
- stars: http://mindlev.wordpress.com/files/2009/12/star.pdf
36
+ stars: https://github.com/downloads/Bluejade/prawn-shapes/star.pdf
35
37
 
36
- arcs and pies: http://mindlev.wordpress.com/files/2009/12/arc1.pdf
38
+ arcs and pies: https://github.com/downloads/Bluejade/prawn-shapes/arc.pdf
37
39
 
38
40
  = Changelog
39
41
 
@@ -115,6 +115,13 @@ module Prawn
115
115
  origin[:handle1] || origin[:point]])
116
116
  end
117
117
 
118
+ ops = %w{fill stroke fill_and_stroke}
119
+ shapes = %w{half_circle quarter_circle pie_slice arc_around open_curve closed_curve}
120
+
121
+ ops.product(shapes).each do |operation,shape|
122
+ class_eval "def #{operation}_#{shape}(*args); #{shape}(*args); #{operation}; end"
123
+ end
124
+
118
125
  private
119
126
 
120
127
  def arc_vertices(center, options)
@@ -122,34 +129,34 @@ module Prawn
122
129
  start_degrees = options[:start_angle]
123
130
  end_degrees = options[:end_angle]
124
131
  return if start_degrees == end_degrees
125
-
132
+
126
133
  overall_start_angle = (start_degrees % 360.0).to_radians
127
134
  overall_end_angle = (end_degrees % 360.0).to_radians
128
135
 
129
136
  # if the angles are now equal, when they weren't before, then
130
137
  # they describe an entire circle
131
138
  return circle_at(center, :radius => radius) if overall_start_angle == overall_end_angle
132
-
139
+
133
140
  overall_end_angle = overall_end_angle + 2.0 * Math::PI if overall_end_angle < overall_start_angle
134
-
141
+
135
142
  delta = overall_end_angle - overall_start_angle
136
143
  quadrants = (delta / (Math::PI * 0.5)).ceil
137
-
144
+
138
145
  vertices = []
139
146
  quadrants.times do |i|
140
147
  start_angle = overall_start_angle + Math::PI * 0.5 * i
141
-
148
+
142
149
  if i == quadrants - 1 then end_angle = overall_end_angle
143
150
  else end_angle = start_angle + Math::PI * 0.5
144
151
  end
145
-
152
+
146
153
  delta = end_angle - start_angle
147
154
  handle_multiplier = KAPPA * delta / (Math::PI * 0.5) * radius
148
-
155
+
149
156
  # negate the angles so as to get the stated orientation of angles
150
157
  # start_angle = -start_angle
151
158
  # end_angle = -end_angle
152
-
159
+
153
160
  vertex = {}
154
161
  point = [Math.cos(start_angle), Math.sin(start_angle)]
155
162
  vertex[:point] = [center[0] + radius * point[0],
@@ -163,7 +170,7 @@ module Prawn
163
170
  #stroke_circle_at(vertex[:handle2], :radius => 10)
164
171
  # stroke_line(vertex[:point], vertex[:handle1])
165
172
  vertices << vertex
166
-
173
+
167
174
  vertex = {}
168
175
  point = [Math.cos(end_angle), Math.sin(end_angle)]
169
176
  vertex[:point] = [center[0] + radius * point[0],
@@ -193,7 +200,7 @@ class Array
193
200
  return self if denominator == 0.0
194
201
  [self[0] / denominator, self[1] / denominator]
195
202
  end
196
-
203
+
197
204
  # if :counter_clockwise => true option, then return a new vector
198
205
  # that points 90 degrees counterlockwise of aVector with a magnitude
199
206
  # of 1.0, otherwise return a new vector that points 90 degrees
@@ -16,6 +16,13 @@ module Prawn
16
16
  polygon(*points)
17
17
  end
18
18
 
19
+ ops = %w{fill stroke fill_and_stroke}
20
+ shapes = %w{star half_star}
21
+
22
+ ops.product(shapes).each do |operation,shape|
23
+ class_eval "def #{operation}_#{shape}(*args); #{shape}(*args); #{operation}; end"
24
+ end
25
+
19
26
  private
20
27
 
21
28
  # 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)
data/prawn_shapes.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  # Version numbering: http://wiki.github.com/sandal/prawn/development-roadmap
2
- PRAWN_SHAPES_VERSION = "0.11.1"
2
+ PRAWN_SHAPES_VERSION = "1.1.0"
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "prawn_shapes"
@@ -13,13 +13,12 @@ Gem::Specification.new do |spec|
13
13
  spec.required_rubygems_version = ">= 1.3.6"
14
14
 
15
15
  spec.test_files = Dir[ "spec/*_spec.rb" ]
16
- spec.has_rdoc = true
17
16
  spec.extra_rdoc_files = %w{README.rdoc LICENSE}
18
17
  spec.rdoc_options << '--title' << 'Prawn Oval Text Documentation' <<
19
18
  '--main' << 'README.rdoc' << '-q'
20
19
  spec.authors = ["Daniel Nelson"]
21
20
  spec.email = ["dnelson@bluejade.com"]
22
- spec.add_dependency('prawn', '>=0.11.1')
21
+ spec.add_dependency('prawn', '~> 1.1')
23
22
  spec.homepage = "https://github.com/Bluejade/prawn-shapes"
24
23
  spec.description = <<END_DESC
25
24
  Adds additional vector shapes to Prawn
data/spec/arc_spec.rb CHANGED
@@ -13,6 +13,36 @@ describe 'Graphics#pie_slice' do
13
13
  end
14
14
  end
15
15
 
16
+ describe 'Graphics#stroke_pie_slice' do
17
+ it 'should work' do
18
+ create_pdf
19
+ @pdf.stroke_pie_slice([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#fill_pie_slice' do
27
+ it 'should work' do
28
+ create_pdf
29
+ @pdf.fill_pie_slice([100, 100], :radius => 50,
30
+ :start_angle => 0, :end_angle => 90)
31
+ curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
32
+ curve.coords.length.should > 0
33
+ end
34
+ end
35
+
36
+ describe 'Graphics#fill_and_stroke_pie_slice' do
37
+ it 'should work' do
38
+ create_pdf
39
+ @pdf.fill_and_stroke_pie_slice([100, 100], :radius => 50,
40
+ :start_angle => 0, :end_angle => 90)
41
+ curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
42
+ curve.coords.length.should > 0
43
+ end
44
+ end
45
+
16
46
  describe 'Graphics#arc_around' do
17
47
  it 'should work' do
18
48
  create_pdf
data/spec/spec_helper.rb CHANGED
@@ -5,10 +5,11 @@ require "bundler"
5
5
  Bundler.setup
6
6
 
7
7
  require "prawn"
8
- require "test/spec"
8
+ require "rspec"
9
9
  require "mocha"
10
10
  require "pdf/reader"
11
11
  require "pdf/inspector"
12
+ require 'pry'
12
13
 
13
14
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
14
15
 
@@ -21,4 +22,4 @@ def create_pdf(klass=Prawn::Document)
21
22
  :right_margin => 0,
22
23
  :top_margin => 0,
23
24
  :bottom_margin => 0)
24
- end
25
+ end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn_shapes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel Nelson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-04-05 00:00:00.000000000 -05:00
13
- default_executable:
11
+ date: 2014-07-21 00:00:00.000000000 Z
14
12
  dependencies:
15
13
  - !ruby/object:Gem::Dependency
16
14
  name: prawn
17
- requirement: &80716660 !ruby/object:Gem::Requirement
18
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
19
16
  requirements:
20
- - - ! '>='
17
+ - - ~>
21
18
  - !ruby/object:Gem::Version
22
- version: 0.11.1
19
+ version: '1.1'
23
20
  type: :runtime
24
21
  prerelease: false
25
- version_requirements: *80716660
26
- description: ! ' Adds additional vector shapes to Prawn
27
-
28
- '
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ description: |2
28
+ Adds additional vector shapes to Prawn
29
29
  email:
30
30
  - dnelson@bluejade.com
31
31
  executables: []
@@ -34,22 +34,22 @@ extra_rdoc_files:
34
34
  - README.rdoc
35
35
  - LICENSE
36
36
  files:
37
+ - LICENSE
38
+ - README.rdoc
39
+ - Rakefile
37
40
  - examples/example_helper.rb
38
- - examples/graphics/star.rb
39
41
  - examples/graphics/arc.rb
42
+ - examples/graphics/star.rb
40
43
  - lib/prawn_shapes.rb
41
- - lib/prawn_shapes/star.rb
42
44
  - lib/prawn_shapes/arc.rb
45
+ - lib/prawn_shapes/star.rb
46
+ - prawn_shapes.gemspec
47
+ - spec/arc_spec.rb
43
48
  - spec/spec_helper.rb
44
49
  - 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
50
  homepage: https://github.com/Bluejade/prawn-shapes
52
51
  licenses: []
52
+ metadata: {}
53
53
  post_install_message:
54
54
  rdoc_options:
55
55
  - --title
@@ -60,23 +60,21 @@ rdoc_options:
60
60
  require_paths:
61
61
  - lib
62
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
- none: false
64
63
  requirements:
65
- - - ! '>='
64
+ - - '>='
66
65
  - !ruby/object:Gem::Version
67
66
  version: 1.8.7
68
67
  required_rubygems_version: !ruby/object:Gem::Requirement
69
- none: false
70
68
  requirements:
71
- - - ! '>='
69
+ - - '>='
72
70
  - !ruby/object:Gem::Version
73
71
  version: 1.3.6
74
72
  requirements: []
75
73
  rubyforge_project:
76
- rubygems_version: 1.5.2
74
+ rubygems_version: 2.2.2
77
75
  signing_key:
78
- specification_version: 3
76
+ specification_version: 4
79
77
  summary: Additional vector shapes for Prawn
80
78
  test_files:
81
- - spec/star_spec.rb
82
79
  - spec/arc_spec.rb
80
+ - spec/star_spec.rb