Browse Source

ap/potrace: Added.

slackware-14.2
Damien Goutte-Gattat 12 years ago
parent
commit
ee5613518e
4 changed files with 247 additions and 0 deletions
  1. +114
    -0
      ap/potrace/potrace-1.8-xfig.patch
  2. +1
    -0
      ap/potrace/potrace-1.8.tar.gz.sha1
  3. +120
    -0
      ap/potrace/potrace.SlackBuild
  4. +12
    -0
      ap/potrace/slack-desc

+ 114
- 0
ap/potrace/potrace-1.8-xfig.patch View File

@ -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 */

+ 1
- 0
ap/potrace/potrace-1.8.tar.gz.sha1 View File

@ -0,0 +1 @@
d76818fc331fb4f842bd4813114e5be01cf46848 potrace-1.8.tar.gz

+ 120
- 0
ap/potrace/potrace.SlackBuild View File

@ -0,0 +1,120 @@
#!/bin/bash
# Build script for Slackware
# Damien Goutte-Gattat "gouttegd" < damien.goutte-gattat at e.ujf-grenoble.fr >
#
# Redistribution and use of this script, with or without modifications, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Latest potrace sourcecode is available at:
# http://potrace.sourceforge.net/
# Source package infos
NAMESRC=${NAMESRC:-potrace}
VERSION=${VERSION:-1.8}
ARCHIVE=${ARCHIVE:-$NAMESRC-$VERSION.tar.gz}
WGET=${WGET:-http://potrace.sourceforge.net/download/$ARCHIVE}
# Built package infos
NAMETGZ=${NAMETGZ:-potrace}
BUILD=${BUILD:-2GGD}
ARCH=${ARCH:-i486}
TARGET=${TARGET:-i486}
# Directories
TMP=${TMP:-/tmp}
OUT=${OUT:-$TMP/build}
PKG=${PKG:-$OUT/$NAMETGZ}
CWD=$(pwd)
set -e # Quit if a command returns non-zero
# Sanity checks
if [ $UID -eq 0 ]; then
echo "You should NOT run this script as ROOT!"
exit 1
fi
if [ ! -d $TMP ]; then
echo "$TMP does not exist or is not a directory!"
exit 1
fi
# Compilation flags
case "$ARCH" in
i?86)
CPUOPT="-O2 -march=$ARCH -mtune=i686"
;;
*)
CPUOPT="-O2"
;;
esac
# Get and verify the source archive
if [ ! -r $ARCHIVE ]; then
wget "$WGET"
fi
sha1sum -c $ARCHIVE.sha1
NAME=$(tar ft $ARCHIVE | head -n 1 | cut -d / -f 1)
# Extract and apply the `xfig' patch
cd $TMP
echo "Building $ARCHIVE..."
tar xf $CWD/$ARCHIVE
cd $NAME
cat $CWD/potrace-1.8-xfig.patch | patch -p0
# Compile
CFLAGS=$CPUOPT \
CXXFLAGS=$CPUOPT \
./configure \
--prefix=/usr \
--enable-metrics \
--enable-a4 \
--disable-dependency-tracking
make -j 3
make install DESTDIR=$PKG
# Strip binaries
find $PKG | xargs file | grep "ELF 32-bit LSB" | cut -d : -f 1 | \
xargs strip --strip-unneeded 2> /dev/null
# Compress man pages
find $PKG/usr/man -type f -exec gzip -9 '{}' \;
# Install the documentation
mkdir -p $PKG/usr/doc/$NAME
install -m 644 \
AUTHORS COPYING ChangeLog INSTALL NEWS README \
$PKG/usr/doc/$NAME
# Copy slack-desc file
mkdir -p $PKG/install
install -m 644 $CWD/slack-desc $PKG/install/slack-desc
# Package the tree
cd $PKG
mkdir -p $OUT
PACKAGING="
chown root:root . -R
/sbin/makepkg -l y -c n $OUT/$NAMETGZ-$VERSION-$ARCH-$BUILD.tgz
rm -rf $PKG
rm -rf $TMP/$NAME
"
if type -p fakeroot ; then
echo "$PACKAGING" | fakeroot
else
su -c "$PACKAGING"
fi

+ 12
- 0
ap/potrace/slack-desc View File

@ -0,0 +1,12 @@
|-----handy-ruler------------------------------------------------------|
potrace: potrace (transform bitmaps into vector graphics)
potrace:
potrace: potrace is a utility for tracing a bitmap, which means, transforming
potrace: a bitmap into a smooth, salable image. The input is a bitmap (PBM,
potrace: PGM, PPM, or BMP), and the default output is one of several vector
potrace: file formats. A typical use is to create EPS files from scanned
potrace: data, such as company or university logos, handwritte notes, etc.
potrace: The resulting image is not "jaggy" like a bitmap, but smooth. It
potrace: can then be rendered at any resolution.
potrace:
potrace:

Loading…
Cancel
Save