* accept dvi function calls and translate to X
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
/* math.h on a Sequent doesn't define M_PI, apparently */
#define M_PI 3.14159265358979323846
HorizontalMove(dw
, delta
)
dw
->dvi
.state
->x
+= delta
;
HorizontalGoto(dw
, NewPosition
)
dw
->dvi
.state
->x
= NewPosition
;
dw
->dvi
.state
->y
+= delta
;
VerticalGoto(dw
, NewPosition
)
dw
->dvi
.state
->y
= NewPosition
;
if (dw
->dvi
.cache
.char_index
!= 0)
XDrawText (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.normal_GC
,
dw
->dvi
.cache
.start_x
, dw
->dvi
.cache
.start_y
,
dw
->dvi
.cache
.cache
, dw
->dvi
.cache
.index
+ 1);
dw
->dvi
.cache
.max
= DVI_TEXT_CACHE_SIZE
;
dw
->dvi
.cache
.char_index
= 0;
dw
->dvi
.cache
.cache
[0].nchars
= 0;
dw
->dvi
.cache
.start_x
= dw
->dvi
.cache
.x
= dw
->dvi
.state
->x
;
dw
->dvi
.cache
.start_y
= dw
->dvi
.cache
.y
= dw
->dvi
.state
->y
;
XClearWindow (XtDisplay (dw
), XtWindow (dw
));
if (dw
->dvi
.line_thickness
< 0) {
desired_line_width
= (((dw
->dvi
.device_resolution
* dw
->dvi
.state
->font_size
) + 5*72)
if (desired_line_width
== 0)
desired_line_width
= dw
->dvi
.line_thickness
;
if (desired_line_width
!= dw
->dvi
.line_width
) {
values
.line_width
= desired_line_width
;
XChangeGC(XtDisplay (dw
), dw
->dvi
.normal_GC
,
dw
->dvi
.line_width
= desired_line_width
;
if (dw
->dvi
.fill
== DVI_FILL_MAX
)
fill_type
= DVI_FILL_BLACK
;
else if (dw
->dvi
.fill
== 0)
fill_type
= DVI_FILL_WHITE
;
fill_type
= DVI_FILL_GRAY
;
if (dw
->dvi
.fill_type
!= fill_type
) {
values
.foreground
= dw
->dvi
.background
;
values
.fill_style
= FillSolid
;
values
.foreground
= dw
->dvi
.foreground
;
values
.fill_style
= FillSolid
;
values
.foreground
= dw
->dvi
.foreground
;
values
.fill_style
= FillOpaqueStippled
;
XChangeGC(XtDisplay (dw
), dw
->dvi
.fill_GC
,
GCFillStyle
|GCForeground
,
dw
->dvi
.fill_type
= fill_type
;
XDrawLine (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.normal_GC
,
dw
->dvi
.state
->x
, dw
->dvi
.state
->y
,
dw
->dvi
.state
->x
+ x
, dw
->dvi
.state
->y
+ y
);
XDrawArc (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.normal_GC
,
dw
->dvi
.state
->x
, dw
->dvi
.state
->y
- diam
/2,
DrawFilledCircle (dw
, diam
)
XFillArc (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.fill_GC
,
dw
->dvi
.state
->x
, dw
->dvi
.state
->y
- diam
/2,
XDrawArc (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.normal_GC
,
dw
->dvi
.state
->x
, dw
->dvi
.state
->y
- b
/2,
DrawFilledEllipse (dw
, a
, b
)
XFillArc (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.fill_GC
,
dw
->dvi
.state
->x
, dw
->dvi
.state
->y
- b
/2,
DrawArc (dw
, x0
, y0
, x1
, y1
)
int rad
= (int)((sqrt ((double)x0
*x0
+ (double)y0
*y0
)
+ sqrt ((double)x1
*x1
+ (double)y1
*y1
) + 1.0)/2.0);
if ((x0
== 0 && y0
== 0) || (x1
== 0 && y1
== 0))
angle1
= (int)(atan2 ((double)y0
, (double)-x0
)*180.0*64.0/M_PI
);
angle2
= (int)(atan2 ((double)-y1
, (double)x1
)*180.0*64.0/M_PI
);
XDrawArc (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.normal_GC
,
dw
->dvi
.state
->x
+ x0
- rad
, dw
->dvi
.state
->y
+ y0
- rad
,
rad
*2, rad
*2, angle1
, angle2
);
p
= (XPoint
*)malloc((n
+ 2)*sizeof(XPoint
));
p
[0].x
= dw
->dvi
.state
->x
;
p
[0].y
= dw
->dvi
.state
->y
;
for (i
= 0; i
< n
; i
++) {
p
[i
+ 1].x
= v
[2*i
] + p
[i
].x
;
p
[i
+ 1].y
= v
[2*i
+ 1] + p
[i
].y
;
p
[n
+1].x
= dw
->dvi
.state
->x
;
p
[n
+1].y
= dw
->dvi
.state
->y
;
XDrawLines (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.normal_GC
,
p
, n
+ 2, CoordModeOrigin
);
DrawFilledPolygon (dw
, v
, n
)
p
= (XPoint
*)malloc((n
+ 1)*sizeof(XPoint
));
p
[0].x
= dw
->dvi
.state
->x
;
p
[0].y
= dw
->dvi
.state
->y
;
for (i
= 0; i
< n
; i
++) {
XFillPolygon (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.fill_GC
,
p
, n
+ 1, Complex
, CoordModePrevious
);
appendPoint(points
, pointi
, x
, y
)
if (*pointi
< POINTS_MAX
) {
flattenCurve(points
, pointi
, x2
, y2
, x3
, y3
, x4
, y4
)
int x2
, y2
, x3
, y3
, x4
, y4
;
int x1
, y1
, dx
, dy
, n1
, n2
, n
;
x1
= points
[*pointi
- 1].x
;
y1
= points
[*pointi
- 1].y
;
n1
= dy
*(x2
- x1
) - dx
*(y2
- y1
);
n2
= dy
*(x3
- x1
) - dx
*(y3
- y1
);
if (n
*n
/ (dy
*dy
+ dx
*dx
) <= FLATNESS
*FLATNESS
)
appendPoint (points
, pointi
, x4
, y4
);
flattenCurve (points
, pointi
,
(x1
+ x2
)/2, (y1
+ y2
)/2,
(x1
+ x2
*2 + x3
)/4, (y1
+ y2
*2 + y3
)/4,
(x1
+3*x2
+ 3*x3
+ x4
)/8, (y1
+3*y2
+ 3*y3
+ y4
)/8);
flattenCurve (points
, pointi
,
(x2
+ x3
*2 + x4
)/4, (y2
+ y3
*2 + y4
)/4,
(x3
+ x4
)/2, (y3
+ y4
)/2,
int sx
, sy
, tx
, ty
, ux
, uy
;
XPoint points
[POINTS_MAX
];
if (n
== 0 || (n
& 1) != 0)
appendPoint (points
, &pointi
, sx
, sy
);
appendPoint (points
, &pointi
, (sx
+ tx
)/2, (sy
+ ty
)/2);
for (i
= 2; i
< n
; i
+= 2) {
flattenCurve (points
, &pointi
,
(sx
+ tx
*5)/6, (sy
+ ty
*5)/6,
(tx
*5 + ux
)/6, (ty
*5 + uy
)/6,
(tx
+ ux
)/2, (ty
+ uy
)/2);
appendPoint (points
, &pointi
, tx
, ty
);
XDrawLines (XtDisplay (dw
), XtWindow (dw
), dw
->dvi
.normal_GC
,
points
, pointi
, CoordModeOrigin
);
c-continued-statement-offset: 8