A testing program that gathers 4 Filling Algorithms based on Android and implemented in Java. These algorithms are:
Seed Filling Algorithm (种子填充算法):
In this program this algorithm is easily to cause 'Stack Overflow', so it is usually Not Recommended。
Point-by-point Filling Algorithm (逐点判断算法):
Scanline Filling Algorithm (扫描线填充算法):
Active-edge-table Filling Algorithm (活性边表填充算法):
In this program, I have improved the traditional active-edge-table filling algorithm and make it enable to adaptively find the better scanning direction.If you want to learn more please refer to file 一种强鲁棒性自适应活性边表算法.pdf in this repository.
How to Test
- Draw a polygon on the canvas as you want.
- Click a button below (i.e. a filling algorithm) to fill the polygon with red color.Notes:
- if you choose 'Seed Filling Algorithm (the first button)' or 'Scanline Filling Algorithm (the third button)', you must have to click anywhere in polygon to appoint a point (i.e. the seed). Only in this way can these 2 filling processes begin.
- if you choose the other algorithms, you don't have to take any other subsequent actions.
- The other buttons' usages:
- the first three buttons in the second row respectively mean scaning the polygon in portrait, landscape and the best direction when use Active-edge-table Filling Algorithm.
- the last button in the first row means scanning without checking and correcting the x coordinates of the adjoining crossover points in polygon when use Active-edge-table Filling Algorithm.
- the last button in the second row means clearing the canvas.
Look at the top left corner:
- 外接矩形面积(Area of Bounding Rectangle): means the area of bounding rectangle for the polygon.
- 横度 (Horizontal Extent): means the offset or stretching extent in horizontal direction for the polygon.
- 纵度 (Vertical Extent): means the offset or stretching extent in vertical direction for the polygon.
- 运行时间 (Runtime): means the runtime of the alogrithm you select.
Environment and Configurations
- Download and install Android Studio.
- Install Android SDK 4.4 but is not necessary.
- Import the whole project 'ScanlineTest' into Android Studio.
- At last, maybe you should enter 'File > Settings > Editor > File Encodings' and adjust 'IDE Encoding', 'Project Encoding' and 'Default encoding for properties files' to 'GBK'.
If you are interested in 'Filling Algorithms', you could refer to some books about 'Computer Graphics'.