Logo

Programming-Idioms

History of Idiom 178 > diff from v7 to v8

Edit summary for version 8 by plusmid:
New Go implementation by user [plusmid]
ā†·

Version 7

2019-03-19, 16:57:26

Version 8

2019-09-26, 14:44:54

Idiom #178 Check if point is inside rectangle

Set boolean b to true if if the point with coƶrdinates (x,y) is inside the rectangle with coƶrdinates (x1,y1,x2,y2) , or to false otherwise.
Describe if the edges are considered to be inside the rectangle.

Idiom #178 Check if point is inside rectangle

Set boolean b to true if if the point with coƶrdinates (x,y) is inside the rectangle with coƶrdinates (x1,y1,x2,y2) , or to false otherwise.
Describe if the edges are considered to be inside the rectangle.

Imports
import "image"
Code
p := image.Pt(x, y)
r := image.Rect(x1, y1, x2, y2)
b := p.In(r)
Comments bubble
Points on the edge of the rectangle are considered as in the rectangle.