diff -Naur -X exclude pic/lex.cpp pic_extended/lex.cpp --- pic/lex.cpp 2007-10-20 17:59:55.000000000 +0000 +++ pic_extended/lex.cpp 2007-11-10 18:49:55.000000000 +0000 @@ -557,6 +557,8 @@ { "wid", WIDTH }, { "width", WIDTH }, { "with", WITH }, + { "xslanted", XSLANTED }, + { "yslanted", YSLANTED }, }; const keyword *start = table; diff -Naur -X exclude pic/object.cpp pic_extended/object.cpp --- pic/object.cpp 2007-10-20 17:59:55.000000000 +0000 +++ pic_extended/object.cpp 2007-11-10 18:49:55.000000000 +0000 @@ -413,6 +413,8 @@ segment_is_absolute = 0; text = 0; shaded = 0; + xslanted = 0; + yslanted = 0; outlined = 0; with = 0; dir = RIGHT_DIRECTION; @@ -565,6 +567,8 @@ 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_xslanted(double) +{ +} + +void graphic_object::set_yslanted(double) +{ +} + void graphic_object::set_fill_color(char *c) { color_fill = strsave(c); @@ -701,14 +713,19 @@ 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), color_fill(0), + xslanted(0), yslanted(0) { } @@ -718,6 +735,19 @@ 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 +805,12 @@ 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 +1928,12 @@ 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 -Naur -X exclude pic/object.h pic_extended/object.h --- pic/object.h 2007-10-20 17:59:55.000000000 +0000 +++ pic_extended/object.h 2007-11-10 18:49:55.000000000 +0000 @@ -133,29 +133,31 @@ ~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 @@ double end_chop; double thickness; double fill; + double xslanted; + double yslanted; char *shaded; char *outlined; direction dir; diff -Naur -X exclude pic/pic.man pic_extended/pic.man --- pic/pic.man 2007-10-20 17:59:55.000000000 +0000 +++ pic_extended/pic.man 2007-11-10 18:49:55.000000000 +0000 @@ -735,6 +735,16 @@ A box with rounded corners can be dotted or dashed. . .LP +Boxes can have slanted sides, +in other words the angle between two sides of an rectangle is not 90\[de]. +The +.B xslanted +and +.B yslanted +attributes are specifying the amount of offset +the line endpoints of the box are shifted in x or y direction. +. +.LP The .B .PS line can have a second argument specifying a maximum height for @@ -818,7 +828,7 @@ 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 -Naur -X exclude pic/pic.y pic_extended/pic.y --- pic/pic.y 2007-10-20 17:59:55.000000000 +0000 +++ pic_extended/pic.y 2007-11-10 18:49:55.000000000 +0000 @@ -197,6 +197,8 @@ %token COLORED %token OUTLINED %token SHADED +%token XSLANTED +%token YSLANTED %token ALIGNED %token SPRINTF %token COMMAND @@ -221,6 +223,7 @@ 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 @@ $$->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; diff -Naur -X exclude pic/troff.cpp pic_extended/troff.cpp --- pic/troff.cpp 2007-10-20 17:59:55.000000000 +0000 +++ pic_extended/troff.cpp 2007-11-10 18:49:55.000000000 +0000 @@ -36,6 +36,8 @@ virtual void simple_polygon(int, const position *, int) = 0; virtual void line_thickness(double) = 0; virtual void set_fill(double) = 0; + virtual void set_xslanted(double) = 0; + virtual void set_yslanted(double) = 0; virtual void set_color(char *, char *) = 0; virtual void reset_color() = 0; virtual char *get_last_filled() = 0; @@ -217,6 +219,8 @@ double scale; double last_line_thickness; double last_fill; + double last_xslanted; + double last_yslanted; char *last_filled; // color char *last_outlined; // color public: @@ -236,6 +240,8 @@ void simple_polygon(int, const position *, int); void line_thickness(double p); void set_fill(double); + void set_xslanted(double); + void set_yslanted(double); void set_color(char *, char *); void reset_color(); char *get_last_filled(); @@ -250,7 +256,8 @@ troff_output::troff_output() : last_filename(0), last_line_thickness(BAD_THICKNESS), - last_fill(-1.0), last_filled(0), last_outlined(0) + last_fill(-1.0), last_filled(0), last_outlined(0), + last_xslanted(0), last_yslanted(0) { } @@ -299,6 +306,8 @@ { line_thickness(BAD_THICKNESS); last_fill = -1.0; // force it to be reset for each picture + last_xslanted = 0; + last_yslanted = 0; reset_color(); if (!flyback_flag) printf(".sp %.3fi+1\n", height); @@ -492,6 +501,16 @@ } } +void troff_output::set_xslanted(double f) +{ + last_xslanted = f; +} + +void troff_output::set_yslanted(double f) +{ + last_yslanted = f; +} + void troff_output::set_color(char *color_fill, char *color_outlined) { if (driver_extension_flag) {