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 +4 -4
- data/README.md +18 -17
- data/lib/vector_be_winding/segment.rb +14 -6
- data/lib/vector_be_winding/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed608fa8b0053321860a3b2a15748af4a5bd0fa7
|
4
|
+
data.tar.gz: 8a2788d12f18590eb8de4e417f0e302b25a8e783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1167d9d518c4fb67729a0796fce284dc1c937affde1678d2acdbc2789cd8a098029057b3aebd9cee0f935ca69a56b340932066970db9f6179486a9025d43979
|
7
|
+
data.tar.gz: a3eda6be2f120e09b2ee3a99f1fdf9f4ecd5a539ed29c29c487591e3a1dec59bbf3fdf54ba1022cb534077c035d078e528aca3e9a8e066beedc4d874ab814d77
|
data/README.md
CHANGED
@@ -1,37 +1,38 @@
|
|
1
1
|
# VectorBeWinding 
|
2
2
|
|
3
|
-
Android Vector Drawable is very
|
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
|
-
|
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
|
-
|
16
|
-
|
13
|
+
```
|
14
|
+
gem install vector_be_winding
|
15
|
+
```
|
17
16
|
|
18
17
|
## Usage
|
19
18
|
|
20
|
-
|
19
|
+
Just exec:
|
21
20
|
|
22
|
-
|
21
|
+
`% vbw vector_file.xml vector_file_1.xml ...`
|
23
22
|
|
24
|
-
|
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
|
-
|
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
|
-
##
|
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
|
-
|
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
|
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.
|
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:
|
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.
|
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:
|