Golang image.Point.Add, Div and Eq functions example

package image

 package main

 import (
 "fmt"
 "image"
 )

 func main() {

 var aPoint, bPoint, cPoint image.Point

 aPoint = image.Pt(10, 10)

 bPoint = image.Pt(20, 20)

 // Add
 cPoint = aPoint.Add(bPoint)

 fmt.Println("c X is : ", cPoint.X)

 fmt.Println("c Y is : ", cPoint.Y)

 // Div
 newBPoint := bPoint.Div(2)

 fmt.Println("New b X is : ", newBPoint.X)
 fmt.Println("New b Y is : ", newBPoint.Y)

 // Eq
 equal := aPoint.Eq(cPoint)

 fmt.Println("aPoint equal to cPoint ? ", equal)

 }

Output :

c X is : 30

c Y is : 30

New b X is : 10

New b Y is : 10

References :

http://golang.org/pkg/image/#Point.Add

http://golang.org/pkg/image/#Point.Div

http://golang.org/pkg/image/#Point.Eq

Advertisement