gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat
-rw-r--r--agg-plot/canvas.h 82
1 files changed, 46 insertions, 36 deletions
diff --git a/agg-plot/canvas.h b/agg-plot/canvas.h
index f5304bec..c7ca3e6b 100644
--- a/agg-plot/canvas.h
+++ b/agg-plot/canvas.h
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <limits.h>
+#include "agg_basics.h"
#include "agg_rendering_buffer.h"
#include "agg_rasterizer_scanline_aa.h"
#include "agg_pixfmt_rgb.h"
@@ -14,28 +15,39 @@
#include "agg_rasterizer_outline_aa.h"
#include "agg_renderer_outline_aa.h"
-#ifdef ENABLE_GAMMA_CORR
#include "agg_gamma_lut.h"
-#endif
-#include "utils.h"
-
-class canvas {
-#ifdef ENABLE_GAMMA_CORR
+class pixel_gamma_corr {
typedef agg::gamma_lut<agg::int8u, agg::int16u, 8, 12> gamma_type;
typedef agg::pixfmt_bgr24_gamma<gamma_type> pixel_fmt;
-#else
- typedef agg::pixfmt_bgr24 pixel_fmt;
-#endif
- typedef agg::renderer_base<pixel_fmt> renderer_base;
+
+ gamma_type m_gamma;
+
+public:
+ typedef pixel_fmt fmt;
+
+ pixel_gamma_corr(agg::rendering_buffer& ren_buf):
+ m_gamma(2.2), pixfmt(ren_buf, m_gamma)
+ { };
+
+ pixel_fmt pixfmt;
+};
+
+struct pixel_simple {
+ agg::pixfmt_bgr24 pixfmt;
+
+ typedef agg::pixfmt_bgr24 fmt;
+
+ pixel_simple(agg::rendering_buffer& ren_buf): pixfmt(ren_buf) { };
+};
+
+template <class pixel, int linewidth>
+class canvas_gen : private pixel {
+ typedef agg::renderer_base<typename pixel::fmt> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
typedef agg::renderer_outline_aa<renderer_base> renderer_oaa;
typedef agg::rasterizer_outline_aa<renderer_oaa> rasterizer_outline_aa;
-#ifdef ENABLE_GAMMA_CORR
- gamma_type m_gamma;
-#endif
- pixel_fmt pixf;
renderer_base rb;
renderer_solid rs;
@@ -52,49 +64,47 @@ class canvas {
double m_height;
public:
- canvas(agg::rendering_buffer& ren_buf, double width, double height,
- agg::rgba bgcol):
-#ifdef ENABLE_GAMMA_CORR
- m_gamma(2.2), pixf(ren_buf, m_gamma), rb(pixf), rs(rb),
-#else
- pixf(ren_buf), rb(pixf), rs(rb),
-#endif
- prof(), ren_oaa(rb, prof), ras_oaa(ren_oaa),
+ canvas_gen(agg::rendering_buffer& ren_buf, double width, double height,
+ agg::rgba bgcol):
+ pixel(ren_buf), rb(pixel::pixfmt), rs(rb), prof(),
+ ren_oaa(rb, prof), ras_oaa(ren_oaa),
ras(), sl(), bg_color(bgcol),
m_width(width), m_height(height)
{
-#ifdef ENABLE_GAMMA_CORR
- prof.width(1.5);
-#else
- prof.width(1.0);
-#endif
+ prof.width(linewidth / 10.0L);
};
- double width() const { return m_width; };
+ double width() const { return m_width; };
double height() const { return m_height; };
void clear() { rb.clear(bg_color); };
- void clear_box(int x1, int y1, int width, int height)
+ void clear_box(const agg::rect_base<int>& r)
{
- for (int y = y1; y < y1 + height; y++)
- rb.copy_hline (x1, y, x1 + width, bg_color);
+ for (int y = r.y1; y < r.y2; y++)
+ this->rb.copy_hline (r.x1, y, r.x2, bg_color);
};
template<class VertexSource>
void draw(VertexSource& vs, agg::rgba8 c)
{
- ras.add_path(vs);
- rs.color(c);
- agg::render_scanlines(ras, sl, rs);
+ this->ras.add_path(vs);
+ this->rs.color(c);
+ agg::render_scanlines(this->ras, this->sl, this->rs);
};
template<class VertexSource>
void draw_outline(VertexSource& vs, agg::rgba8 c)
{
- ren_oaa.color(c);
- ras_oaa.add_path(vs);
+ this->ren_oaa.color(c);
+ this->ras_oaa.add_path(vs);
};
};
+#ifdef ENABLE_GAMMA_CORR
+typedef canvas_gen<pixel_gamma_corr, 15> canvas;
+#else
+typedef canvas_gen<pixel_simple, 10> canvas;
+#endif
+
#endif
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月17日 12:15:24 +0000

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