# XPCE: How to fill a path of lines and bezier curves?

**URL:** <https://swi-prolog.discourse.group/t/xpce-how-to-fill-a-path-of-lines-and-bezier-curves/7379>\
**Category:** Help!\
**Tags:** xpce\
**Created:** [April 16, 2024, 10:46am UTC](https://swi-prolog.discourse.group/t/xpce-how-to-fill-a-path-of-lines-and-bezier-curves/7379 "2024-04-16T10:46:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwon-young](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/kwon-young/32/4841_2.png) [@kwon-young](https://swi-prolog.discourse.group/u/kwon-young)\
**Post date:** [April 16, 2024, 10:46am UTC](https://swi-prolog.discourse.group/t/xpce-how-to-fill-a-path-of-lines-and-bezier-curves/7379/1 "2024-04-16T10:46:01Z")

</div>

Hello,  
I am currently trying to parse and draw [svg d path](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#path) using prolog.  
I found that xpce can draw lines, bezier curves and arcs which are all the graphical components needed to draw the path.  
However, how would I fill such path ?

I have found the [`path`](https://www.swi-prolog.org/packages/xpce/UserGuide/summary.html#class:path) class in xpce but I believe we can only draw a polyline or a smooth line with a list of points.  
Would it be possible to pass a list of `line/4` and `bezier_curve/4` instead ?

Here is an example of a list of lines and bezier curves that I would like to fill :

```prolog
bezier_curve(point(0,-39),point(200,133),point(0,29),point(73,133))
bezier_curve(point(200,133),point(314,38),point(266,133),point(314,96))
bezier_curve(point(314,38),point(96,-133),point(314,-46),point(208,-133))
bezier_curve(point(96,-133),point(0,-39),point(32,-133),point(0,-103))
line(0,-39,0,-39)

```

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [April 16, 2024, 1:43pm UTC](https://swi-prolog.discourse.group/t/xpce-how-to-fill-a-path-of-lines-and-bezier-curves/7379/2 "2024-04-16T13:43:58Z")

</div>

> [@kwon-young](#):
>
> However, how would I fill such path ?

I’m afraid you can’t, unless you can build the final shape from a number of things that can be filled each. Smooth paths use bezier curves (I think), so maybe you can combine arcs, smooth and non-smooth paths?

---

<div class="post-metadata">

**Author:** ![kwon-young](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/kwon-young/32/4841_2.png) [@kwon-young](https://swi-prolog.discourse.group/u/kwon-young)\
**Post date:** [April 16, 2024, 3:45pm UTC](https://swi-prolog.discourse.group/t/xpce-how-to-fill-a-path-of-lines-and-bezier-curves/7379/3 "2024-04-16T15:45:08Z")

</div>

> [@jan](#):
>
> Smooth paths use bezier curves (I think)

Do you know if we can modify the control points of the bezier curves of smooth paths ?  
As a last resort, I suppose I could interpolate points from my curves and draw that.  
Although, that does not help with multi path shapes…

By the way, I have stumbled upon the PceDraw program and I kind of love it 🙂  
Is there a way to send a list of drawing commands to PceDraw ?  
I have read the `realize_drawing/2` from `library('draw/importpl')` but that does not draw inside PceDraw but in a simple device.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [April 16, 2024, 7:11pm UTC](https://swi-prolog.discourse.group/t/xpce-how-to-fill-a-path-of-lines-and-bezier-curves/7379/4 "2024-04-16T19:11:08Z")

</div>

> [@kwon-young](#):
>
> Do you know if we can modify the control points of the bezier curves of smooth paths ?

I don’t recall. Check the source 🙂

> [@kwon-young](#):
>
> Is there a way to send a list of drawing commands to PceDraw ?

I do not think so. After all it is simply a device with objects displayed on it, so it should be ewasy enough to create a drawing from Prolog rather then through the UI.

Enjoy 🙂
