vector_be_winding 0.9.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d63331bdde70ece16ad946c86b40d16651ff6e3
4
- data.tar.gz: 757ea390d934c45d3dfb2461d05182955bfafaf3
3
+ metadata.gz: ed608fa8b0053321860a3b2a15748af4a5bd0fa7
4
+ data.tar.gz: 8a2788d12f18590eb8de4e417f0e302b25a8e783
5
5
  SHA512:
6
- metadata.gz: 349d180848c2a3a0cda2fdab934c4cf6bacd599c629fcafaaa66e74073b2f8e9cce6553cca95df1fc78d3e15abad77ada9647450724ceab32dffae7c56a8194a
7
- data.tar.gz: 02deb594f43de821830d565aa5c5db4d4ac9bae726b6d8b9875624f0f5febaab80f0eaa2c0a5b77708276693f932e90882985bc4553ce566774f3f1382c4780f
6
+ metadata.gz: a1167d9d518c4fb67729a0796fce284dc1c937affde1678d2acdbc2789cd8a098029057b3aebd9cee0f935ca69a56b340932066970db9f6179486a9025d43979
7
+ data.tar.gz: a3eda6be2f120e09b2ee3a99f1fdf9f4ecd5a539ed29c29c487591e3a1dec59bbf3fdf54ba1022cb534077c035d078e528aca3e9a8e066beedc4d874ab814d77
data/README.md CHANGED
@@ -1,37 +1,38 @@
1
1
  # VectorBeWinding ![Travis](https://travis-ci.org/dagezi/vector_be_winding.svg?branch=master)
2
2
 
3
- Android Vector Drawable is very combinent, but sometimes it missing holes in the shape generated by some tools. `vector_be_winding` will massage such Vector Drawalbes so that the shape will be rendered as expectd!
3
+ Android Vector Drawable is very convenient,
4
+ but sometimes it missing holes in the shape generated by some tools.
5
+ `vector_be_winding` will massage such Vector Drawalbes
6
+ so that the shape will be rendered as expected!
4
7
 
5
- ## Example
6
8
 
7
- TODO: Describe some pipeline which might generate "wrong" Vector Drawable.
8
-
9
- 1. Skecth + vdtool
10
-
11
- TODO: Describe why it happens and how this tool resolve it.
9
+ Try [SampleApp](https://github.com/dagezi/vector_be_winding/tree/master/sampleApp) to see how it works.
12
10
 
13
11
  ## Installation
14
12
 
15
- just with Gem.
16
-
13
+ ```
14
+ gem install vector_be_winding
15
+ ```
17
16
 
18
17
  ## Usage
19
18
 
20
- TODO: Write usage instructions here
19
+ Just exec:
21
20
 
22
- ## Development
21
+ `% vbw vector_file.xml vector_file_1.xml ...`
23
22
 
24
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
23
+ Then the vector drawable files which doesn't follow winding rules will be
24
+ automatically converted and the back-up file with `.bak` extension will
25
+ be create.
25
26
 
26
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
27
+ ### Options
28
+ - `-v` : verbose; shows the file which will be converted
29
+ - `-n` : dry run
30
+ - `-i` : specify the template of back up file name.
27
31
 
28
32
  ## Contributing
29
33
 
30
34
  Bug reports and pull requests are welcome on GitHub at https://github.com/dagezi/vector_be_winding.
31
35
 
32
- ## Lisense
36
+ ## License
33
37
 
34
38
  MIT License.
35
-
36
-
37
-
@@ -1,7 +1,8 @@
1
1
  module VectorBeWinding
2
2
  class Segment < Shape
3
3
  attr_reader :start_point, :direction, :end_point,
4
- :control, :control_1
4
+ :control, :control_1,
5
+ :radius, :rotation, :large_arc, :sweep
5
6
 
6
7
  def initialize(direction, start_point, end_point_hint, prev_segment = nil)
7
8
  @direction = direction
@@ -31,9 +32,12 @@ module VectorBeWinding
31
32
  start_point
32
33
  @control = create_vector(control.x, control.y, @direction.absolute?)
33
34
  @control_1 = create_vector(control_1.x, control_1.y, @direction.absolute?)
35
+ elsif @direction.instance_of?(::Savage::Directions::ArcTo)
36
+ @radius = @direction.radius
37
+ @rotation = @direction.rotation
38
+ @large_arc = @direction.large_arc
39
+ @sweep = @direction.sweep
34
40
  end
35
-
36
- # TODO: Support 'A'
37
41
  end
38
42
 
39
43
  def control_2
@@ -60,13 +64,15 @@ module VectorBeWinding
60
64
  # Approximate with triangle
61
65
  (start_point - p).cross(control - start_point) +
62
66
  (control - p).cross(end_point - control)
63
- elsif @direction.kind_of?(::Savage::Directions::CubicCurveTo)
67
+ elsif @direction.kind_of?(::Savage::Directions::CubicCurveTo)
64
68
  # Approximate with quadrangle
65
69
  (start_point - p).cross(control_1 - start_point) +
66
70
  (control_1 - p).cross(control_2 - control_1) +
67
71
  (control_2 - p).cross(end_point - control_2)
72
+ elsif @direction.kind_of?(::Savage::Directions::ArcTo)
73
+ # Very rough approximation. TODO: Be more precise
74
+ (start_point - p).cross(end_point - start_point) / 2.0 + (sweep ? 1 : -1)
68
75
  else
69
- # TODO: Support arc
70
76
  (start_point - p).cross(end_point - start_point) / 2.0
71
77
  end
72
78
  end
@@ -92,8 +98,10 @@ module VectorBeWinding
92
98
  ::Savage::Directions::CubicCurveTo.new(
93
99
  control.x, control.y, control_1.x, control_1.y,
94
100
  start_point.x, start_point.y, true)
101
+ when 'A'
102
+ ::Savage::Directions::ArcTo.new(
103
+ radius.x, radius.y, rotation, large_arc, !sweep, start_point.x, start_point.y, true)
95
104
  else
96
- # TODO: Support 'A'
97
105
  raise "Unknown direction: #{@direction}"
98
106
  end
99
107
  end
@@ -1,3 +1,3 @@
1
1
  module VectorBeWinding
2
- VERSION = "0.9.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vector_be_winding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi SASAKI
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2018-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savage
@@ -112,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.6.10
115
+ rubygems_version: 2.6.14
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Let Android vector drawable follow winding-rule.
119
119
  test_files: []
120
- has_rdoc: