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.2k Golang : Proper way to test CIDR membership of an IP 4 or 6 address example
+4.5k Java : Generate multiplication table example
+7.1k Golang : Validate credit card example
+15.3k Golang : How to get Unix file descriptor for console and file
+46.4k Golang : Encode image to base64 example
+10.4k Golang : Generate random integer or float number
+13.3k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+9.7k Golang : Sort and reverse sort a slice of floats
+30k Golang : Get time.Duration in year, month, week or day
+37.7k Golang : Comparing date or timestamp
+29.2k Golang : missing Git command