Bug 116731 - [PATCH] graphics/potrace: improve xfig backend
Summary: [PATCH] graphics/potrace: improve xfig backend
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Alejandro Pulver
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-29 08:30 UTC by bf
Modified: 2007-10-21 05:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bf 2007-09-29 08:30:00 UTC
add upstream patch to improve xfig backend:

"May 22, 2007: Updated XFig backend. The following patch to Potrace 1.8 improves the XFig output by adding a depth setting to the spline components. This prevents them from floating to the background when editing. Thanks to Rafael Laboissiere for suggesting this."




diff -ruN potrace.orig/files/patch-backend_xfig.c potrace/files/patch-backend_xfig.c
--- potrace.orig/files/patch-backend_xfig.c	Wed Dec 31 19:00:00 1969
+++ potrace/files/patch-backend_xfig.c	Sat Sep 29 03:00:41 2007
@@ -0,0 +1,114 @@
+Index: ChangeLog
+===================================================================
+--- ChangeLog	(revision 153)
++++ ChangeLog	(revision 154)
+@@ -1,5 +1,9 @@
+ ChangeLog
+ 
++	(2007/05/22) PS1 - xfig backend: added depth to opaque components
++	to avoid them floating to the background. Suggested by Rafael
++	Laboissiere.
++
+ v1.8 2007/04/09
+ 	(2007/04/08) PS1 - portability: use 'test' instead of '[' in shell
+ 	scripts.
+Index: src/backend_xfig.c
+===================================================================
+--- src/backend_xfig.c	(revision 153)
++++ src/backend_xfig.c	(revision 154)
+@@ -124,13 +124,13 @@
+   return n;
+ }
+ 
+-/* do one path. First should be 1 on the very first path, else 0. */
+-static int xfig_path(FILE *fout, potrace_curve_t *curve, trans_t t, int sign) {
++/* do one path. */
++static void xfig_path(FILE *fout, potrace_curve_t *curve, trans_t t, int sign, int depth) {
+   int i;
+   dpoint_t *c;
+   int m = curve->n;
+ 
+-  fprintf(fout, "3 1 0 0 0 %d 50 0 20 0.000 0 0 0 %d\n", sign=='+' ? 32 : 33, npoints(curve, m));
++  fprintf(fout, "3 1 0 0 0 %d %d 0 20 0.000 0 0 0 %d\n", sign=='+' ? 32 : 33, depth, npoints(curve, m));
+ 
+   for (i=0; i<m; i++) {
+     c = curve->c[i];
+@@ -154,15 +154,43 @@
+       break;
+     }
+   }
+-  return 0;
+ }
+ 
++/* render a whole tree */
++static void xfig_write_paths(FILE *fout, potrace_path_t *plist, trans_t t, int depth) {
++  potrace_path_t *p, *q;
++
++  for (p=plist; p; p=p->sibling) {
++    xfig_path(fout, &p->curve, t, p->sign, depth);
++    for (q=p->childlist; q; q=q->sibling) {
++      xfig_path(fout, &q->curve, t, q->sign, depth >= 1 ? depth-1 : 0);
++    }
++    for (q=p->childlist; q; q=q->sibling) {
++      xfig_write_paths(fout, q->childlist, t, depth >= 2 ? depth-2 : 0);
++    }
++  }
++}
++
++/* calculate the depth of a tree. Call with d=0. */
++static int xfig_get_depth(potrace_path_t *plist) {
++  potrace_path_t *p;
++  int max =0;
++  int d;
++
++  for (p=plist; p; p=p->sibling) {
++    d = xfig_get_depth(p->childlist);
++    if (d > max) {
++      max = d;
++    }
++  }
++  return max + 1;
++}
++
+ /* ---------------------------------------------------------------------- */
+ /* Backend. */
+ 
+ /* public interface for XFIG */
+ int page_xfig(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo) {
+-  potrace_path_t *p;
+   trans_t t;
+   double si, co;
+   double origx = imginfo->trans.orig[0] + imginfo->lmar;
+@@ -174,6 +202,7 @@
+   pageformat_t *f;
+   int i;
+   int x0, y0, x1, y1;  /* in xfig's coordinates */
++  int depth;
+   
+   si = sin(info.angle/180*M_PI);
+   co = cos(info.angle/180*M_PI);
+@@ -220,11 +249,21 @@
+   fprintf(fout, "0 33 #%06x\n", info.fillcolor);
+   fprintf(fout, "6 %d %d %d %d\n", x0-75, y1-35, x1+75, y0+35); /* bounding box */
+ 
++  /* determine depth of the tree */
++  depth = xfig_get_depth(plist);
++
++  /* figure out appropriate xfig starting depth. Note: xfig only has 1000 depths available */
++  if (depth <= 40) {
++    depth = 50;
++  } else if (depth < 990) {
++    depth += 10;
++  } else {
++    depth = 999;
++  }
++
+   /* write paths. Note: can never use "opticurve" with this backend -
+      it just does not approximate Bezier curves closely enough.  */
+-  list_forall (p, plist) {
+-    xfig_path(fout, &p->curve, t, p->sign);
+-  }
++  xfig_write_paths(fout, plist, t, depth);
+ 
+   fprintf(fout, "-6\n"); /* end bounding box */
+
Comment 1 bf 2007-09-29 09:45:11 UTC
Please move this PR to the ports category.  I
apologize for the mistake.

bf.


      ____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
Comment 2 Bjoern A. Zeeb freebsd_committer freebsd_triage 2007-09-29 10:27:31 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-ports-bugs

reassign to ports
Comment 3 Alejandro Pulver freebsd_committer freebsd_triage 2007-09-29 22:21:51 UTC
Responsible Changed
From-To: freebsd-ports-bugs->alepulver

I'll take it.
Comment 4 Alejandro Pulver freebsd_committer freebsd_triage 2007-09-29 23:23:08 UTC
State Changed
From-To: open->feedback

Ask maintainer for approval.
Comment 5 Alejandro Pulver freebsd_committer freebsd_triage 2007-09-29 23:23:09 UTC
Hello.

The following PR with a patch has been submitted that affects your
graphics/potrace port. See:

http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/116731

If you approve it please state so in a reply, and if you don't too. Of
course comments and further suggestions are also welcome.

Best Regards,
Ale
Comment 6 Piotr Smyrak 2007-10-04 21:18:45 UTC
On Sat, 29 Sep 2007 19:23:09 -0300, Alejandro Pulver wrote
> 
> The following PR with a patch has been submitted that 
> affects your graphics/potrace port. See:
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/116731
> 
> If you approve it please state so in a reply, and if you 
> don't too. Of course comments and further suggestions are 
> also welcome.

Approved, please commit.
-- 
 Piotr Smyrak
 piotr.smyrak@heron.pl
Comment 7 Alejandro Pulver freebsd_committer freebsd_triage 2007-10-06 02:06:25 UTC
State Changed
From-To: feedback->open

Approved.
Comment 8 dfilter service freebsd_committer freebsd_triage 2007-10-21 04:58:11 UTC
alepulver    2007-10-21 03:58:02 UTC

  FreeBSD ports repository

  Added files:
    graphics/potrace/files patch-backend_xfig.c 
  Log:
  - Add upstream patch to improve xfig backend.
  
  PR:             ports/116731
  Submitted by:   bf <bf2006a@yahoo.com>
  Approved by:    smyru@heron.pl (maintainer)
  
  Revision  Changes    Path
  1.1       +114 -0    ports/graphics/potrace/files/patch-backend_xfig.c (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 9 Alejandro Pulver freebsd_committer freebsd_triage 2007-10-21 04:58:33 UTC
State Changed
From-To: open->closed

Committed. Thanks!