summaryrefslogtreecommitdiff
path: root/kicad/pl-render.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-22 04:40:40 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-22 04:40:40 -0300
commitf4e780e0101b81d373a6fec3fc41bd8e382f9c21 (patch)
tree7a04e437be2ca642758e6bfb012777e3fa4eaeb2 /kicad/pl-render.c
parent01e563c537c8503b86c833d351207396ec6c9fc2 (diff)
downloadeeshow-f4e780e0101b81d373a6fec3fc41bd8e382f9c21.tar.gz
eeshow-f4e780e0101b81d373a6fec3fc41bd8e382f9c21.tar.bz2
eeshow-f4e780e0101b81d373a6fec3fc41bd8e382f9c21.zip
eeshow/kicad/: begin text support for page layout (WIP); add missing pl-common.h
Diffstat (limited to 'kicad/pl-render.c')
-rw-r--r--kicad/pl-render.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/kicad/pl-render.c b/kicad/pl-render.c
index a6723cd..b682a82 100644
--- a/kicad/pl-render.c
+++ b/kicad/pl-render.c
@@ -18,6 +18,7 @@
#include "misc/util.h"
#include "misc/diag.h"
#include "gfx/style.h"
+#include "gfx/text.h"
#include "gfx/gfx.h"
#include "kicad/pl-common.h"
#include "kicad/pl.h"
@@ -35,15 +36,9 @@ static int mil(float mm)
}
-static int cx(int x, int dx, int xo, int xe)
+static int coord(int v, int d, int o, int e)
{
- return dx >= 0 ? xo + x : xe - x;
-}
-
-
-static int cy(int y, int dy, int yo, int ye)
-{
- return dy >= 0 ? yo + y : ye - y;
+ return d >= 0 ? o + v : e - v;
}
@@ -66,27 +61,28 @@ static void render_obj(const struct pl_ctx *pl, const struct pl_obj *obj,
if (x > ww || y > hh || ex > ww || ey > hh)
return;
+ x = coord(x, obj->dx, xo, xe);
+ y = coord(y, obj->dy, yo, ye);
+ ex = coord(ex, obj->edx, xo, xe);
+ ey = coord(ey, obj->edy, yo, ye);
+
switch (obj->type) {
case pl_obj_rect:
- gfx_rect(
- cx(x, obj->dx, xo, xe), cy(y, obj->dy, yo, ye),
- cx(ex, obj->edx, xo, xe), cy(ey, obj->edy, yo, ye),
+ gfx_rect(x, y, ex, ey,
COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
break;
case pl_obj_line: {
- int vx[] = {
- cx(x, obj->dx, xo, xe),
- cx(ex, obj->edx, xo, xe)
- };
- int vy[] = {
- cy(y, obj->dy, yo, ye),
- cy(ey, obj->edy, yo, ye)
- };
+ int vx[] = { x, ex };
+ int vy[] = { y, ey };
gfx_poly(2, vx, vy,
COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
break;
+ case pl_obj_text:
+ gfx_text(x, y, obj->s, mil(obj->ey), text_min, 0,
+ COLOR_COMP_DWG, LAYER_COMP_DWG);
+ break;
default:
break;
}