github.com/unidoc/unidoc@v2.2.0+incompatible/pdf/contentstream/draw/point.go (about)

     1  /*
     2   * This file is subject to the terms and conditions defined in
     3   * file 'LICENSE.md', which is part of this source code package.
     4   */
     5  
     6  package draw
     7  
     8  import "fmt"
     9  
    10  type Point struct {
    11  	X float64
    12  	Y float64
    13  }
    14  
    15  func NewPoint(x, y float64) Point {
    16  	point := Point{}
    17  	point.X = x
    18  	point.Y = y
    19  	return point
    20  }
    21  
    22  func (p Point) Add(dx, dy float64) Point {
    23  	p.X += dx
    24  	p.Y += dy
    25  	return p
    26  }
    27  
    28  // Add vector to a point.
    29  func (this Point) AddVector(v Vector) Point {
    30  	this.X += v.Dx
    31  	this.Y += v.Dy
    32  	return this
    33  }
    34  
    35  func (p Point) String() string {
    36  	return fmt.Sprintf("(%.1f,%.1f)", p.X, p.Y)
    37  }