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
+15.2k Golang : Accurate and reliable decimal calculations
+6k PHP : How to check if an array is empty ?
+38.1k Golang : Read a text file and replace certain words
+43.5k Golang : Get hardware information such as disk, memory and CPU usage
+15.7k Golang : Get checkbox or extract multipart form data value example
+29.4k Golang : JQuery AJAX post data to server and send data back to client example
+23.2k Golang : Print out struct values in string format
+6k Fontello : How to load and use fonts?
+5k Python : Convert(cast) bytes to string example
+16.8k Golang : Get own process identifier
+10k Golang : Convert octal value to string to deal with leading zero problem
+20.2k Golang : How to get struct tag and use field name to retrieve data?