ruby_clipper 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Changelog +7 -0
- data/Gemfile +4 -0
- data/LICENSE.bindings +4 -0
- data/LICENSE.clipper +29 -0
- data/README.md +151 -0
- data/Rakefile +2 -0
- data/ext/clipper/clipper.cpp +3328 -0
- data/ext/clipper/clipper.hpp +306 -0
- data/ext/clipper/extconf.rb +6 -0
- data/ext/clipper/rbclipper.cpp +389 -0
- data/lib/clipper/version.rb +6 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd9e20dcdc1decfc753ebb14ca62cfd8077319aa
|
4
|
+
data.tar.gz: 4796343ef3c486905f58988be7d87eb6822690b4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3165419f7b81ba0ad128fc8f3ce014c3b349a9720b07293399ebbcfeabf0b28d86913a6aa8383c5481b9c6c5a4e2942ebcdfbf264f50587befea475c9b9b2768
|
7
|
+
data.tar.gz: 922ff6f21db74f6134ca47f34daa71ec581a2f806a9e07ca9bb78e7dd7eeeeccef515da39bf1868e1f1e26a986712951a6cd68c87d0a11a5e6236866c6b4bd15
|
data/Changelog
ADDED
data/Gemfile
ADDED
data/LICENSE.bindings
ADDED
data/LICENSE.clipper
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
The Clipper code library, the "Software" (including Delphi and C++ code
|
2
|
+
and accompanying documentation), has been released under the following
|
3
|
+
license, terms and conditions:
|
4
|
+
|
5
|
+
Boost Software License - Version 1.0 - August 17th, 2003
|
6
|
+
http://www.boost.org/LICENSE_1_0.txt
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person or organization
|
9
|
+
obtaining a copy of the software and accompanying documentation covered by
|
10
|
+
this license (the "Software") to use, reproduce, display, distribute,
|
11
|
+
execute, and transmit the Software, and to prepare derivative works of the
|
12
|
+
Software, and to permit third-parties to whom the Software is furnished to
|
13
|
+
do so, all subject to the following:
|
14
|
+
|
15
|
+
The copyright notices in the Software and this entire statement, including
|
16
|
+
the above license grant, this restriction and the following disclaimer,
|
17
|
+
must be included in all copies of the Software, in whole or in part, and
|
18
|
+
all derivative works of the Software, unless such copies or derivative
|
19
|
+
works are solely in the form of machine-executable object code generated by
|
20
|
+
a source language processor.
|
21
|
+
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
25
|
+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
26
|
+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
27
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
28
|
+
DEALINGS IN THE SOFTWARE.
|
29
|
+
|
data/README.md
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
Synopsis
|
2
|
+
==========
|
3
|
+
These are Ruby bindings to Clipper, Angus Johnson's Polygon clipping
|
4
|
+
library. Because Clipper is not readily packaged, and is so beautifully
|
5
|
+
self-contained, I've included the two required files in the package.
|
6
|
+
|
7
|
+
This release contains version 5.0.1 of Clipper.
|
8
|
+
|
9
|
+
* [Clipper Homepage](http://angusj.com/delphi/clipper.php)
|
10
|
+
* [rbclipper](http://github.com/mieko/rbclipper)
|
11
|
+
|
12
|
+
To install:
|
13
|
+
|
14
|
+
gem install ruby_clipper
|
15
|
+
|
16
|
+
Build locally:
|
17
|
+
|
18
|
+
rake install
|
19
|
+
|
20
|
+
|
21
|
+
Simple Usage:
|
22
|
+
===========
|
23
|
+
This shold be enough to get you started. Full documentation is below.
|
24
|
+
|
25
|
+
require 'clipper'
|
26
|
+
|
27
|
+
a = [[0, 0], [0, 100], [100, 100], [100, 0]]
|
28
|
+
b = [[-5, 50], [200, 50], [100, 5]]
|
29
|
+
|
30
|
+
c = Clipper::Clipper.new
|
31
|
+
|
32
|
+
c.add_subject_polygon(a)
|
33
|
+
c.add_clip_polygon(b)
|
34
|
+
c.union :non_zero, :non_zero
|
35
|
+
|
36
|
+
=> [[[100.0, 0.0], [0.0, 0.0], [0.0, 47.85714326530613], [-4.999999, 50.0],
|
37
|
+
[0.0, 50.0], [0.0, 100.0], [100.0, 100.0], [100.0, 50.0],
|
38
|
+
[200.0, 50.0], [100.0, 5.0]]]
|
39
|
+
|
40
|
+
Documentation
|
41
|
+
================
|
42
|
+
|
43
|
+
Clipper is a two-dimensional polygon clipping library. `rbclipper`, the Ruby
|
44
|
+
bindings can be accessed by:
|
45
|
+
|
46
|
+
require 'clipper'
|
47
|
+
|
48
|
+
|
49
|
+
Polygons
|
50
|
+
--------
|
51
|
+
Operations that accept or return polygons are specified as an array of `[x,y]`
|
52
|
+
coordinates, for example, to specify a triangle:
|
53
|
+
|
54
|
+
triangle = [[0,0], [0,100], [50, -100]]
|
55
|
+
|
56
|
+
Clipper supports both holes and complex polygons. Coordinates for output
|
57
|
+
polygons are clockwise for shells, and and counter-clockwise for holes.
|
58
|
+
See force_orientation.
|
59
|
+
|
60
|
+
Note that since 2.8, Clipper defines orientation with respect to a
|
61
|
+
_downward-increasing Y axis_, similar to how many 2D GUI/drawing APIs position
|
62
|
+
coordinate (0,0) at the top-left corner. The bindings have followed Clipper
|
63
|
+
proper in this regard.
|
64
|
+
|
65
|
+
Multiple polygons are represented as simply an array of polygons.
|
66
|
+
|
67
|
+
Fill Types
|
68
|
+
-----------
|
69
|
+
* `:even_odd`
|
70
|
+
|
71
|
+
A point is considered inside the polygon if the number of edge-crossings to
|
72
|
+
get there from outside the shape is an even number.
|
73
|
+
|
74
|
+
* `:non_zero`
|
75
|
+
|
76
|
+
A point is considered inside the polygon if the number of edge-crossings to
|
77
|
+
get there is greater than zero.
|
78
|
+
|
79
|
+
* `:positive`
|
80
|
+
|
81
|
+
See Clipper Homepage.
|
82
|
+
|
83
|
+
* `:negative`
|
84
|
+
|
85
|
+
See Clipper Homepage.
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
Clipper::Clipper Methods
|
90
|
+
-------
|
91
|
+
|
92
|
+
* `Clipper#initialize`
|
93
|
+
|
94
|
+
Creates a new clipper object.
|
95
|
+
|
96
|
+
* `Clipper#add_subject_polygon(polygon)`
|
97
|
+
|
98
|
+
* `Clipper#add_clip_polygon(polygon)`
|
99
|
+
|
100
|
+
Adds a subject or clip polygon to the engine. Boolean operations are
|
101
|
+
calculated as `SUBJECT` *operatation* `CLIP`. Multiple polygons can Pay attention
|
102
|
+
to the orientation of the coordinates given; counter-clockwise for shells and
|
103
|
+
clockwise for holes.
|
104
|
+
|
105
|
+
Multiple subject and clip polygons can be added to the engine for operations.
|
106
|
+
|
107
|
+
* `Clipper#add_subject_polygons(expolygon)`
|
108
|
+
|
109
|
+
* `Clipper#add_clip_polygons(expolygon)`
|
110
|
+
|
111
|
+
Add an "ExPolygon" to the engine. Which is basically a list of polygons - the first is the
|
112
|
+
outside (counter-clock-wise) and the rest, if any, are the holes (clock-wise).
|
113
|
+
Boolean operations consider every expolygon added in this manner to be the same object.
|
114
|
+
|
115
|
+
* `Clipper#multiplier`
|
116
|
+
|
117
|
+
* `Clipper#multiplier=`
|
118
|
+
|
119
|
+
Defaults to 2^10 = 1048576. Clipper since version 4.0 uses integer math instead of floating point.
|
120
|
+
To simplify using floating point coordinates, this multiplier is multiplied to each coordinate value
|
121
|
+
before beeing sent to Clipper, and each result coordinate is divided by the multiplier. Use 1 if you
|
122
|
+
want to use integer coordinates.
|
123
|
+
|
124
|
+
* `Clipper#intersection(subject_fill=:even_odd, clip_fill=:even_odd, result_type=:polygons)`
|
125
|
+
|
126
|
+
* `Clipper#union(subject_fill=:even_odd, clip_fill=:even_odd, result_type=:polygons)`
|
127
|
+
|
128
|
+
* `Clipper#difference(subject_fill=:even_odd, clip_fill=:even_odd, result_type=:polygons)`
|
129
|
+
|
130
|
+
* `Clipper#xor(subject_fill=:even_odd, clip_fill=:even_odd, result_type=:polygons)`
|
131
|
+
|
132
|
+
Performs a boolean operation on the polygons that have been added to the
|
133
|
+
clipper object. The result is a list of polygons or expolygons, depending on result_type being :polygons or :expolygons
|
134
|
+
|
135
|
+
* `Clipper#offset_polygons(polygons, delta, join_type, miter_limit=0)`
|
136
|
+
|
137
|
+
Expands the polygons by delta. Use negative delta to compress the polygons. join_type is any of :jtSquare, :jtButt, :jtMiter or :jtRound.
|
138
|
+
Use miter_limit to make sharp joints not extend too long, by cutting off the edge.
|
139
|
+
|
140
|
+
* `Clipper#area(polygon)`
|
141
|
+
|
142
|
+
Returns the area of the supplied polygon. The returned area is negative if the polygon points are oriented clockwise, positive otherwise. Obeys the multiplier and use_full_coordinate_range settings for the clipper object.
|
143
|
+
|
144
|
+
* `Clipper#Orientation(polygon)`
|
145
|
+
|
146
|
+
Orientation returns a boolean value that is based on the polygon's orientation relative to the display's orientation (ie Y-axis positive upward vs Y-axis positive downward).
|
147
|
+
|
148
|
+
* On Y-axis positive upward displays, Orientation will return true if the polygon's orientation is counter-clockwise.
|
149
|
+
* On Y-axis positive downward displays, Orientation will return true if the polygon's orientation is clockwise.
|
150
|
+
|
151
|
+
|
data/Rakefile
ADDED