# Polygon filling algorithm example (scanline)

**URL:** <https://discourse.processing.org/t/polygon-filling-algorithm-example-scanline/11778>\
**Category:** Coding Questions\
**Created:** [June 2, 2019, 6:14pm UTC](https://discourse.processing.org/t/polygon-filling-algorithm-example-scanline/11778 "2019-06-02T18:14:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BProcess](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@BProcess](https://discourse.processing.org/u/BProcess)\
**Post date:** [June 2, 2019, 6:14pm UTC](https://discourse.processing.org/t/polygon-filling-algorithm-example-scanline/11778/1 "2019-06-02T18:14:07Z")

</div>

Hi All,

I would like to do the sacn line algorithm in Processing. I have read a lot about it but I have no clue how to start it. Do you have any example or something what helps to start to implement it?

Thanks a lot in advance!

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [June 3, 2019, 9:55am UTC](https://discourse.processing.org/t/polygon-filling-algorithm-example-scanline/11778/2 "2019-06-03T09:55:13Z")

</div>

See Wikipedia article on scanline please

---

<div class="post-metadata">

**Author:** ![BProcess](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@BProcess](https://discourse.processing.org/u/BProcess)\
**Post date:** [June 3, 2019, 7:39pm UTC](https://discourse.processing.org/t/polygon-filling-algorithm-example-scanline/11778/3 "2019-06-03T19:39:16Z")

</div>

Ok, I’ve seen it and I understand how this should work.

What I dont know, how can I store the coordinates of the points where the scan-line goes through the polygon.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [June 5, 2019, 5:33pm UTC](https://discourse.processing.org/t/polygon-filling-algorithm-example-scanline/11778/4 "2019-06-05T17:33:31Z")

</div>

show your code please

see also [Store the coordinates of the mouse clicks](https://discourse.processing.org/t/store-the-coordinates-of-the-mouse-clicks/11745/4)

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 6, 2019, 5:44am UTC](https://discourse.processing.org/t/polygon-filling-algorithm-example-scanline/11778/5 "2019-06-06T05:44:07Z")

</div>

Here are links to several past implementations of scanline / floodfill

- [https://forum.processing.org/two/discussion/comment/110211/#Comment\_110211](https://forum.processing.org/two/discussion/comment/110211/#Comment_110211)
