summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwl <wl>2007-11-19 09:28:44 +0000
committerwl <wl>2007-11-19 09:28:44 +0000
commit5291a235c550b0b9304a0b8db5069f9045b6dbf4 (patch)
tree492b16e8fc3ad23fdeaf75372cf17952c2c2fe4b
parent2bfcebf32711adf0f7579ca08b3ad843e6145ce9 (diff)
downloadgroff-5291a235c550b0b9304a0b8db5069f9045b6dbf4.tar.gz
* src/groff/preproc/pic/lex.cpp (table): Add box attributes
`xslanted' and `yslanted'. * src/groff/preproc/pic/object.cpp (object_spec::object_spec): Initialize `xslanted' and `yslanted'. (graphic_object): Add methods `set_xlanted' and `set_yslanted'. (closed_object): Ditto. Add members `xslanted' and `yslanted'. (box_object::print): Use them. (object_spec::make_object): Handle slant values. * src/groff/preproc/pic/object.h (IS_XSLANTED, IS_YSLANTED): New constants. (object_spec): Add members `xslanted' and `yslanted'. * src/groff/preproc/pic/pic.y (XSLANTED, YSLANTED): New left-valued tokens. Add rules for them. * src/groff/preproc/pic/pic.man, NEWS, doc/pic.ms: Document above changes.
-rw-r--r--ChangeLog24
-rw-r--r--NEWS4
-rw-r--r--doc/pic.ms28
-rw-r--r--src/preproc/pic/lex.cpp6
-rw-r--r--src/preproc/pic/object.cpp45
-rw-r--r--src/preproc/pic/object.h52
-rw-r--r--src/preproc/pic/pic.man16
-rw-r--r--src/preproc/pic/pic.y15
8 files changed, 152 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index 156d0528..20a8f879 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,29 @@
+2007-11-17 Heinz-Jürgen Oertel <hj.oertel@t-online.de>
+
+ * src/groff/preproc/pic/lex.cpp (table): Add box attributes
+ `xslanted' and `yslanted'.
+
+ * src/groff/preproc/pic/object.cpp (object_spec::object_spec):
+ Initialize `xslanted' and `yslanted'.
+ (graphic_object): Add methods `set_xlanted' and `set_yslanted'.
+ (closed_object): Ditto.
+ Add members `xslanted' and `yslanted'.
+ (box_object::print): Use them.
+ (object_spec::make_object): Handle slant values.
+ * src/groff/preproc/pic/object.h (IS_XSLANTED, IS_YSLANTED): New
+ constants.
+ (object_spec): Add members `xslanted' and `yslanted'.
+ * src/groff/preproc/pic/pic.y (XSLANTED, YSLANTED): New left-valued
+ tokens.
+ Add rules for them.
+
+ * src/groff/preproc/pic/pic.man, NEWS, doc/pic.ms: Document above
+ changes.
+
2007-11-16 Werner LEMBERG <wl@gnu.org>
* tmac/hyphenex.pl: Generate copyright notice (this has been
- approved By Barbara Beeton).
+ approved by Barbara Beeton).
* tmac/hyphenex.us: Updated.
2007-11-10 Michail Vidiassov <master@iaas.msu.ru>
diff --git a/NEWS b/NEWS
index deca0166..dea9b8ab 100644
--- a/NEWS
+++ b/NEWS
@@ -79,6 +79,10 @@ o int(x) now really behaves as documented: It truncates the non-integer part
o Pic now supports up to 32 macro arguments (and up to 16 on EBCDIC
platforms).
+o Heinz-Jürgen Örtel contributed code for two new keywords, `xslanted' and
+ `yslanted', which can change the shape of boxes into arbitrary
+ parallelograms.
+
Eqn
---
diff --git a/doc/pic.ms b/doc/pic.ms
index 9c0c3669..580bb744 100644
--- a/doc/pic.ms
+++ b/doc/pic.ms
@@ -31,7 +31,7 @@
.\" Eric S. Raymond <esr@thyrsus.com> in August 1995. It has been put
.\" under the GPL in March 2006.
.\"
-.\" $Id: pic.ms,v 1.35 2007/03/21 13:30:59 wl Exp $
+.\" $Id: pic.ms,v 1.36 2007/11/19 09:28:44 wl Exp $
.
.
.\" Set a proper TeX and LaTeX
@@ -635,6 +635,24 @@ Radius values higher than half the minimum box dimension are silently
truncated to that value.
.
.NH 2
+Slanted Boxes
+.PP
+GNU \fBgpic\fP supports slanted boxes:
+.KS
+.PS
+box wid 1.2 xslanted 0.1 "xslanted 0.1";
+move;
+box wid 1.2 yslanted -0.1 "yslanted -0.1";
+move;
+box wid 1.2 xslanted -0.2 yslanted 0.1 "xslanted -0.2" "yslanted 0.1";
+.PE
+.CE "4: Various slanted boxes.
+.PP
+The \fBxslanted\fP and \fByslanted\fP attributes specify the x and
+y\~offset, respectively, of the box's upper right corner from its default
+position.
+.
+.NH 2
Arrowheads
.PP
Lines and arcs can be decorated as well. Any line or arc (and any
@@ -644,7 +662,7 @@ as modifiers:
.PS
line <- ->
.PE
-.CE "4: Double-headed line made with \fBline <- ->\fP"
+.CE "5: Double-headed line made with \fBline <- ->\fP"
.PP
In fact, the \fBarrow\fP command is just shorthand for \fBline ->\fP. And
there is a double-head modifier <->, so the figure above could have been made
@@ -710,7 +728,7 @@ values are darker; GNU \fBfillval\fP uses 0 for white and 1 for black.
.PS
circle fill; move; circle fill 0.4; move; circle fill 0.9;
.PE
-.CE "5: \fBcircle fill; move; circle fill 0.4; move; circle fill 0.9;\fR"
+.CE "6: \fBcircle fill; move; circle fill 0.4; move; circle fill 0.9;\fR"
.PP
GNU \fBgpic\fP makes some additional guarantees. A fill value greater
than 1 can also be used: this means fill with the shade of gray that
@@ -735,7 +753,7 @@ suffix specifying the color. Example:
.PS
box color "yellow"; arrow color "cyan"; circle shaded "green" outline "black";
.PE
-.CE "6: \fBbox color ""yellow""; arrow color ""cyan""; \
+.CE "7: \fBbox color ""yellow""; arrow color ""cyan""; \
circle shaded ""green"" outline ""black"";\fR"
.PP
Alternative spellings are \fBcolour\fP, \fBcolored\fP, \fBcoloured\fP,
@@ -2673,6 +2691,8 @@ direction on the block's bounding box.
invis[ible] \fR# make primitive invisible\fP
solid \fR# make closed figure solid\fP
fill[ed] [<expr>] \fR# set fill density for figure\fP
+ xscaled <expr> \fR# slant box into x direction\fP
+ yscaled <expr> \fR# slant box into y direction\fP
colo[u]r[ed] TEXT \fR# set fill and outline color for figure\fP
outline[d] TEXT \fR# set outline color for figure\fP
shaded TEXT \fR# set fill color for figure\fP
diff --git a/src/preproc/pic/lex.cpp b/src/preproc/pic/lex.cpp
index 17357ac6..b286e0f0 100644
--- a/src/preproc/pic/lex.cpp
+++ b/src/preproc/pic/lex.cpp
@@ -1,6 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004, 2006
- Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004, 2006,
+ 2007 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -557,6 +557,8 @@ int lookup_keyword(const char *str, int len)
{ "wid", WIDTH },
{ "width", WIDTH },
{ "with", WITH },
+ { "xslanted", XSLANTED },
+ { "yslanted", YSLANTED },
};
const keyword *start = table;
diff --git a/src/preproc/pic/object.cpp b/src/preproc/pic/object.cpp
index 2eeb9cde..f16ab40c 100644
--- a/src/preproc/pic/object.cpp
+++ b/src/preproc/pic/object.cpp
@@ -413,6 +413,8 @@ object_spec::object_spec(object_type t) : type(t)
segment_is_absolute = 0;
text = 0;
shaded = 0;
+ xslanted = 0;
+ yslanted = 0;
outlined = 0;
with = 0;
dir = RIGHT_DIRECTION;
@@ -565,6 +567,8 @@ public:
void set_outline_color(char *);
char *get_outline_color();
virtual void set_fill(double);
+ virtual void set_xslanted(double);
+ virtual void set_yslanted(double);
virtual void set_fill_color(char *);
};
@@ -594,6 +598,14 @@ void graphic_object::set_fill(double)
{
}
+void graphic_object::set_xslanted(double)
+{
+}
+
+void graphic_object::set_yslanted(double)
+{
+}
+
void graphic_object::set_fill_color(char *c)
{
color_fill = strsave(c);
@@ -701,14 +713,18 @@ public:
closed_object(const position &);
object_type type() = 0;
void set_fill(double);
+ void set_xslanted(double);
+ void set_yslanted(double);
void set_fill_color(char *fill);
protected:
double fill; // < 0 if not filled
+ double xslanted; // !=0 if x is slanted
+ double yslanted; // !=0 if y is slanted
char *color_fill; // = 0 if not colored
};
closed_object::closed_object(const position &pos)
-: rectangle_object(pos), fill(-1.0), color_fill(0)
+: rectangle_object(pos), fill(-1.0), xslanted(0), yslanted(0), color_fill(0)
{
}
@@ -718,6 +734,19 @@ void closed_object::set_fill(double f)
fill = f;
}
+/* accept positive and negative values */
+void closed_object::set_xslanted(double s)
+{
+ //assert(s >= 0.0);
+ xslanted = s;
+}
+/* accept positive and negative values */
+void closed_object::set_yslanted(double s)
+{
+ //assert(s >= 0.0);
+ yslanted = s;
+}
+
void closed_object::set_fill_color(char *f)
{
color_fill = strsave(f);
@@ -775,10 +804,12 @@ void box_object::print()
if (xrad == 0.0) {
distance dim2 = dim/2.0;
position vec[4];
- vec[0] = cent + position(dim2.x, -dim2.y);
- vec[1] = cent + position(dim2.x, dim2.y);
- vec[2] = cent + position(-dim2.x, dim2.y);
- vec[3] = cent + position(-dim2.x, -dim2.y);
+ /* error("x slanted %1", xslanted); */
+ /* error("y slanted %1", yslanted); */
+ vec[0] = cent + position(dim2.x, -(dim2.y - yslanted)); /* lr */
+ vec[1] = cent + position(dim2.x + xslanted, dim2.y + yslanted); /* ur */
+ vec[2] = cent + position(-(dim2.x - xslanted), dim2.y); /* ul */
+ vec[3] = cent + position(-(dim2.x), -dim2.y); /* ll */
out->polygon(vec, 4, lt, fill);
}
else {
@@ -1896,6 +1927,10 @@ object *object_spec::make_object(position *curpos, direction *dirp)
obj->set_thickness(th);
if (flags & IS_OUTLINED)
obj->set_outline_color(outlined);
+ if (flags & IS_XSLANTED)
+ obj->set_xslanted(xslanted);
+ if (flags & IS_YSLANTED)
+ obj->set_yslanted(yslanted);
if (flags & (IS_DEFAULT_FILLED | IS_FILLED)) {
if (flags & IS_SHADED)
obj->set_fill_color(shaded);
diff --git a/src/preproc/pic/object.h b/src/preproc/pic/object.h
index 9f7f4bc3..e87cc8bc 100644
--- a/src/preproc/pic/object.h
+++ b/src/preproc/pic/object.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004, 2007
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -133,29 +133,31 @@ struct text_item {
~text_item();
};
-const unsigned long IS_DOTTED = 01;
-const unsigned long IS_DASHED = 02;
-const unsigned long IS_CLOCKWISE = 04;
-const unsigned long IS_INVISIBLE = 020;
-const unsigned long HAS_LEFT_ARROW_HEAD = 040;
-const unsigned long HAS_RIGHT_ARROW_HEAD = 0100;
-const unsigned long HAS_SEGMENT = 0200;
-const unsigned long IS_SAME = 0400;
-const unsigned long HAS_FROM = 01000;
-const unsigned long HAS_AT = 02000;
-const unsigned long HAS_WITH = 04000;
-const unsigned long HAS_HEIGHT = 010000;
-const unsigned long HAS_WIDTH = 020000;
-const unsigned long HAS_RADIUS = 040000;
-const unsigned long HAS_TO = 0100000;
-const unsigned long IS_CHOPPED = 0200000;
-const unsigned long IS_DEFAULT_CHOPPED = 0400000;
-const unsigned long HAS_THICKNESS = 01000000;
-const unsigned long IS_FILLED = 02000000;
-const unsigned long IS_DEFAULT_FILLED = 04000000;
-const unsigned long IS_ALIGNED = 010000000;
-const unsigned long IS_SHADED = 020000000;
-const unsigned long IS_OUTLINED = 040000000;
+const unsigned long IS_DOTTED = 01;
+const unsigned long IS_DASHED = 02;
+const unsigned long IS_CLOCKWISE = 04;
+const unsigned long IS_INVISIBLE = 020;
+const unsigned long HAS_LEFT_ARROW_HEAD = 040;
+const unsigned long HAS_RIGHT_ARROW_HEAD = 0100;
+const unsigned long HAS_SEGMENT = 0200;
+const unsigned long IS_SAME = 0400;
+const unsigned long HAS_FROM = 01000;
+const unsigned long HAS_AT = 02000;
+const unsigned long HAS_WITH = 04000;
+const unsigned long HAS_HEIGHT = 010000;
+const unsigned long HAS_WIDTH = 020000;
+const unsigned long HAS_RADIUS = 040000;
+const unsigned long HAS_TO = 0100000;
+const unsigned long IS_CHOPPED = 0200000;
+const unsigned long IS_DEFAULT_CHOPPED = 0400000;
+const unsigned long HAS_THICKNESS = 01000000;
+const unsigned long IS_FILLED = 02000000;
+const unsigned long IS_DEFAULT_FILLED = 04000000;
+const unsigned long IS_ALIGNED = 010000000;
+const unsigned long IS_SHADED = 020000000;
+const unsigned long IS_OUTLINED = 040000000;
+const unsigned long IS_XSLANTED = 0100000000;
+const unsigned long IS_YSLANTED = 0200000000;
struct segment {
int is_absolute;
@@ -189,6 +191,8 @@ struct object_spec {
double end_chop;
double thickness;
double fill;
+ double xslanted;
+ double yslanted;
char *shaded;
char *outlined;
direction dir;
diff --git a/src/preproc/pic/pic.man b/src/preproc/pic/pic.man
index c54cfbef..9242d656 100644
--- a/src/preproc/pic/pic.man
+++ b/src/preproc/pic/pic.man
@@ -1,5 +1,6 @@
.ig
-Copyright (C) 1989-2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright (C) 1989-2000, 2001, 2002, 2003, 2004, 2007
+ Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -735,6 +736,17 @@ has a value of\ 0.
A box with rounded corners can be dotted or dashed.
.
.LP
+Boxes can have slanted sides.
+This effectively changes the shape of a box from a rectangle to an
+arbitrary parallelogram.
+The
+.B xslanted
+and
+.B yslanted
+attributes specify the x and y\~offset of the box's upper right corner
+from its default position.
+.
+.LP
The
.B .PS
line can have a second argument specifying a maximum height for
@@ -818,7 +830,7 @@ variable, nor by the width or height given in the
line.
.
.LP
-Boxes (including boxes with rounded corners),
+Boxes (including boxes with rounded corners or slanted sides),
circles and ellipses can be filled by giving them an attribute of
.BR fill [ ed ].
This takes an optional argument of an expression with a value between
diff --git a/src/preproc/pic/pic.y b/src/preproc/pic/pic.y
index 2f838da3..2f0b31f9 100644
--- a/src/preproc/pic/pic.y
+++ b/src/preproc/pic/pic.y
@@ -197,6 +197,8 @@ char *do_sprintf(const char *form, const double *v, int nv);
%token COLORED
%token OUTLINED
%token SHADED
+%token XSLANTED
+%token YSLANTED
%token ALIGNED
%token SPRINTF
%token COMMAND
@@ -221,6 +223,7 @@ box "foo" above ljust == box ("foo" above ljust)
precedence than left and right, so that eg `line chop left'
parses properly. */
%left CHOP SOLID DASHED DOTTED UP DOWN FILL COLORED OUTLINED
+%left XSLANTED YSLANTED
%left LABEL
%left VARIABLE NUMBER '(' SIN COS ATAN2 LOG EXP SQRT K_MAX K_MIN INT RAND SRAND LAST
@@ -935,6 +938,18 @@ object_spec:
$$->flags |= IS_FILLED;
$$->fill = $3;
}
+ | object_spec XSLANTED expr
+ {
+ $$ = $1;
+ $$->flags |= IS_XSLANTED;
+ $$->xslanted = $3;
+ }
+ | object_spec YSLANTED expr
+ {
+ $$ = $1;
+ $$->flags |= IS_YSLANTED;
+ $$->yslanted = $3;
+ }
| object_spec SHADED text
{
$$ = $1;