text2path 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/README.md +11 -1
  4. data/lib/text2path/glyph.rb +1 -3
  5. data/lib/text2path/svg_font.rb +13 -3
  6. data/lib/text2path/version.rb +1 -1
  7. metadata +2 -47
  8. data/lib/ext/savage/LICENSE +0 -20
  9. data/lib/ext/savage/README.rdoc +0 -108
  10. data/lib/ext/savage/Rakefile +0 -39
  11. data/lib/ext/savage/VERSION +0 -1
  12. data/lib/ext/savage/lib/savage.rb +0 -3
  13. data/lib/ext/savage/lib/savage/direction.rb +0 -42
  14. data/lib/ext/savage/lib/savage/direction_proxy.rb +0 -19
  15. data/lib/ext/savage/lib/savage/directions/arc_to.rb +0 -29
  16. data/lib/ext/savage/lib/savage/directions/close_path.rb +0 -18
  17. data/lib/ext/savage/lib/savage/directions/coordinate_target.rb +0 -17
  18. data/lib/ext/savage/lib/savage/directions/cubic_curve_to.rb +0 -40
  19. data/lib/ext/savage/lib/savage/directions/horizontal_to.rb +0 -19
  20. data/lib/ext/savage/lib/savage/directions/line_to.rb +0 -15
  21. data/lib/ext/savage/lib/savage/directions/move_to.rb +0 -15
  22. data/lib/ext/savage/lib/savage/directions/point_target.rb +0 -17
  23. data/lib/ext/savage/lib/savage/directions/quadratic_curve_to.rb +0 -44
  24. data/lib/ext/savage/lib/savage/directions/vertical_to.rb +0 -19
  25. data/lib/ext/savage/lib/savage/parser.rb +0 -108
  26. data/lib/ext/savage/lib/savage/path.rb +0 -50
  27. data/lib/ext/savage/lib/savage/sub_path.rb +0 -54
  28. data/lib/ext/savage/lib/savage/transformable.rb +0 -48
  29. data/lib/ext/savage/lib/savage/utils.rb +0 -7
  30. data/lib/ext/savage/savage.gemspec +0 -80
  31. data/lib/ext/savage/spec/savage/directions/arc_to_spec.rb +0 -97
  32. data/lib/ext/savage/spec/savage/directions/close_path_spec.rb +0 -30
  33. data/lib/ext/savage/spec/savage/directions/cubic_curve_to_spec.rb +0 -146
  34. data/lib/ext/savage/spec/savage/directions/horizontal_to_spec.rb +0 -10
  35. data/lib/ext/savage/spec/savage/directions/line_to_spec.rb +0 -10
  36. data/lib/ext/savage/spec/savage/directions/move_to_spec.rb +0 -10
  37. data/lib/ext/savage/spec/savage/directions/point_spec.rb +0 -12
  38. data/lib/ext/savage/spec/savage/directions/quadratic_curve_spec.rb +0 -123
  39. data/lib/ext/savage/spec/savage/directions/vertical_to_spec.rb +0 -10
  40. data/lib/ext/savage/spec/savage/parser_spec.rb +0 -250
  41. data/lib/ext/savage/spec/savage/path_spec.rb +0 -105
  42. data/lib/ext/savage/spec/savage/sub_path_spec.rb +0 -195
  43. data/lib/ext/savage/spec/savage/transformable_spec.rb +0 -62
  44. data/lib/ext/savage/spec/savage_spec.rb +0 -5
  45. data/lib/ext/savage/spec/shared/command.rb +0 -13
  46. data/lib/ext/savage/spec/shared/coordinate_target.rb +0 -36
  47. data/lib/ext/savage/spec/shared/direction.rb +0 -29
  48. data/lib/ext/savage/spec/shared/point_target.rb +0 -45
  49. data/lib/ext/savage/spec/spec_helper.rb +0 -36
  50. data/libpeerconnection.log +0 -0
  51. data/out.svg +0 -1
  52. data/test.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49ef0ca8005be11a5117ab3fea6614e4d7c21d56
4
- data.tar.gz: 9aa4f00502589c492470b28d6768d232034b4437
3
+ metadata.gz: 1f71e079c9ef4a011fcdd9db369fbc40dcc86283
4
+ data.tar.gz: f778d42831d4649fe5ce2357a76df45d62a7e2d0
5
5
  SHA512:
6
- metadata.gz: 81e5e62f2639e847de38605b10ece164290825ba26eef89e1e47d877293980fc160f9c12710bb7bf2566cbd56e77364d564d7c248cfc53962bf165fa9dbbbaf9
7
- data.tar.gz: 640e1a6bd966dca1ffc8ef02f781aab0825a7c9022a5e51437bec486ca1e1e88f7a6c7375183a73ff6f48d3816b8b920bca7364a89148bb0b63cfbc3abf503c1
6
+ metadata.gz: c6b05b6094510a7ddfe0031800b733c337fbad322e325133ad7fabaa2fffdc4282a11539f7f8bd1573838b57c4f0d1a72d3a3d473f1c154e32e737e804e7baa8
7
+ data.tar.gz: 37a3b56ce426359d0e500be66a5024fc826caeadc50212e5650cdd74c6cfe3d2e6382922cdbe0745ef6fa5e9e5b718f7f7f153eebac9f421eee17fa2e41c05b7
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'http://ruby.taobao.org'
2
2
 
3
3
  gem 'nokogiri'
4
4
  gem 'htmlentities'
5
+ gem 'savage', git: 'https://github.com/qhwa/savage.git'
data/README.md CHANGED
@@ -40,7 +40,17 @@ in your Gemfile
40
40
 
41
41
 
42
42
  ## helpful infomation
43
- [generating svg font file](http://xmlgraphics.apache.org/batik/tools/font-converter.html)
43
+ ### generating svg font file
44
+ You can do it with [batik ttf2svg tool](http://xmlgraphics.apache.org/batik/tools/font-converter.html)
45
+
46
+ in short:
47
+ ~~~sh
48
+ java -jar batik-ttf2svg.jar -autorange "some-font.ttf" -o "some-font.svg"
49
+ ~~~
50
+
51
+ ## License
52
+ copy right(s) qhwa 2013
53
+ Licensed under the MIT license.
44
54
 
45
55
  ## TODO
46
56
  This project is at its very beginning, features missing:
@@ -1,8 +1,6 @@
1
1
  module Text2Path
2
2
 
3
- Glyph = Struct.new :path, :horiz_adv_x, :horiz_adv_y
4
-
5
- class Glyph
3
+ class Glyph < Struct.new :path, :horiz_adv_x, :horiz_adv_y
6
4
 
7
5
  def empty?
8
6
  !path || path.empty?
@@ -33,9 +33,13 @@ module Text2Path
33
33
 
34
34
  def glyph( letter )
35
35
  key = letter.respond_to?(:ord) ? letter.ord : letter.to_i
36
- glyphs[key] #|| missing_glyph
36
+ glyphs[key] || missing_glyph
37
37
  end
38
38
 
39
+ # "missing_glyph" is the fallback glyph
40
+ # when not letter not in the charmap
41
+ attr_reader :missing_glyph
42
+
39
43
  private
40
44
 
41
45
  def load_font
@@ -76,17 +80,23 @@ module Text2Path
76
80
  # e.g.
77
81
  # &amp; &quot; ..
78
82
  decoder.decode( name )[0].ord
83
+ when nil
84
+ # just ignore it
79
85
  else
80
86
  raise "unknown name: #{name}"
81
87
  end
82
88
 
83
- adv_x = glyph.attr('horiz-adv-x') || @horiz_adv_x
84
- map[key] = Glyph.new( glyph.attr('d'), adv_x.to_f )
89
+ map[key] = parse_glyph( glyph )
85
90
  map
86
91
  end
87
92
 
93
+ @missing_glyph = parse_glyph( @xml.css('missing-glyph').first )
88
94
  end
89
95
 
96
+ def parse_glyph( node )
97
+ adv_x = node.attr('horiz-adv-x') || @horiz_adv_x
98
+ Glyph.new( node.attr('d'), adv_x.to_f )
99
+ end
90
100
  end
91
101
 
92
102
  end
@@ -1,3 +1,3 @@
1
1
  module Text2Path
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text2path
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - qhwa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-07 00:00:00.000000000 Z
11
+ date: 2013-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -47,52 +47,7 @@ extra_rdoc_files:
47
47
  files:
48
48
  - README.md
49
49
  - Gemfile.lock
50
- - out.svg
51
- - libpeerconnection.log
52
50
  - Gemfile
53
- - test.rb
54
- - lib/ext/savage/spec/shared/direction.rb
55
- - lib/ext/savage/spec/shared/coordinate_target.rb
56
- - lib/ext/savage/spec/shared/point_target.rb
57
- - lib/ext/savage/spec/shared/command.rb
58
- - lib/ext/savage/spec/savage/parser_spec.rb
59
- - lib/ext/savage/spec/savage/path_spec.rb
60
- - lib/ext/savage/spec/savage/transformable_spec.rb
61
- - lib/ext/savage/spec/savage/directions/arc_to_spec.rb
62
- - lib/ext/savage/spec/savage/directions/point_spec.rb
63
- - lib/ext/savage/spec/savage/directions/vertical_to_spec.rb
64
- - lib/ext/savage/spec/savage/directions/horizontal_to_spec.rb
65
- - lib/ext/savage/spec/savage/directions/quadratic_curve_spec.rb
66
- - lib/ext/savage/spec/savage/directions/cubic_curve_to_spec.rb
67
- - lib/ext/savage/spec/savage/directions/close_path_spec.rb
68
- - lib/ext/savage/spec/savage/directions/line_to_spec.rb
69
- - lib/ext/savage/spec/savage/directions/move_to_spec.rb
70
- - lib/ext/savage/spec/savage/sub_path_spec.rb
71
- - lib/ext/savage/spec/savage_spec.rb
72
- - lib/ext/savage/spec/spec_helper.rb
73
- - lib/ext/savage/Rakefile
74
- - lib/ext/savage/VERSION
75
- - lib/ext/savage/savage.gemspec
76
- - lib/ext/savage/LICENSE
77
- - lib/ext/savage/lib/savage/utils.rb
78
- - lib/ext/savage/lib/savage/transformable.rb
79
- - lib/ext/savage/lib/savage/directions/quadratic_curve_to.rb
80
- - lib/ext/savage/lib/savage/directions/arc_to.rb
81
- - lib/ext/savage/lib/savage/directions/line_to.rb
82
- - lib/ext/savage/lib/savage/directions/coordinate_target.rb
83
- - lib/ext/savage/lib/savage/directions/point_target.rb
84
- - lib/ext/savage/lib/savage/directions/cubic_curve_to.rb
85
- - lib/ext/savage/lib/savage/directions/move_to.rb
86
- - lib/ext/savage/lib/savage/directions/horizontal_to.rb
87
- - lib/ext/savage/lib/savage/directions/close_path.rb
88
- - lib/ext/savage/lib/savage/directions/vertical_to.rb
89
- - lib/ext/savage/lib/savage/direction.rb
90
- - lib/ext/savage/lib/savage/parser.rb
91
- - lib/ext/savage/lib/savage/path.rb
92
- - lib/ext/savage/lib/savage/sub_path.rb
93
- - lib/ext/savage/lib/savage/direction_proxy.rb
94
- - lib/ext/savage/lib/savage.rb
95
- - lib/ext/savage/README.rdoc
96
51
  - lib/text2path.rb
97
52
  - lib/text2path/glyph.rb
98
53
  - lib/text2path/version.rb
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010 Jeremy Holland
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,108 +0,0 @@
1
- = Savage
2
-
3
- A little gem for extracting and manipulating SVG vector path data, Savage will make your life easier when it comes time to dynamically draw new and manipulate existing SVG paths. No more wacky regex to capture those cryptic path data strings; just pass the whole "d" attribute into Savage's parser, et voilá: You'll be given an instance of Savage::Path, replete with an array of subpaths split on the "move to" commands (to better help with those pesky winding issues). In turn, each subpath contains its own array of directions that can be swapped around, reconfigured, and otherwise manipulated to your heart's content in a truly human-readable way.
4
-
5
- == Latest Update
6
-
7
- Version 1.2.0 includes a new array abstraction (see below) and optimized implementation of Direction#to_command, courtesy of {bdon}[https://github.com/bdon]!
8
-
9
- == Usage
10
-
11
- <b>Parsing existing data</b>
12
-
13
- Easy-peasy Japanesey. Just take a look at the below:
14
-
15
- path = Savage::Parser.parse my_path_data_string
16
- path.subpaths # [subpath_1, subpath_2, ... subpath_n]
17
- path.subpaths.last.directions # [direction_1, direction_2, ... direction_n]
18
-
19
- Once extracted, you can manipulate, add, and remove the subpaths and directions as you see fit. See below for instructions on using the various direction types
20
-
21
- <b>Creating from scratch</b>
22
-
23
- What if you want to roll your own from the get-go? No problem:
24
-
25
- path = Savage::Path.new do |p|
26
- p.move_to 100, 200
27
- p.line_to 300, 400
28
- p.horizontal_to 500
29
- p.close_path
30
- end
31
-
32
- We'll learn more about the actual drawing methods here shortly, but suffice it to say they are provided both as methods on the constructor block parameter for the sake of your visual organization, and the path itself after instantiation, as below:
33
-
34
- path = Savage::Path.new
35
- path.move_to 100, 200
36
- path.line_to 300, 400
37
- path.horizontal_to 500
38
- path.close_path
39
-
40
- <b>Drawing with Savage</b>
41
-
42
- So what are the different directions we can give our virtual pen? Here I'll refer you first to the SVG 1.1 specification by our friends down at the W3C, as they can describe all the specifics much better than I: http://www.w3.org/TR/SVG/paths.html#PathData. Each "command" listed in that section has an analog method on the Savage::SubPath class as well as the Savage::Path class (calling one of the methods on an instance of the Savage::Path class actually just delegates the call to the last SubPath in that path's selection of subpaths). Every parameter of these methods is expected to be a Numeric except where noted otherwise. The methods are as follows:
43
-
44
- * <b>path.move_to(target_x, target_y)</b> - Move the 'pen' to the specified coordinates on the 'canvas' without drawing anything. Note that you can only call this method on a subpath if it's otherwise empty. Most of the time, just call this on an instance of the Path class, which will actually create a new subpath for you to continue drawing into
45
- * <b>path.close_path()</b> - Draw a straight line from the current position to the coordinates of the start of the current subpath
46
- * <b>path.line_to(target_x, target_y)</b> - Draw a straight line from the current position to the specified coordinates
47
- * <b>path.horizontal_to(target_x)</b> - Draw a straight horizontal line to the provided x coordinate
48
- * <b>path.vertical_to(target_y)</b> - Draw a straight vertical line to the provided y coordinate
49
- * <b>path.cubic_curve_to(control_1_x, control_1_y, control_2_x, control_2_y, target_x, target_y)</b> - Draw a cubic Bézier curve from the current position to the target coordinates (target_x/y) using the control points specified - see the SVG specification referred to above for more info
50
- * <b>path.cubic_curve_to(control_2_x, control_2_y, target_x, target_y)</b> - Shorthand cubic Bézier curve; assumes continuation of previous curve. See SVG specification
51
- * <b>path.quadratic_curve_to(control_x, control_y, target_x, target_y)</b> - Draw a quadratic Bézier curve from the current position to the target coordinates (target_x/y) using the control point specified - see the SVG specification referred to above for more info
52
- * <b>path.quadratic_curve_to(target_x, target_y)</b> - Shorthand quadratic Bézier curve; assumes continuation of previous curve. See SVG specification
53
- * <b>path.arc_to(radius_x,radius_y,rotation,large_arc_flag,sweep_flag,target_x,target_y)</b> - This is a doozy and complicated as sin to explain, so we'll let the W3C do it for us - see the spec. Otherwise, be aware that the large_arc_flag and sweep_flag arguments are expected to be boolean values, not Numeric.
54
-
55
- There you have it, pretty much right out of the book. One thing to keep in mind is that all of these methods use ABSOLUTE coordinates by default; if you want to use relative coordinates (based on the current position of the 'pen'), just pass false as the final argument to any of them:
56
-
57
- path.line_to 100, 200, false
58
-
59
- Each of these commands just creates a new instance of the appropriate subclass of the Savage::Direction class and pushes it onto the end of the directions list in question. Don't necessarily want to draw onto the end? Just create your own instance using the standard constructor and insert it wherever it butters your biscuit so to do:
60
-
61
- direction = Savage::Directions::LineTo.new(100,200)
62
- subpath.directions.insert(3,direction)
63
-
64
- Did you mess up before and need to change a directions coordinates after you drew it (or, more likely, after you parsed it out of some pre-existing data)? No problem:
65
-
66
- direction = Savage::Directions::LineTo.new(100,200)
67
- direction.target.x = 234
68
-
69
- As you may have guessed, Savage::Path#subpaths and Savage::SubPath#directions are both just good old-fashioned arrays, so you can fiddle with them using all your favorite Enumerable tricks as always.
70
-
71
- <b>Abstracting it to an array (new in v1.2.0!)</b>
72
-
73
- Bang!:
74
-
75
- path.to_a # => ["M", 100, 200, ...]
76
-
77
- <b>Turning it back into a path data string</b>
78
-
79
- Bang!:
80
-
81
- path.to_command # => 'M100 200-342 43.5Q-34.88 123.9 13-532' or whatever...
82
-
83
- Note that the #to_command method exists on Savage::Path, Savage::SubPath, and each subclass of Savage::Direction, so you can be as fine-grained with it as needed.
84
-
85
- == Issues / Feature Requests
86
-
87
- I have no doubt that will be some problems with this thing, as well as features missing that some of you fine folks might want. Please, please, please check Github's issue-tracking system to see if a ticket for the problem has already been submitted, or create a new one if not. I'll check the issues listed therein regularly, but you email me directly at your own risk (and by risk, I mean risk of not receiving a reply). :)
88
-
89
- == Note on Patches/Pull Requests
90
-
91
- * Fork the project.
92
- * Make your feature addition or bug fix. I very much prefer feature-specific branches.
93
- * Add specs for it. This is important so I don't break it in a future version unintentionally, which I can guarantee I will do.
94
- * Commit. Do not mess with rakefile, version, or history, please.
95
- * Send me a pull request - again, bonus points for topic branches.
96
-
97
- == Contributors
98
-
99
- * Jeremy Holland (jeremy@jeremypholland.com, github:{awebneck}[https://github.com/awebneck]) -- author
100
- * Christoffer Klang (toffeklang@yahoo.se, github:{christoffer}[https://github.com/christoffer]) -- regexp improvements
101
- * Bartosz Dz (github:{MatmaRex}[https://github.com/matmarex]) -- parser improvements, scientific notation support, bug fixes
102
- * Brandon Liu (github:{bdon}[https://github.com/bdon]) -- spec improvements, array abstraction
103
-
104
- == Copyright
105
-
106
- Copyright (c) 2010 Jeremy Holland. See LICENSE for details.
107
-
108
-
@@ -1,39 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "savage"
8
- gem.summary = %Q{A little library to manipulate SVG path data}
9
- gem.description = %Q{A little gem for extracting and manipulating SVG vector path data.}
10
- gem.email = "jeremy@jeremypholland.com"
11
- gem.homepage = "http://github.com/awebneck/savage"
12
- gem.authors = ["Jeremy Holland"]
13
- gem.add_development_dependency "rspec", ">= 2.3.0"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
- require 'rspec/core/rake_task'
22
- RSpec::Core::RakeTask.new(:spec)
23
- RSpec::Core::RakeTask.new(:rcov) do |spec|
24
- spec.rcov = true
25
- end
26
-
27
- task :spec => :check_dependencies
28
-
29
- task :default => :spec
30
-
31
- require 'rake/rdoctask'
32
- Rake::RDocTask.new do |rdoc|
33
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
34
-
35
- rdoc.rdoc_dir = 'rdoc'
36
- rdoc.title = "savage #{version}"
37
- rdoc.rdoc_files.include('README*')
38
- rdoc.rdoc_files.include('lib/**/*.rb')
39
- end
@@ -1 +0,0 @@
1
- 1.2.0
@@ -1,3 +0,0 @@
1
- %w[ utils transformable direction path parser ].each do |library|
2
- require_relative "savage/#{library}"
3
- end
@@ -1,42 +0,0 @@
1
- module Savage
2
- module Directions
3
- Point = Struct.new :x, :y
4
- end
5
-
6
- class Direction
7
-
8
- include Utils
9
- include Transformable
10
-
11
- def initialize(absolute)
12
- @absolute = absolute
13
- end
14
-
15
- def absolute?
16
- @absolute
17
- end
18
-
19
- def relative?
20
- !absolute?
21
- end
22
-
23
- def to_command
24
- arr = to_a
25
- arr.map! do |x|
26
- x.to_i == x ? x.to_i : x
27
- end
28
- arr[0] + arr[1..-1].join(' ').gsub(/ -/,'-')
29
- end
30
- end
31
- end
32
-
33
- require File.dirname(__FILE__) + "/directions/close_path"
34
- require File.dirname(__FILE__) + "/directions/coordinate_target"
35
- require File.dirname(__FILE__) + "/directions/horizontal_to"
36
- require File.dirname(__FILE__) + "/directions/vertical_to"
37
- require File.dirname(__FILE__) + "/directions/point_target"
38
- require File.dirname(__FILE__) + "/directions/move_to"
39
- require File.dirname(__FILE__) + "/directions/line_to"
40
- require File.dirname(__FILE__) + "/directions/quadratic_curve_to"
41
- require File.dirname(__FILE__) + "/directions/cubic_curve_to"
42
- require File.dirname(__FILE__) + "/directions/arc_to"
@@ -1,19 +0,0 @@
1
- module Savage
2
- module DirectionProxy
3
- def self.included(klass)
4
- klass.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def define_proxies(&block)
9
- Directions.constants.each do |constant_sym|
10
- constant = (constant_sym.is_a?(Symbol)) ? constant_sym.to_s : constant_sym
11
- unless %w[PointTarget CoordinateTarget Point MoveTo].include? constant
12
- sym = constant.to_s.gsub(/[A-Z]/) { |p| '_' + p.downcase }[1..-1].to_sym
13
- block.call(sym,constant)
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,29 +0,0 @@
1
- module Savage
2
- module Directions
3
- class ArcTo < PointTarget
4
- attr_accessor :radius, :rotation, :large_arc, :sweep
5
-
6
- def initialize(radius_x, radius_y, rotation, large_arc, sweep, target_x, target_y, absolute=true)
7
- super(target_x, target_y, absolute)
8
- @radius = Point.new(radius_x, radius_y)
9
- @rotation = rotation
10
- @large_arc = large_arc.is_a?(Numeric) ? large_arc > 0 : large_arc
11
- @sweep = sweep.is_a?(Numeric) ? sweep > 0 : sweep
12
- end
13
-
14
- def to_a
15
- [command_code, @radius.x, @radius.y, @rotation, bool_to_int(@large_arc), bool_to_int(@sweep), target.x, target.y]
16
- end
17
-
18
- def command_code
19
- (absolute?) ? 'A' : 'a'
20
- end
21
-
22
- def transform(scale_x, skew_x, skew_y, scale_y, tx, ty)
23
- # relative arc_to dont't need to be tranlated
24
- tx = ty = 0 if relative?
25
- transform_dot( target, scale_x, skew_x, skew_y, scale_y, tx, ty)
26
- end
27
- end
28
- end
29
- end
@@ -1,18 +0,0 @@
1
- module Savage
2
- module Directions
3
- class ClosePath < Direction
4
-
5
- def initialize(absolute=true)
6
- super(absolute)
7
- end
8
-
9
- def to_a
10
- [command_code]
11
- end
12
-
13
- def command_code
14
- (absolute?) ? 'Z' : 'z'
15
- end
16
- end
17
- end
18
- end