]> mj.ucw.cz Git - leo.git/commitdiff
Merge branch 'master' into labelling
authorKarryanna <karry@karryanna.cz>
Tue, 12 May 2015 12:29:25 +0000 (14:29 +0200)
committerKarryanna <karry@karryanna.cz>
Tue, 12 May 2015 12:29:25 +0000 (14:29 +0200)
leo.c
svg.c
svg.h
sym-text.c
sym.h

diff --git a/leo.c b/leo.c
index 75df2e7a4f3b85b4e24ee476da3f1116fd5c5ae1..f22e5a50e2de10068658edcbae876840f70b6b30 100644 (file)
--- a/leo.c
+++ b/leo.c
@@ -57,7 +57,7 @@ static void draw_scale(struct svg *svg)
 
   svg_push_element(svg, "g");
   svg_set_attr(svg, "id", "scale");
-  svg_set_attr_format(svg, "transform", "translate(%.6g,%.6g)", x * svg->scale, y * svg->scale);
+  svg_set_attr_format(svg, "transform", "translate(%s,%s)", svg_format_dimen(svg, x), svg_format_dimen(svg, y));
 
   for (int outline=1; outline>=0; outline--)
     {
diff --git a/svg.c b/svg.c
index 0aaa4d9410e0ca44dc4e3a25a3826e825bb8abbd..819014353509827840baea639d27500ed0c51f82 100644 (file)
--- a/svg.c
+++ b/svg.c
@@ -273,9 +273,14 @@ void svg_set_attr_float(struct svg *svg, const char *key, double val)
   svg_set_attr_ref(svg, key, mp_printf(svg->pool, "%.6g", val));
 }
 
+char *svg_format_dimen(struct svg *svg, double val)
+{
+  return mp_printf(svg->pool, "%.6g", val * svg->scale);
+}
+
 void svg_set_attr_dimen(struct svg *svg, const char *key, double val)
 {
-  svg_set_attr_ref(svg, key, mp_printf(svg->pool, "%.6g", val * svg->scale));
+  svg_set_attr_ref(svg, key, svg_format_dimen(svg, val));
 }
 
 void svg_set_attr_color(struct svg *svg, const char *key, color_t color)
diff --git a/svg.h b/svg.h
index c9520c44bd5e7f326cb56da50584b68e0acb8c6f..b50a869f6ae20a1660e2122522fb29440520ce11 100644 (file)
--- a/svg.h
+++ b/svg.h
@@ -69,6 +69,8 @@ void svg_path_line_to(struct svg *svg, double x, double y);
 void svg_path_line_to_rel(struct svg *svg, double x, double y);
 void svg_path_close(struct svg *svg);
 
+char *svg_format_dimen(struct svg *svg, double val);
+
 /* svg-icon.c */
 
 struct svg_icon {
index 3188938a38fd151c92998fce6005a493b3cb7904..6622fd61fbd2b56b9c769b6be16484a7d2f10a07 100644 (file)
@@ -7,6 +7,7 @@
 #include <ucw/lib.h>
 #include <ucw/stkstring.h>
 
+#include <math.h>
 #include <stdio.h>
 #include <ft2build.h>
 #include FT_FREETYPE_H
@@ -244,10 +245,16 @@ printf("Drawing %s at [%.2f; %.2f]\n", osm_val_decode(t->text), t->x, t->y);
       t->y = sy / nn;
     }
 
-  if (t->opacity != 1)
+  bool use_group = 0;
+  bool want_rotate = (fabs(t->rotate) > 1e-5);
+  if (t->opacity != 1 || want_rotate)
     {
+      use_group = 1;
       svg_push_element(svg, "g");
-      svg_set_attr_float(svg, "opacity", t->opacity);
+      if (t->opacity != 1)
+       svg_set_attr_float(svg, "opacity", t->opacity);
+      if (want_rotate)
+       svg_set_attr_format(svg, "transform", "rotate(%.2f %s %s)", -t->rotate, svg_format_dimen(svg, t->x), svg_format_dimen(svg, t->y));
     }
 
   if (t->halo_radius)
@@ -295,7 +302,7 @@ printf("Drawing %s at [%.2f; %.2f]\n", osm_val_decode(t->text), t->x, t->y);
   svg_pop(svg);
 #endif
 
-  if (t->opacity != 1)
+  if (use_group)
     svg_pop(svg);
 }
 
diff --git a/sym.h b/sym.h
index 6af4f2b163a9ad52c77ba981f918b27afc521e94..d2e294c893c7afc541c99984b19039da35075c84 100644 (file)
--- a/sym.h
+++ b/sym.h
@@ -134,6 +134,7 @@ struct sym_text {
   color_t text_color;
   double x;
   double y;
+  double rotate;                       // Rotation in degrees CCW
   struct text_font *font;
   double opacity;
   color_t halo_color;