Recommend this page to a friend! |
Classes of Win Aung Cho | PHP Rectangle Class | README.md | Download |
|
DownloadPHP-RECTSLIBThis class Lib help you to construct the rectangles using various logical operations such as Union, Intersect and Subtract. It will generate the border edges of non-overlapped rectangles. JScript version AlgorythmAlgorythm is very simple. - A region on which contains all the rectangles is divided into several rectangles according to the corners of the rectangles. - Remove the rectangles above which does not lie inside all rectangles. This step gives the non-overlapped union of the rectangles. - Then choose or remove the rectangles which lies inside the subject rectangles according to boolean operation union, intersect or subtract. Operation procedureCreate rectanglesRectangles are represenred by the associative array in which diagonal points p1 and p2 are stored. Other variables for drawing are name, color and state. Point p1 is always upper left corner and p2 is for lower right of rectangles so that p1 has smaller value of x and y then p2.
Merge all rectangles into meshList all x and y coordinates from the corner points p1, p2 of rectangles. Sort x and y list and then create rectangles for all x and y. Get (2n-1)^2 mesh rectangles for n original rectangles.
Generate rectangle operationSelect mesh by checking inside or not the desired rectangles which for logical operation. Eg. If A B C D E are the recangles, - For union of [A B C] & [D E], mesh must be lied in side both of [A B C] & [D E]. - For subtract [B E] from [A B C D], mesh must be inside the [A B C D] and outside of [B E]. - For intersect [A B C D] & [B E], mesh must be inside of both [A B C] & [D E].
Generate bounding edgesGenerate edges of each rectangles and select external edges by removing common edges.
Check with ImagesOriginal Rectangles
Start meshing for all rectanglesMeshing and get union of rectangles
Intersection of all with 2 rectangles
Subtract of 2 from all
ContactContact me for comercial use via mail winaungcho@gmail.com. |