perfect-shape 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +15 -3
- data/VERSION +1 -1
- data/lib/perfect_shape/path.rb +4 -3
- data/perfect-shape.gemspec +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cd9bf6e78e556604f5a9ff5b26e7b952ca8c61424aac789238c2d5d8961b1c8
|
4
|
+
data.tar.gz: a76a11a91632b22a3b3b136d55ded17ba17b10b940de7186c912bf5cb0642cc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54ca03287c4efe1f2a88ab8ad9a3372c29313460f433be17e7300428ea34264d6fcfbd3bc54dedb3953959295a97669e89553fa450f04ab62e99779638501826
|
7
|
+
data.tar.gz: 4c254bfaa37c9d4254ec2df488a0989a580c5907594b992be1d024d3ddda1f790b5340e3f9205214454f167400b9af182d4ad71cf913336203af411a13d220e6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.0.6
|
4
|
+
|
5
|
+
- Fix issue with `Path#contain?` algorithm not working correclty when `Path` contains non-basic shapes because `shapes.count` is checked instead of `basic_shapes.count`
|
6
|
+
- Document `PerfectShape::MultiPoint`
|
7
|
+
|
3
8
|
## 1.0.5
|
4
9
|
|
5
10
|
- Support Ruby 3.1 by including bundled 'matrix' gem ('>= 0.4.2', '< 1.1.0')
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Perfect Shape 1.0.
|
1
|
+
# Perfect Shape 1.0.6
|
2
2
|
## Geometric Algorithms
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/perfect-shape.svg)](http://badge.fury.io/rb/perfect-shape)
|
4
4
|
[![Test](https://github.com/AndyObtiva/perfect-shape/actions/workflows/ruby.yml/badge.svg)](https://github.com/AndyObtiva/perfect-shape/actions/workflows/ruby.yml)
|
@@ -14,13 +14,13 @@ To ensure accuracy and precision, this library does all its mathematical operati
|
|
14
14
|
Run:
|
15
15
|
|
16
16
|
```
|
17
|
-
gem install perfect-shape -v 1.0.
|
17
|
+
gem install perfect-shape -v 1.0.6
|
18
18
|
```
|
19
19
|
|
20
20
|
Or include in Bundler `Gemfile`:
|
21
21
|
|
22
22
|
```ruby
|
23
|
-
gem 'perfect-shape', '~> 1.0.
|
23
|
+
gem 'perfect-shape', '~> 1.0.6'
|
24
24
|
```
|
25
25
|
|
26
26
|
And, run:
|
@@ -85,6 +85,18 @@ Includes `PerfectShape::PointLocation`
|
|
85
85
|
- `#max_x`: max x
|
86
86
|
- `#max_y`: max y
|
87
87
|
|
88
|
+
### `PerfectShape::MultiPoint`
|
89
|
+
|
90
|
+
Module
|
91
|
+
|
92
|
+
- `::normalize_point_array`: normalizes `Array` of multiple points into (x,y) point coordinate `Array` format per point
|
93
|
+
- `#initialize(points: [])`: initializes `points` with `Array` of multiple points (e.g. useful for shapes like `Line` and `Polygon`).
|
94
|
+
- `#points`: `Array` of multiple points
|
95
|
+
- `#min_x`: min x of all points
|
96
|
+
- `#min_y`: min y of all points
|
97
|
+
- `#max_x`: max x of all points
|
98
|
+
- `#max_y`: max y of all points
|
99
|
+
|
88
100
|
### `PerfectShape::AffineTransform`
|
89
101
|
|
90
102
|
Class
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.6
|
data/lib/perfect_shape/path.rb
CHANGED
@@ -134,7 +134,7 @@ module PerfectShape
|
|
134
134
|
if (x * 0.0 + y * 0.0) == 0.0
|
135
135
|
# N * 0.0 is 0.0 only if N is finite.
|
136
136
|
# Here we know that both x and y are finite.
|
137
|
-
return false if
|
137
|
+
return false if basic_shapes.count < 2
|
138
138
|
mask = winding_rule == :wind_non_zero ? -1 : 1
|
139
139
|
(point_crossings(x, y) & mask) != 0
|
140
140
|
else
|
@@ -161,14 +161,14 @@ module PerfectShape
|
|
161
161
|
def point_crossings(x_or_point, y = nil)
|
162
162
|
x, y = Point.normalize_point(x_or_point, y)
|
163
163
|
return unless x && y
|
164
|
-
return 0 if
|
164
|
+
return 0 if basic_shapes.count == 0
|
165
165
|
movx = movy = curx = cury = endx = endy = 0
|
166
166
|
coords = points.flatten
|
167
167
|
curx = movx = coords[0]
|
168
168
|
cury = movy = coords[1]
|
169
169
|
crossings = 0
|
170
170
|
ci = 2
|
171
|
-
1.upto(
|
171
|
+
1.upto(basic_shapes.count - 1).each do |i|
|
172
172
|
case drawing_types[i]
|
173
173
|
when :move_to
|
174
174
|
if cury != movy
|
@@ -244,6 +244,7 @@ module PerfectShape
|
|
244
244
|
# Lastly, if the path is closed, an extra shape is
|
245
245
|
# added to represent the line connecting the last point to the first
|
246
246
|
def disconnected_shapes
|
247
|
+
# TODO it seems basic_shapes.first should always return a point, but there is a case with CompositeShape that results in a line (shape) not point returned
|
247
248
|
initial_point = start_point = basic_shapes.first.to_a.map {|n| BigDecimal(n.to_s)}
|
248
249
|
final_point = nil
|
249
250
|
the_disconnected_shapes = basic_shapes.drop(1).map do |shape|
|
data/perfect-shape.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: perfect-shape 1.0.
|
5
|
+
# stub: perfect-shape 1.0.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "perfect-shape".freeze
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Andy Maleh".freeze]
|
14
|
-
s.date = "2022-
|
14
|
+
s.date = "2022-11-05"
|
15
15
|
s.description = "Perfect Shape is a collection of pure Ruby geometric algorithms that are mostly useful for GUI manipulation like checking viewport rectangle intersection or containment of a mouse click point in popular geometry shapes such as rectangle, square, arc (open, chord, and pie), ellipse, circle, polygon, and paths containing lines, quadratic b\u00E9zier curves, and cubic bezier curves, potentially with affine transforms applied like translation, scale, rotation, shear/skew, and inversion (including both the Ray Casting Algorithm, aka Even-odd Rule, and the Winding Number Algorithm, aka Nonzero Rule). Additionally, it contains some purely mathematical algorithms like IEEEremainder (also known as IEEE-754 remainder).".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
|
|
47
47
|
]
|
48
48
|
s.homepage = "http://github.com/AndyObtiva/perfect-shape".freeze
|
49
49
|
s.licenses = ["MIT".freeze]
|
50
|
-
s.rubygems_version = "3.3.
|
50
|
+
s.rubygems_version = "3.3.16".freeze
|
51
51
|
s.summary = "Perfect Shape - Geometric Algorithms".freeze
|
52
52
|
|
53
53
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perfect-shape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matrix
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
rubygems_version: 3.3.
|
183
|
+
rubygems_version: 3.3.16
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Perfect Shape - Geometric Algorithms
|