9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] libdraw: add bezierpts
@ 2021-01-01 15:53 telephil9
  2021-01-06 20:13 ` [9front] " telephil9
  0 siblings, 1 reply; 4+ messages in thread
From: telephil9 @ 2021-01-01 15:53 UTC (permalink / raw)
  To: 9front; +Cc: telephil9

Hi,

Happy new year to everyone!

This patch exposes a new bezierpts function similar to the current bezsplinepts.
Note that this merely makes it visible as it was already present in libdraw.
===
diff -r f020e57da8d6 sys/include/draw.h
--- a/sys/include/draw.h	Thu Dec 17 20:26:38 2020 -0800
+++ b/sys/include/draw.h	Fri Jan 01 16:48:33 2021 +0100
@@ -436,6 +436,7 @@
 extern Point	stringsubfont(Image*, Point, Image*, Subfont*, char*);
 extern int		bezier(Image*, Point, Point, Point, Point, int, int, int, Image*, Point);
 extern int		bezierop(Image*, Point, Point, Point, Point, int, int, int, Image*, Point, Drawop);
+extern int		bezierpts(Point, Point, Point, Point, Point**);
 extern int		bezspline(Image*, Point*, int, int, int, int, Image*, Point);
 extern int		bezsplineop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
 extern int		bezsplinepts(Point*, int, Point**);
diff -r f020e57da8d6 sys/src/libdraw/bezier.c
--- a/sys/src/libdraw/bezier.c	Thu Dec 17 20:26:38 2020 -0800
+++ b/sys/src/libdraw/bezier.c	Fri Jan 01 16:48:33 2021 +0100
@@ -98,12 +98,23 @@
 }
 
 static void
-bezierpts(Plist *l, Point p0, Point p1, Point p2, Point p3)
+_bezierpts(Plist *l, Point p0, Point p1, Point p2, Point p3)
 {
 	bpts(l, p0, p1, p2, p3);
 	appendpt(l, p3);
 }
 
+int
+bezierpts(Point p0, Point p1, Point p2, Point p3, Point **pp)
+{
+	Plist l;
+	l.p = nil;
+	l.np = 0;
+	_bezierpts(&l, p0, p1, p2, p3);
+	*pp = l.p;
+	return l.np;
+}
+
 static void
 _bezsplinepts(Plist *l, Point *pt, int npt)
 {
@@ -167,7 +178,7 @@
 	Plist l;
 
 	l.np = 0;
-	bezierpts(&l, p0, p1, p2, p3);
+	_bezierpts(&l, p0, p1, p2, p3);
 	if(l.np == -1)
 		return 0;
 	if(l.np != 0){
@@ -211,7 +222,7 @@
 	Plist l;
 
 	l.np = 0;
-	bezierpts(&l, p0, p1, p2, p3);
+	_bezierpts(&l, p0, p1, p2, p3);
 	if(l.np == -1)
 		return 0;
 	if(l.np != 0){
===

Updated man page:
===
diff -r f020e57da8d6 sys/man/2/draw
--- a/sys/man/2/draw	Thu Dec 17 20:26:38 2020 -0800
+++ b/sys/man/2/draw	Fri Jan 01 16:49:11 2021 +0100
@@ -103,6 +103,8 @@
 		int end0, int end1, int radius, Image *src, Point sp,
 		Drawop op)
 .PB
+int	bezierpts(Point p0, Point p1, Point p2, Point p3, Point **pp)
+.PB
 int	bezspline(Image *dst, Point *pt, int npt, int end0, int end1,
 		int radius, Image *src, Point sp)
 .PB
@@ -603,6 +605,16 @@
 in
 .IR dst .
 .TP
+\f5bezierpts(\f2a\fP, \f2b\fP, \f2c\fP, \f2d\fP, \f2pp\fP)
+.I Bezierpts
+returns in
+.I pp
+a list of points making up the open polygon that
+.I bezier
+would draw.
+The caller is responsible for freeing
+.IR *pp .
+.TP
 \f5bezspline(\f2dst\fP, \f2p\fP, \f2np\fP, \f2end0\fP, \f2end1\fP, \f2thick\fP, \f2src\fP, \f2sp\fP)
 .I Bezspline
 takes the same arguments as
===

--phil

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [9front] Re: [PATCH] libdraw: add bezierpts
  2021-01-01 15:53 [9front] [PATCH] libdraw: add bezierpts telephil9
@ 2021-01-06 20:13 ` telephil9
  2021-01-06 20:51   ` ori
  0 siblings, 1 reply; 4+ messages in thread
From: telephil9 @ 2021-01-06 20:13 UTC (permalink / raw)
  To: 9front, telephil9; +Cc: 9front

Hi,

It seems my mail has gone unnocited.
Ping ?

Thanks

--phil

Quoth telephil9@gmail.com:
> Hi,
> 
> Happy new year to everyone!
> 
> This patch exposes a new bezierpts function similar to the current bezsplinepts.
> Note that this merely makes it visible as it was already present in libdraw.
> ===
> diff -r f020e57da8d6 sys/include/draw.h
> --- a/sys/include/draw.h	Thu Dec 17 20:26:38 2020 -0800
> +++ b/sys/include/draw.h	Fri Jan 01 16:48:33 2021 +0100
> @@ -436,6 +436,7 @@
>  extern Point	stringsubfont(Image*, Point, Image*, Subfont*, char*);
>  extern int		bezier(Image*, Point, Point, Point, Point, int, int, int, Image*, Point);
>  extern int		bezierop(Image*, Point, Point, Point, Point, int, int, int, Image*, Point, Drawop);
> +extern int		bezierpts(Point, Point, Point, Point, Point**);
>  extern int		bezspline(Image*, Point*, int, int, int, int, Image*, Point);
>  extern int		bezsplineop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
>  extern int		bezsplinepts(Point*, int, Point**);
> diff -r f020e57da8d6 sys/src/libdraw/bezier.c
> --- a/sys/src/libdraw/bezier.c	Thu Dec 17 20:26:38 2020 -0800
> +++ b/sys/src/libdraw/bezier.c	Fri Jan 01 16:48:33 2021 +0100
> @@ -98,12 +98,23 @@
>  }
>  
>  static void
> -bezierpts(Plist *l, Point p0, Point p1, Point p2, Point p3)
> +_bezierpts(Plist *l, Point p0, Point p1, Point p2, Point p3)
>  {
>  	bpts(l, p0, p1, p2, p3);
>  	appendpt(l, p3);
>  }
>  
> +int
> +bezierpts(Point p0, Point p1, Point p2, Point p3, Point **pp)
> +{
> +	Plist l;
> +	l.p = nil;
> +	l.np = 0;
> +	_bezierpts(&l, p0, p1, p2, p3);
> +	*pp = l.p;
> +	return l.np;
> +}
> +
>  static void
>  _bezsplinepts(Plist *l, Point *pt, int npt)
>  {
> @@ -167,7 +178,7 @@
>  	Plist l;
>  
>  	l.np = 0;
> -	bezierpts(&l, p0, p1, p2, p3);
> +	_bezierpts(&l, p0, p1, p2, p3);
>  	if(l.np == -1)
>  		return 0;
>  	if(l.np != 0){
> @@ -211,7 +222,7 @@
>  	Plist l;
>  
>  	l.np = 0;
> -	bezierpts(&l, p0, p1, p2, p3);
> +	_bezierpts(&l, p0, p1, p2, p3);
>  	if(l.np == -1)
>  		return 0;
>  	if(l.np != 0){
> ===
> 
> Updated man page:
> ===
> diff -r f020e57da8d6 sys/man/2/draw
> --- a/sys/man/2/draw	Thu Dec 17 20:26:38 2020 -0800
> +++ b/sys/man/2/draw	Fri Jan 01 16:49:11 2021 +0100
> @@ -103,6 +103,8 @@
>  		int end0, int end1, int radius, Image *src, Point sp,
>  		Drawop op)
>  .PB
> +int	bezierpts(Point p0, Point p1, Point p2, Point p3, Point **pp)
> +.PB
>  int	bezspline(Image *dst, Point *pt, int npt, int end0, int end1,
>  		int radius, Image *src, Point sp)
>  .PB
> @@ -603,6 +605,16 @@
>  in
>  .IR dst .
>  .TP
> +\f5bezierpts(\f2a\fP, \f2b\fP, \f2c\fP, \f2d\fP, \f2pp\fP)
> +.I Bezierpts
> +returns in
> +.I pp
> +a list of points making up the open polygon that
> +.I bezier
> +would draw.
> +The caller is responsible for freeing
> +.IR *pp .
> +.TP
>  \f5bezspline(\f2dst\fP, \f2p\fP, \f2np\fP, \f2end0\fP, \f2end1\fP, \f2thick\fP, \f2src\fP, \f2sp\fP)
>  .I Bezspline
>  takes the same arguments as
> ===
> 
> --phil

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] Re: [PATCH] libdraw: add bezierpts
  2021-01-06 20:13 ` [9front] " telephil9
@ 2021-01-06 20:51   ` ori
  2021-01-06 21:04     ` telephil9
  0 siblings, 1 reply; 4+ messages in thread
From: ori @ 2021-01-06 20:51 UTC (permalink / raw)
  To: 9front, telephil9; +Cc: 9front

Quoth telephil9@gmail.com:
> Hi,
> 
> It seems my mail has gone unnocited.
> Ping ?
> 
> Thanks
> 
> --phil
> 
> Quoth telephil9@gmail.com:
> > Hi,
> > 
> > Happy new year to everyone!
> > 
> > This patch exposes a new bezierpts function similar to the current bezsplinepts.
> > Note that this merely makes it visible as it was already present in libdraw.

I'd started looking at this, and it just gives a set of points around the edge
of the bezier. I'm wondering why you need this, and what makes this API the right
solution?

It makes more sense as an implementation detalil to me, for tesselating the polygon
as it gets rendered.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] Re: [PATCH] libdraw: add bezierpts
  2021-01-06 20:51   ` ori
@ 2021-01-06 21:04     ` telephil9
  0 siblings, 0 replies; 4+ messages in thread
From: telephil9 @ 2021-01-06 21:04 UTC (permalink / raw)
  To: 9front, ori, telephil9; +Cc: 9front

[-- Attachment #1: Type: text/plain, Size: 384 bytes --]

Quoth ori@eigenstate.org:
> I'd started looking at this, and it just gives a set of points around the edge
> of the bezier. I'm wondering why you need this, and what makes this API the right
> solution?

I use this to do SVG rendering in netsurf (see screenshot).
For this I need to build a path that is composed of several lines and/or bezier curves so I need the individual points.

[-- Attachment #2: ns_svg_working.png --]
[-- Type: image/png, Size: 38025 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-06 21:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-01 15:53 [9front] [PATCH] libdraw: add bezierpts telephil9
2021-01-06 20:13 ` [9front] " telephil9
2021-01-06 20:51   ` ori
2021-01-06 21:04     ` telephil9

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/9front

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9front 9front/ http://inbox.vuxu.org/9front \
		9front@9front.org
	public-inbox-index 9front

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9front


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git