Golang image.Point.String and Sub functions example
package image
Golang image.Point.String and Sub functions usage example
package main
import (
"fmt"
"image"
)
func main() {
var aPoint, bPoint image.Point
aPoint = image.Pt(10, 10)
bPoint = image.Pt(200, 200)
// String
fmt.Println("aPoint in string format :", aPoint.String())
fmt.Println("bPoint in string format :", bPoint.String())
// Sub
var pPoint, qPoint image.Point
pPoint = image.Pt(0, 0)
qPoint = image.Pt(20, 20)
pqPoint := pPoint.Sub(qPoint) // Subtract p - q
fmt.Println("p-q vector is : ", pqPoint.String())
}
Output :
aPoint in string format : (10,10)
bPoint in string format : (200,200)
p-q vector is : (-20,-20)
References :
See also : Golang image.Point.In, Mod and Mul functions example
Advertisement
Something interesting
Tutorials
+11.3k Golang : Post data with url.Values{}
+15.9k Golang : Read a file line by line
+8.8k Yum Error: no such table: packages
+8.3k Golang : Check if integer is power of four example
+17.5k Golang : Clone with pointer and modify value
+7.1k Nginx : How to block user agent ?
+10.1k Golang : Compare files modify date example
+9.8k Golang : Format strings to SEO friendly URL example
+10.4k Golang : cannot assign type int to value (type uint8) in range error
+20.8k Golang : Convert date string to variants of time.Time type examples
+6.1k Golang : How to write backslash in string?
+12.2k Golang : Detect user location with HTML5 geo-location