gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/trans.h
diff options
context:
space:
mode:
Diffstat (limited to 'agg-plot/trans.h')
-rw-r--r--agg-plot/trans.h 98
1 files changed, 94 insertions, 4 deletions
diff --git a/agg-plot/trans.h b/agg-plot/trans.h
index 71727d12..54fb7eb4 100644
--- a/agg-plot/trans.h
+++ b/agg-plot/trans.h
@@ -6,6 +6,7 @@
#include "markers.h"
#include "utils.h"
#include "resource-manager.h"
+#include "draw_svg.h"
#include "agg_trans_affine.h"
#include "agg_path_storage.h"
@@ -34,7 +35,6 @@ struct scalable_context {
typedef scalable base_type;
};
-
struct drawable_context {
template <class conv_type, bool approx>
@@ -57,13 +57,65 @@ struct trans {
typedef typename context::base_type base_type;
typedef agg::conv_stroke<base_type> stroke_base;
- typedef typename context::template adapter<stroke_base, true> stroke;
+ typedef typename context::template adapter<stroke_base, true> vs_stroke;
+
+ class stroke : public vs_stroke {
+ public:
+ stroke(base_type* src) : vs_stroke(src), m_width(1.0) { }
+
+ void width(double w) {
+ this->m_output.width(w);
+ m_width = w;
+ }
+
+ virtual str write_svg(int id, agg::rgba8 c) {
+ str path;
+ svg_property_list* ls = this->m_source->svg_path(path);
+ str s = svg_stroke_path(path, m_width, id, c, ls);
+ list::free(ls);
+ return s;
+ }
+
+ private:
+ double m_width;
+ };
typedef agg::conv_curve<base_type> curve_base;
- typedef typename context::template adapter<curve_base, true> curve;
+ typedef typename context::template adapter<curve_base, true> vs_curve;
+
+ class curve : public vs_curve {
+ public:
+ curve(base_type* src) : vs_curve(src) { }
+
+ virtual svg_property_list* svg_path(str& s) {
+ svg_curve_coords_from_vs(this->m_source, s);
+ return 0;
+ }
+ };
typedef agg::conv_dash<base_type> dash_base;
- typedef typename context::template adapter<dash_base, false> dash;
+ typedef typename context::template adapter<dash_base, false> vs_dash;
+
+ class dash : public vs_dash {
+ public:
+ dash(base_type* src) : vs_dash(src), m_dasharray(16) { }
+
+ virtual svg_property_list* svg_path(str& s) {
+ svg_property_list* ls = this->m_source->svg_path(s);
+ svg_property_item item(stroke_dasharray, this->m_dasharray.cstr());
+ ls = new svg_property_list(item, ls);
+ return ls;
+ }
+
+ void add_dash(double a, double b) {
+ this->m_output.add_dash(a, b);
+ this->m_dasharray.append("", ',');
+ this->m_dasharray.printf_add("%g,%g", a, b);
+ }
+
+ private:
+ str m_dasharray;
+ };
typedef agg::conv_contour<base_type> extend_base;
typedef typename context::template adapter<extend_base, true> extend;
@@ -126,4 +178,42 @@ struct trans {
};
};
+template <class T>
+class svg_proxy : public svg_vs {
+protected:
+ T* m_base;
+
+public:
+ svg_proxy(T* src): svg_vs(), m_base(src) { }
+
+ virtual void rewind(unsigned path_id) { m_base->rewind(path_id); }
+ virtual unsigned vertex(double* x, double* y) { return m_base->vertex(x, y); }
+
+ T& self() { return *m_base; }
+};
+
+struct svg_context {
+
+ template <class conv_type, bool approx>
+ class adapter : public svg_vs
+ {
+ protected:
+ conv_type m_output;
+ svg_vs* m_source;
+
+ public:
+ adapter(svg_vs* src): m_output(*src), m_source(src) { }
+
+ template <class init_type>
+ adapter(svg_vs* src, init_type& val): m_output(*src, val), m_source(src) { }
+
+ virtual void rewind(unsigned path_id) { m_output.rewind(path_id); }
+ virtual unsigned vertex(double* x, double* y) { return m_output.vertex(x, y); }
+
+ conv_type& self() { return m_output; };
+ };
+
+ typedef svg_vs base_type;
+};
+
#endif
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月29日 08:54:19 +0000

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