1 Star 0 Fork 0

coodder / unipdf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
point.go 840 Bytes
一键复制 编辑 原始数据 按行查看 历史
jhonm 提交于 2023-08-07 15:31 . init
package draw
import (
"fmt"
"gitee.com/coodder/unipdf/internal/transform"
)
// Point represents a two-dimensional point.
type Point struct {
X float64
Y float64
}
// NewPoint returns a new point with the coordinates x, y.
func NewPoint(x, y float64) Point {
return Point{X: x, Y: y}
}
// Add shifts the coordinates of the point with dx, dy and returns the result.
func (p Point) Add(dx, dy float64) Point {
p.X += dx
p.Y += dy
return p
}
// AddVector adds vector to a point.
func (p Point) AddVector(v Vector) Point {
p.X += v.Dx
p.Y += v.Dy
return p
}
// Rotate returns a new Point at `p` rotated by `theta` degrees.
func (p Point) Rotate(theta float64) Point {
r := transform.NewPoint(p.X, p.Y).Rotate(theta)
return NewPoint(r.X, r.Y)
}
func (p Point) String() string {
return fmt.Sprintf("(%.1f,%.1f)", p.X, p.Y)
}
Go
1
https://gitee.com/coodder/unipdf.git
git@gitee.com:coodder/unipdf.git
coodder
unipdf
unipdf
v1.2.0

搜索帮助

53164aa7 5694891 3bd8fe86 5694891