author | Francesco Abbate <francesco.bbt@gmail.com> | 2009年11月18日 19:31:25 +0000 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2009年11月18日 19:31:25 +0000 |
commit | b2d5b7d64100164e40e3141094736f2ac010a69f (patch) | |
tree | 41ac9a78eea0c8c677b7dff6e6a46f5f901fae19 /agg-plot/canvas.h | |
parent | e8a10279d92ab7a66402bae02a8fc423a6162fd5 (diff) | |
download | gsl-shell-b2d5b7d64100164e40e3141094736f2ac010a69f.tar.gz |
-rw-r--r-- | agg-plot/canvas.h | 76 |
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 |