E
E
Evgeny Yakushov2020-11-09 22:42:18
C++ / C#
Evgeny Yakushov, 2020-11-09 22:42:18

How to color a shape?

Good for all! A question. I do not really understand the algorithm for finding a point inside a polygon (in this case, a triangle, but the algorithm should be general). There is a raster display of the figure, stored in an array, and its polygon, which is built by pixels with lines through the Bresenham algorithm, the resulting figure needs to be painted over.
Now at this stage, for convenience, while drawing to a file.

5fa999512a772791049237.png

The result should be like this, that is, do not touch the contour.

5fa99ab98f171074054125.png

There was an idea of ​​line-by-line passing and searching for boundaries, but the problem is that the sequence can go from several units, and at the vertices it’s like a solid line, without a break (here is such a break ----- -11----11---, and the top is usually ------11---- and other variations)

Please help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Antonio Solo, 2020-11-09
@solotony

The algorithm for filling is as follows: you take a point, see if it falls inside the polygon, if it does, you paint
and draw the borders with lines.
how to determine that a point is inside a polygon
how to draw a line bresenham's algorithm

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question