Documentation ¶
Overview ¶
Package polygon deals with polygons, ie paths with straight lines.
This is, besides other functionality, a proxy class for a polyclip package from
https://github.com/akavel/polyclip-go
(See CREDITS file for details)
BSD License ¶
Copyright (c) 2017-20, Norbert Pillmayer (norbert@pillmayer.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of this software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Index ¶
- func AsString(pg Polygon) string
- func L() tracing.Trace
- func Pr2Pt(p arithm.Pair) pc.Point
- func Pt2Pr(pt pc.Point) arithm.Pair
- type GPPolygon
- func (pg *GPPolygon) AppendSubpath(p Polygon) *GPPolygon
- func (pg *GPPolygon) Copy() *GPPolygon
- func (pg *GPPolygon) Cycle() *GPPolygon
- func (pg *GPPolygon) IsCycle() bool
- func (pg *GPPolygon) Knot(pr arithm.Pair) *GPPolygon
- func (pg *GPPolygon) N() int
- func (pg *GPPolygon) Pt(i int) arithm.Pair
- func (pg *GPPolygon) Reverse()
- func (pg *GPPolygon) String() string
- func (pg *GPPolygon) Subpath(from, to int)
- type Polygon
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GPPolygon ¶
type GPPolygon struct {
// contains filtered or unexported fields
}
GPPolygon is a concrete implementation of Polygon, based on Go-Polygon's types.
func NullPolygon ¶
func NullPolygon() *GPPolygon
NullPolygon creates an empty polygon. This is the starting point for a builder-like functionality. Clients start with a null-polygon and subsequently add knots to it.
Example (package qualifiers omitted for clarity and brevity):
polygon := NullPolygon().Knot(P(1,2)).Knot(P(12,5)).Knot(P(20,3.5)).Cycle()
func (*GPPolygon) AppendSubpath ¶
AppendSubpath appends a polygon to a polygon.
type Polygon ¶
type Polygon interface { IsCycle() bool // is this a cyclic polygon, i.e, is it complete? N() int // number of knots in the polygon Pt(int) arithm.Pair // knot #i modulo N }
Polygon is an interface for immutable polygons.
func Difference ¶
Difference constructs the difference of 2 polygons. Returns a new polygon.
func Intersection ¶
Intersection constructs the intersection of 2 polygons. Returns a new polygon.