import ( "image" ) func main() { // Create a Point struct with coordinates x=10 and y=20 point := image.Point{10, 20} // Print the Point struct fmt.Println(point) }
func main() { point1 := image.Point{10, 20} point2 := image.Point{5, 10} // Add the two points point3 := point1.Add(point2) // Subtract the two points point4 := point1.Sub(point2) // Print the new points fmt.Println(point3) fmt.Println(point4) }In this example, we create two Point structs, point1 and point2. We add point1 and point2 together and store the result in point3. Similarly, we subtract the two points and store the result in point4. Overall, the Point struct and its associated functions allows us to perform arithmetic operations and manipulate points in a 2D coordinate system.