gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/draw_svg.h
diff options
context:
space:
mode:
Diffstat (limited to 'agg-plot/draw_svg.h')
-rw-r--r--agg-plot/draw_svg.h 29
1 files changed, 20 insertions, 9 deletions
diff --git a/agg-plot/draw_svg.h b/agg-plot/draw_svg.h
index f7341a67..20d5a77c 100644
--- a/agg-plot/draw_svg.h
+++ b/agg-plot/draw_svg.h
@@ -22,10 +22,21 @@ struct svg_property_item {
svg_property_item(enum svg_path_property_e k, const char *v) : key(k), value(v) { }
};
+static inline double svg_y_coord(double y, double h) { return h - y; }
+
+template <class VertexSource>
+static inline unsigned
+vertex_flip(VertexSource* vs, double* x, double* y, double h)
+{
+ unsigned cmd = vs->vertex(x, y);
+ *y = svg_y_coord(*y, h);
+ return cmd;
+}
+
typedef pod_list<svg_property_item> svg_property_list;
template <typename VertexSource>
-void svg_coords_from_vs(VertexSource* vs, str& s)
+void svg_coords_from_vs(VertexSource* vs, str& s, double h)
{
unsigned cmd;
double x, y;
@@ -34,7 +45,7 @@ void svg_coords_from_vs(VertexSource* vs, str& s)
vs->rewind(0);
- while ((cmd = vs->vertex(&x, &y)))
+ while ((cmd = vertex_flip(vs, &x, &y, h)))
{
if (agg::is_move_to(cmd)) {
s.printf_add("%sM %g,%g", sep, x, y);
@@ -43,11 +54,11 @@ void svg_coords_from_vs(VertexSource* vs, str& s)
} else if (agg::is_close(cmd)) {
s.printf_add("%sz", sep);
} else if (agg::is_curve3(cmd)) {
- vs->vertex(&x, &y);
+ vertex_flip(vs, &x, &y, h);
s.printf_add("%s%g,%g", sep, x, y);
} else if (agg::is_curve4(cmd)) {
vs->vertex(&x, &y);
- vs->vertex(&x, &y);
+ vertex_flip(vs, &x, &y, h);
s.printf_add("%s%g,%g", sep, x, y);
}
sep = space;
@@ -55,7 +66,7 @@ void svg_coords_from_vs(VertexSource* vs, str& s)
}
template <typename VertexSource>
-void svg_curve_coords_from_vs(VertexSource* vs, str& s)
+void svg_curve_coords_from_vs(VertexSource* vs, str& s, double h)
{
unsigned cmd;
double x, y;
@@ -65,7 +76,7 @@ void svg_curve_coords_from_vs(VertexSource* vs, str& s)
vs->rewind(0);
- while ((cmd = vs->vertex(&x, &y)))
+ while ((cmd = vertex_flip(vs, &x, &y, h)))
{
if (agg::is_move_to(cmd)) {
s.printf_add("%sM %g,%g", sep, x, y);
@@ -75,13 +86,13 @@ void svg_curve_coords_from_vs(VertexSource* vs, str& s)
} else if (agg::is_curve4(cmd)) {
double x1 = x, y1 = y;
double x2, y2;
- vs->vertex(&x2, &y2);
- vs->vertex(&x, &y);
+ vertex_flip(vs, &x2, &y2, h);
+ vertex_flip(vs, &x, &y, h);
s.printf_add("%sC %g,%g %g,%g %g,%g", sep, x1, y1, x2, x2, x, y);
omit_line_to = false;
} else if (agg::is_curve3(cmd)) {
double x1 = x, y1 = y;
- vs->vertex(&x, &y);
+ vertex_flip(vs, &x, &y, h);
s.printf_add("%sQ %g,%g %g,%g", sep, x1, y1, x, y);
omit_line_to = false;
} else if (agg::is_close(cmd)) {
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月15日 08:33:50 +0000

AltStyle によって変換されたページ (->オリジナル) /