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
+14.1k Javascript : Prompt confirmation before exit
+4.7k Adding Skype actions such as call and chat into web page examples
+14.8k Golang : Get URI segments by number and assign as variable example
+8.1k Golang : How To Use Panic and Recover
+22.4k Golang : Read directory content with filepath.Walk()
+12.1k Golang : Pagination with go-paginator configuration example
+5.4k Javascript : How to loop over and parse JSON data?
+17.2k Golang : When to use init() function?
+17.3k Golang : How to tell if a file is compressed either gzip or zip ?
+7.8k Golang : Getting Echo framework StartAutoTLS to work