First draft of AGG plot modules. The old one based on GNU libplot is removed. - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/canvas.h
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2009年11月18日 19:31:25 +0000
committerFrancesco Abbate <francesco.bbt@gmail.com>2009年11月18日 19:31:25 +0000
commitb2d5b7d64100164e40e3141094736f2ac010a69f (patch)
tree41ac9a78eea0c8c677b7dff6e6a46f5f901fae19 /agg-plot/canvas.h
parente8a10279d92ab7a66402bae02a8fc423a6162fd5 (diff)
downloadgsl-shell-b2d5b7d64100164e40e3141094736f2ac010a69f.tar.gz
First draft of AGG plot modules. The old one based on GNU libplot is removed.
Diffstat (limited to 'agg-plot/canvas.h')
-rw-r--r--agg-plot/canvas.h 76
1 files changed, 76 insertions, 0 deletions
diff --git a/agg-plot/canvas.h b/agg-plot/canvas.h
new file mode 100644
index 00000000..0a4aac22
--- /dev/null
+++ b/agg-plot/canvas.h
@@ -0,0 +1,76 @@
+#ifndef AGGPLOT_CANVAS_H
+#define AGGPLOT_CANVAS_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include "agg_rendering_buffer.h"
+#include "agg_rasterizer_scanline_aa.h"
+// #include "agg_ellipse.h"
+// #include "agg_trans_affine.h"
+// #include "agg_conv_transform.h"
+// #include "agg_conv_stroke.h"
+#include "agg_pixfmt_rgb.h"
+#include "agg_scanline_p.h"
+#include "agg_renderer_scanline.h"
+#include "agg_trans_viewport.h"
+// #include "agg_image_filters.h"
+
+class canvas {
+ typedef agg::pixfmt_bgr24 pixel_fmt;
+ typedef agg::renderer_base<pixel_fmt> renderer_base;
+ typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
+
+ pixel_fmt *pixf;
+ renderer_base *rb;
+ renderer_solid *rs;
+
+ agg::rasterizer_scanline_aa<> ras;
+ agg::scanline_p8 sl;
+
+ agg::rgba bg_color;
+
+ agg::trans_affine mtx;
+
+ double m_width;
+ double m_height;
+
+public:
+ canvas(agg::rendering_buffer& ren_buf, double width, double height,
+ agg::rgba bgcol):
+ ras(), sl(), bg_color(bgcol), mtx(), m_width(width), m_height(height)
+ {
+ pixf = new pixel_fmt(ren_buf);
+ rb = new renderer_base(*pixf);
+ rs = new renderer_solid(*rb);
+
+ mtx.scale(width, height);
+ };
+
+ ~canvas() {
+ free (rs);
+ free (rb);
+ free (pixf);
+ };
+
+ double width() const { return m_width; };
+ double height() const { return m_height; };
+
+ void clear() { rb->clear(bg_color); };
+
+ const agg::trans_affine& trans_matrix() const { return mtx; };
+
+ template<class VertexSource>
+ void draw(VertexSource& vs, agg::rgba8 c)
+ {
+ if (rs == NULL)
+ return;
+
+ ras.add_path(vs);
+ rs->color(c);
+ agg::render_scanlines(ras, sl, *rs);
+ };
+};
+
+#endif
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月16日 11:31:08 +0000

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