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
Advertisement
Something interesting
Tutorials
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+27.6k PHP : Convert(cast) string to bigInt
+21.6k Golang : Encrypt and decrypt data with TripleDES
+13.7k Golang : Image to ASCII art example
+5.8k Javascript : How to replace HTML inside <div>?
+18.6k Golang : Generate thumbnails from images
+13.2k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+18.2k Golang : Get command line arguments
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+20.7k Android Studio : AlertDialog and EditText to get user string input example
+35.9k Golang : Integer is between a range