diff options
Diffstat (limited to 'source/fitz/draw-path.c')
-rw-r--r-- | source/fitz/draw-path.c | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/source/fitz/draw-path.c b/source/fitz/draw-path.c index 2c0caa50..9956ff45 100644 --- a/source/fitz/draw-path.c +++ b/source/fitz/draw-path.c @@ -269,6 +269,58 @@ fz_add_line(fz_context *ctx, sctx *s, float x0, float y0, float x1, float y1) } static void +fz_add_horiz_rect(fz_context *ctx, sctx *s, float x0, float y0, float x1, float y1) +{ + if (s->ctm->b == 0 && s->ctm->c == 0) + { + float tx0 = s->ctm->a * x0 + s->ctm->e; + float ty0 = s->ctm->d * y0 + s->ctm->f; + float tx1 = s->ctm->a * x1 + s->ctm->e; + float ty1 = s->ctm->d * y1 + s->ctm->f; + fz_insert_gel_rect(ctx, s->gel, tx1, ty1, tx0, ty0); + } + else if (s->ctm->a == 0 && s->ctm->d == 0) + { + float tx0 = s->ctm->c * y0 + s->ctm->e; + float ty0 = s->ctm->b * x0 + s->ctm->f; + float tx1 = s->ctm->c * y1 + s->ctm->e; + float ty1 = s->ctm->b * x1 + s->ctm->f; + fz_insert_gel_rect(ctx, s->gel, tx1, ty0, tx0, ty1); + } + else + { + fz_add_line(ctx, s, x0, y0, x1, y0); + fz_add_line(ctx, s, x1, y1, x0, y1); + } +} + +static void +fz_add_vert_rect(fz_context *ctx, sctx *s, float x0, float y0, float x1, float y1) +{ + if (s->ctm->b == 0 && s->ctm->c == 0) + { + float tx0 = s->ctm->a * x0 + s->ctm->e; + float ty0 = s->ctm->d * y0 + s->ctm->f; + float tx1 = s->ctm->a * x1 + s->ctm->e; + float ty1 = s->ctm->d * y1 + s->ctm->f; + fz_insert_gel_rect(ctx, s->gel, tx0, ty1, tx1, ty0); + } + else if (s->ctm->a == 0 && s->ctm->d == 0) + { + float tx0 = s->ctm->c * y0 + s->ctm->e; + float ty0 = s->ctm->b * x0 + s->ctm->f; + float tx1 = s->ctm->c * y1 + s->ctm->e; + float ty1 = s->ctm->b * x1 + s->ctm->f; + fz_insert_gel_rect(ctx, s->gel, tx0, ty0, tx1, ty1); + } + else + { + fz_add_line(ctx, s, x1, y0, x0, y0); + fz_add_line(ctx, s, x0, y1, x1, y1); + } +} + +static void fz_add_arc(fz_context *ctx, sctx *s, float xc, float yc, float x0, float y0, @@ -321,8 +373,19 @@ fz_add_line_stroke(fz_context *ctx, sctx *s, float ax, float ay, float bx, float float dlx = dy * scale; float dly = -dx * scale; - fz_add_line(ctx, s, ax - dlx, ay - dly, bx - dlx, by - dly); - fz_add_line(ctx, s, bx + dlx, by + dly, ax + dlx, ay + dly); + if (0 && dx == 0) + { + fz_add_vert_rect(ctx, s, ax - dlx, ay, bx + dlx, by); + } + else if (dy == 0) + { + fz_add_horiz_rect(ctx, s, ax, ay - dly, bx, by + dly); + } + else + { + fz_add_line(ctx, s, ax - dlx, ay - dly, bx - dlx, by - dly); + fz_add_line(ctx, s, bx + dlx, by + dly, ax + dlx, ay + dly); + } } static void |