# Detect shapes split by intersecting lines

**URL:** <https://discourse.processing.org/t/detect-shapes-split-by-intersecting-lines/31641>\
**Category:** Coding Questions\
**Created:** [August 9, 2021, 8:37am UTC](https://discourse.processing.org/t/detect-shapes-split-by-intersecting-lines/31641 "2021-08-09T08:37:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hkjung](https://avatars.discourse-cdn.com/v4/letter/h/c89c15/32.png) [@hkjung](https://discourse.processing.org/u/hkjung)\
**Post date:** [August 9, 2021, 8:37am UTC](https://discourse.processing.org/t/detect-shapes-split-by-intersecting-lines/31641/1 "2021-08-09T08:37:14Z")

</div>

I want to detect separate shapes as lines split the canvas. I saved line intersection points in the list of PVectors, but don’t know how to connect points that complete split shapes separately.

Here’s a sample image that has 4 lines splitting the canvas with their intersection points marked in red and saved in the list (the left one). I also saved in the same list the corners and default line points marked in black. Is there any way to detect all split shapes separately, for example, to apply different colors to each? (The image on the right is what I want to.)

![images](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a23cb18892311f51e00bb78d1118be84b3498dd6.png)

---

<div class="post-metadata">

**Author:** ![hkjung](https://avatars.discourse-cdn.com/v4/letter/h/c89c15/32.png) [@hkjung](https://discourse.processing.org/u/hkjung)\
**Post date:** [August 9, 2021, 9:12am UTC](https://discourse.processing.org/t/detect-shapes-split-by-intersecting-lines/31641/2 "2021-08-09T09:12:39Z")

</div>

This seems to be a similar question and answers: [Detecting all the shapes formed by intersecting lines - #5 by jeremydouglass](https://discourse.processing.org/t/detecting-all-the-shapes-formed-by-intersecting-lines/11372/5) (Still, I am not sure how to connect intersection points to separate shapes.)

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [August 9, 2021, 9:18am UTC](https://discourse.processing.org/t/detect-shapes-split-by-intersecting-lines/31641/3 "2021-08-09T09:18:11Z")

</div>

I was working on this just last night 😃 .

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a5c9dd2812351778b6407a645aee1d5648753539.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3672ee69e2c294c6862fb3587bfe4f086247fdcc.png) ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/df4eb0f34afce2e393c3474655bc875181311fc7.png)

The feature will be included in the next release of [Processing Geometry Suite](https://discourse.processing.org/t/processing-geometry-suite/29924) (for now the code is in the [dev](https://github.com/micycle1/PGS/tree/dev) branch – you don’t even need to compute points of intersection, simply provide a list of line segment vertices).

---

<div class="post-metadata">

**Author:** ![hkjung](https://avatars.discourse-cdn.com/v4/letter/h/c89c15/32.png) [@hkjung](https://discourse.processing.org/u/hkjung)\
**Post date:** [August 9, 2021, 9:25am UTC](https://discourse.processing.org/t/detect-shapes-split-by-intersecting-lines/31641/4 "2021-08-09T09:25:51Z")

</div>

Awesome, other examples look great too! Thank you!

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [August 10, 2021, 6:47pm UTC](https://discourse.processing.org/t/detect-shapes-split-by-intersecting-lines/31641/5 "2021-08-10T18:47:00Z")

</div>

This functionality has now been [released](https://github.com/micycle1/PGS/releases/tag/1.1.2). The method in question is `PGS_Processing.polygonizeLines()`.
