#Vectorio point withinness

1 messages · Page 1 of 1 (latest)

abstract widget
#

Yeah this could happen for any arbitrary shape. What’s the use case you have in mind?

#

Missed the livestream. Man it’s a long one! Any hints where you had this idea?

gleaming umbra
#

They wanted to put the tree lights within the Christmas tree.

wild bison
#

@abstract widget to expand a bit. We have a tree drawn with multiple polygons (Triangles) inside of a for loop:

#

The question that came up was could we choose random pixels on the display and then determine whether or not they were colored green. That way we could select N random locations that are on the tree and place colorful circle ornaments at those locations.

wild bison
#

Thinking about this a different way maybe we don't care about the color of the pixel specifically but just whether or not it is inside of the vectorio shape.

#

For interactive UI controls we use a function contains(touch_piont) which accepts a tuple argument representing a point on the display. The function returns true if the point is contained within the shape of the control. If vectorio shapes had a similar function we could use it for this.
If it were possible to do something like:

points=[(5, 5), (100, 20), (20, 20), (20, 100)]
polygon = vectorio.Polygon(pixel_shader=palette, points=points, x=0, y=0)
if polygon.contains((25, 25)):
    print("point was inside the shape")
#

this would allow the ornament placing behavior mentioned above to work. But would also make it very easy to use vectorio shapes as touch points within an interactive UI.

abstract widget
#

Neat, this sounds great. Thanks for the detail! You can open an issue/feature request and assign it to me or I’ll just get to it sooner or later.

Bitmapsaver seems like a reasonable workaround but for the touch purpose as well as lightweightness (saving a screenshot is not exactly an instantaneous command) and some other reasons (might be a gateway to supporting python-defined shapes) (and it’s one step closer to masking) this seems like a natural inclusion.