Merge branch 'master' into fox-gui - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年08月11日 12:07:39 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年08月11日 12:07:39 +0200
commit427d762746455aaf88b2935de122e7201634d8f8 (patch)
tree82bc9a370c9bf64da6b5350594f80bc93dc5e1e7 /agg-plot
parent1167a7ac6cd85e18b7ed45aafef41601de2b1cb9 (diff)
parent5ae3556a85ec812736c5c68af6499c1350268e4e (diff)
downloadgsl-shell-427d762746455aaf88b2935de122e7201634d8f8.tar.gz
Merge branch 'master' into fox-gui
Conflicts: agg-plot/canvas-window-cpp.h agg-plot/window-cpp.h makepackages
Diffstat (limited to 'agg-plot')
-rw-r--r--agg-plot/agg_font_freetype.cpp 3
-rw-r--r--agg-plot/agg_pixfmt_rgb24_lcd.h 8
-rw-r--r--agg-plot/canvas-window-cpp.h 4
-rw-r--r--agg-plot/canvas.h 21
-rw-r--r--agg-plot/colors.cpp 4
-rw-r--r--agg-plot/colors.h 4
-rw-r--r--agg-plot/plot.h 2
-rw-r--r--agg-plot/support_x11.cpp 2
-rw-r--r--agg-plot/text-shape.h 45
-rw-r--r--agg-plot/text.cpp 8
-rw-r--r--agg-plot/text.h 4
-rw-r--r--agg-plot/text_label.h 47
-rw-r--r--agg-plot/window-cpp.h 2
13 files changed, 90 insertions, 64 deletions
diff --git a/agg-plot/agg_font_freetype.cpp b/agg-plot/agg_font_freetype.cpp
index 45fdf46c..f9d82a3a 100644
--- a/agg-plot/agg_font_freetype.cpp
+++ b/agg-plot/agg_font_freetype.cpp
@@ -909,8 +909,7 @@ namespace agg
m_glyph_index = FT_Get_Char_Index(m_cur_face, glyph_code);
m_last_error = FT_Load_Glyph(m_cur_face,
m_glyph_index,
-// m_hinting ? FT_LOAD_DEFAULT : FT_LOAD_NO_HINTING);
- m_hinting ? FT_LOAD_FORCE_AUTOHINT : FT_LOAD_NO_HINTING);
+ m_hinting ? (FT_LOAD_TARGET_LCD|FT_LOAD_FORCE_AUTOHINT) : FT_LOAD_NO_HINTING);
if(m_last_error == 0)
{
switch(m_glyph_rendering)
diff --git a/agg-plot/agg_pixfmt_rgb24_lcd.h b/agg-plot/agg_pixfmt_rgb24_lcd.h
index 3f8f7313..885bd8b3 100644
--- a/agg-plot/agg_pixfmt_rgb24_lcd.h
+++ b/agg-plot/agg_pixfmt_rgb24_lcd.h
@@ -116,8 +116,8 @@ namespace agg
void copy_hline(int x, int y, unsigned len, const color_type& c)
{
- int xr = x / 3;
- int8u* p = m_rbuf->row_ptr(x, y, len) + xr;
+ int xr = x - (x % 3);
+ int8u* p = m_rbuf->row_ptr(y) + xr;
for (int ilen = len; ilen > 0; p += 3, ilen -= 3)
{
p[0] = c.r;
@@ -188,8 +188,8 @@ namespace agg
void copy_hline(int x, int y, unsigned len, const color_type& c)
{
- int xr = x / 3;
- int8u* p = m_rbuf->row_ptr(x, y, len) + xr;
+ int xr = x - (x % 3);
+ int8u* p = m_rbuf->row_ptr(y) + xr;
for (int ilen = len; ilen > 0; p += 3, ilen -= 3)
{
p[0] = c.r;
diff --git a/agg-plot/canvas-window-cpp.h b/agg-plot/canvas-window-cpp.h
index 29ccc75e..2d29fef5 100644
--- a/agg-plot/canvas-window-cpp.h
+++ b/agg-plot/canvas-window-cpp.h
@@ -22,7 +22,7 @@ extern "C" {
class canvas_window : public platform_support_ext {
protected:
canvas *m_canvas;
- agg::rgba m_bgcolor;
+ agg::rgba8 m_bgcolor;
agg::trans_affine m_matrix;
@@ -43,7 +43,7 @@ public:
enum win_status_e status;
- canvas_window(gsl_shell_state* gs, agg::rgba& bgcol):
+ canvas_window(gsl_shell_state* gs, agg::rgba8 bgcol):
platform_support_ext(gslshell::pixel_format, true),
m_canvas(NULL), m_bgcolor(bgcol), m_matrix(), m_gsl_shell(gs),
status(not_ready)
diff --git a/agg-plot/canvas.h b/agg-plot/canvas.h
index 3a35a501..eba25b61 100644
--- a/agg-plot/canvas.h
+++ b/agg-plot/canvas.h
@@ -20,7 +20,7 @@ template <class Pixel>
class renderer_gray_aa
{
public:
- renderer_gray_aa(agg::rendering_buffer& ren_buf, agg::rgba bg_color):
+ renderer_gray_aa(agg::rendering_buffer& ren_buf, agg::rgba8 bg_color):
m_pixbuf(ren_buf), m_ren_base(m_pixbuf), m_ren_solid(m_ren_base),
m_bgcol(bg_color)
{ }
@@ -40,13 +40,12 @@ public:
void color(agg::rgba8 c) { m_ren_solid.color(c); }
- void clear(agg::rgba c) { m_ren_base.clear(c); }
+ void clear(agg::rgba8 c) { m_ren_base.clear(c); }
void clear_box(const agg::rect_base<int>& r)
{
- unsigned len = r.x2 - r.x1;
for (int y = r.y1; y < r.y2; y++)
- m_ren_base.copy_hline (r.x1, y, len, m_bgcol);
+ m_ren_base.copy_hline (r.x1, y, r.x2, m_bgcol);
}
void clip_box(const agg::rect_base<int>& clip)
@@ -65,7 +64,7 @@ private:
Pixel m_pixbuf;
agg::renderer_base<Pixel> m_ren_base;
agg::renderer_scanline_aa_solid<agg::renderer_base<Pixel> > m_ren_solid;
- agg::rgba m_bgcol;
+ agg::rgba8 m_bgcol;
};
template <class Pixel>
@@ -79,7 +78,7 @@ class renderer_subpixel_aa
};
public:
- renderer_subpixel_aa(agg::rendering_buffer& ren_buf, agg::rgba bg_color):
+ renderer_subpixel_aa(agg::rendering_buffer& ren_buf, agg::rgba8 bg_color):
m_pixbuf(ren_buf), m_ren_base(m_pixbuf), m_ren_solid(m_ren_base),
m_bgcol(bg_color)
{ }
@@ -91,13 +90,13 @@ public:
double width() const { return m_pixbuf.width() / subpixel_scale; };
double height() const { return m_pixbuf.height(); };
- void clear(agg::rgba c) { m_ren_base.clear(c); }
+ void clear(agg::rgba8 c) { m_ren_base.clear(c); }
void clear_box(const agg::rect_base<int>& r)
{
- unsigned len = subpixel_scale * (r.x2 - r.x1);
+ int x1 = subpixel_scale * r.x1, x2 = subpixel_scale * r.x2;
for (int y = r.y1; y < r.y2; y++)
- m_ren_base.copy_hline (subpixel_scale * r.x1, y, len, m_bgcol);
+ m_ren_base.copy_hline (x1, y, x2, m_bgcol);
}
void clip_box(const agg::rect_base<int>& clip)
@@ -128,7 +127,7 @@ private:
pixfmt_type m_pixbuf;
agg::renderer_base<pixfmt_type> m_ren_base;
agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt_type> > m_ren_solid;
- agg::rgba m_bgcol;
+ agg::rgba8 m_bgcol;
};
template <class Renderer>
@@ -143,7 +142,7 @@ class canvas_gen : public Renderer {
public:
canvas_gen(agg::rendering_buffer& ren_buf, double width, double height,
- agg::rgba bgcol):
+ agg::rgba8 bgcol):
Renderer(ren_buf, bgcol), ras(), sl()
{ }
diff --git a/agg-plot/colors.cpp b/agg-plot/colors.cpp
index adef7ea9..9cee633e 100644
--- a/agg-plot/colors.cpp
+++ b/agg-plot/colors.cpp
@@ -70,7 +70,7 @@ color_arg_lookup (lua_State *L, int index)
return rgba8_lookup (L, cstr);
}
-agg::rgba colors::white(1, 1, 1);
-agg::rgba colors::black(0, 0, 0);
+agg::rgba8 colors::white(0xff, 0xff, 0xff);
+agg::rgba8 colors::black(0, 0, 0);
agg::rgba8 colors::cdefault(180, 0, 0, 255);
diff --git a/agg-plot/colors.h b/agg-plot/colors.h
index ceba512e..a507c729 100644
--- a/agg-plot/colors.h
+++ b/agg-plot/colors.h
@@ -12,8 +12,8 @@ extern agg::rgba8 color_arg_lookup (lua_State *L, int index);
namespace colors {
- extern agg::rgba white;
- extern agg::rgba black;
+ extern agg::rgba8 white;
+ extern agg::rgba8 black;
extern agg::rgba8 cdefault;
};
diff --git a/agg-plot/plot.h b/agg-plot/plot.h
index 9cfb159b..fbc6707c 100644
--- a/agg-plot/plot.h
+++ b/agg-plot/plot.h
@@ -796,7 +796,7 @@ void plot<RM>::draw_axis(canvas_type& canvas, agg::trans_affine& canvas_mtx,
{
draw::text* label = labels[j];
label->apply_transform(m, 1.0);
- canvas.draw(*label, agg::rgba(0, 0, 0));
+ canvas.draw(*label, colors::black);
}
lndash.add_dash(7.0, 3.0);
diff --git a/agg-plot/support_x11.cpp b/agg-plot/support_x11.cpp
index cc40d3d2..a489c730 100644
--- a/agg-plot/support_x11.cpp
+++ b/agg-plot/support_x11.cpp
@@ -2,7 +2,7 @@
#include "agg-pixfmt-config.h"
-const char *ttf_names[] = {"freefont/FreeSans.ttf", "ttf-dejavu/DejaVuSans.ttf", 0};
+const char *ttf_names[] = {"ubuntu-font-family/Ubuntu-R.ttf", "freefont/FreeSans.ttf", "ttf-dejavu/DejaVuSans.ttf", 0};
const char *gslshell::get_font_name()
{
diff --git a/agg-plot/text-shape.h b/agg-plot/text-shape.h
index 38abf892..e8dff0ce 100644
--- a/agg-plot/text-shape.h
+++ b/agg-plot/text-shape.h
@@ -10,11 +10,12 @@ namespace draw {
public:
text_shape(double x, double y, const char* text,
double _size = 10.0, double hjustif = 0.0, double vjustif = 0.0):
- m_text_label(text, _size), m_scaling(0), m_size(_size)
+ m_text_label(text, round(_size)), m_x(x), m_y(y), m_font_size(_size), m_size(_size)
{
- m_matrix.tx = x;
- m_matrix.ty = y;
+ m_matrix.tx = m_x;
+ m_matrix.ty = m_y;
m_text_label.model_mtx(m_matrix);
+ compute_bounding_box();
}
virtual void rewind(unsigned path_id)
@@ -24,20 +25,25 @@ namespace draw {
virtual unsigned vertex(double* x, double* y)
{
- unsigned cmd = m_text_label.vertex(x, y);
- if (m_scaling && agg::is_vertex(cmd))
- m_scaling->transform(x, y);
- return cmd;
+ return m_text_label.vertex(x, y);
}
virtual void bounding_box(double *x1, double *y1, double *x2, double *y2)
{
+ *x1 = m_bbox.x1;
+ *y1 = m_bbox.y1;
+ *x2 = m_bbox.x2;
+ *y2 = m_bbox.y2;
+ }
+
+ void compute_bounding_box()
+ {
const double pad = 1.0;
const double tx = m_matrix.tx, ty = m_matrix.ty;
- *x1 = tx - pad;
- *y1 = ty - pad;
- *x2 = tx + m_text_label.get_text_width() + pad;
- *y2 = ty + m_text_label.get_text_height() + pad;
+ m_bbox.x1 = tx - pad;
+ m_bbox.y1 = ty - pad;
+ m_bbox.x2 = tx + m_text_label.get_text_width() + pad;
+ m_bbox.y2 = ty + m_text_label.get_text_height() + pad;
}
virtual str write_svg(int id, agg::rgba8 c, double h)
@@ -48,11 +54,6 @@ namespace draw {
const agg::trans_affine& m = m_matrix;
double x = m.tx, y = m.ty;
- if (m_scaling)
- {
- m_scaling->transform(&x, &y);
- txt_size *= m_scaling->sy;
- }
str s = str::print("<text x=\"%g\" y=\"%g\" id=\"text%i\"" \
" style=\"font-size:%i\">" \
@@ -65,15 +66,23 @@ namespace draw {
virtual void apply_transform(const agg::trans_affine& m, double as)
{
- m_scaling = &m;
+ m_text_label.font_size(m.sx * m_font_size, round(m.sy * m_font_size));
+
+ double x = m_x, y = m_y;
+ m.transform(&x, &y);
+ m_matrix.tx = x;
+ m_matrix.ty = y;
+
m_text_label.approximation_scale(m.scale());
}
private:
text_label m_text_label;
+ double m_x, m_y;
+ double m_font_size;
agg::trans_affine m_matrix;
- const agg::trans_affine* m_scaling;
double m_size;
+ agg::rect_base<double> m_bbox;
};
}
diff --git a/agg-plot/text.cpp b/agg-plot/text.cpp
index 90e55129..0582b9e0 100644
--- a/agg-plot/text.cpp
+++ b/agg-plot/text.cpp
@@ -11,10 +11,10 @@ namespace draw {
void
text::apply_transform(const agg::trans_affine& m, double as)
{
- m_matrix.tx = m_x;
- m_matrix.ty = m_y;
-
- m.transform(&m_matrix.tx, &m_matrix.ty);
+ double x = m_x, y = m_y;
+ m.transform(&x, &y);
+ m_matrix.tx = x;
+ m_matrix.ty = round(y);
}
void
diff --git a/agg-plot/text.h b/agg-plot/text.h
index 96957bbf..c6c62e6e 100644
--- a/agg-plot/text.h
+++ b/agg-plot/text.h
@@ -23,7 +23,7 @@ class text : public sg_object
public:
text(const char* text, double size = 10.0, double hjustif = 0.0, double vjustif = 0.0):
m_x(0.0), m_y(0.0), m_angle(0.0),
- m_hjustif(hjustif), m_vjustif(vjustif), m_text_label(text, size)
+ m_hjustif(hjustif), m_vjustif(vjustif), m_text_label(text, round(size))
{
m_text_label.model_mtx(m_matrix);
}
@@ -54,7 +54,7 @@ class text : public sg_object
const char * get_text() const { return m_text_label.text().cstr(); }
- double text_height() const { return m_text_label.text_height(); }
+ double text_height() const { return m_text_label.get_text_height(); }
void set_point(double x, double y)
{
diff --git a/agg-plot/text_label.h b/agg-plot/text_label.h
index d5ed932d..8d5d7293 100644
--- a/agg-plot/text_label.h
+++ b/agg-plot/text_label.h
@@ -10,6 +10,12 @@
#include "sg_object.h"
+struct grid_fit_y_only {
+ static void adjust(double& x, double& y) { y = round(y); }
+};
+
+typedef grid_fit_y_only grid_fit;
+
class text_label
{
enum { scale_x = 100 };
@@ -20,7 +26,8 @@ class text_label
str m_text_buf;
double m_width;
- double m_height;
+ double m_font_height;
+ double m_font_width;
unsigned m_pos;
double m_x, m_y;
@@ -36,25 +43,23 @@ class text_label
public:
text_label(const char* text, double size):
- m_text_buf(text), m_height(size), m_pos(0),
+ m_text_buf(text), m_font_height(size), m_font_width(size),
m_font_eng(gslshell::font_engine()), m_font_man(gslshell::font_manager()),
m_model_mtx(&identity_matrix),
m_text_curve(m_font_man.path_adaptor()), m_text_trans(m_text_curve, m_text_mtx)
{
- set_font_size();
+ update_font_size();
m_width = get_text_width();
}
void model_mtx(const agg::trans_affine& m) { m_model_mtx = &m; }
- void set_font_size()
+ void font_size(double height, double width)
{
- m_font_eng.height(m_height);
- m_font_eng.width(m_height * scale_x);
+ m_font_height = height;
+ m_font_width = width;
}
- double text_height() const { return m_height; }
-
const str& text() const { return m_text_buf; }
bool load_glyph()
@@ -72,9 +77,16 @@ class text_label
if(glyph->data_type == agg::glyph_data_outline)
{
- m_text_mtx.tx = m_x / scale_x;
- m_text_mtx.ty = floor(m_y + 0.5);
- m_model_mtx->transform(&m_text_mtx.tx, &m_text_mtx.ty);
+ agg::trans_affine& m = m_text_mtx;
+
+ m.tx = m_x / scale_x;
+ m.ty = m_y;
+ m_model_mtx->transform(&m.tx, &m.ty);
+
+ if (fabs(m.sx * m.sy) > fabs(m.shx * m.shy))
+ grid_fit::adjust(m.tx, m.ty);
+ else
+ grid_fit::adjust(m.ty, m.tx);
m_advance_x = glyph->advance_x;
m_advance_y = glyph->advance_y;
@@ -88,7 +100,7 @@ class text_label
void rewind(double hjustif, double vjustif)
{
m_x = scale_x * (- hjustif * m_width);
- m_y = - 0.86 * vjustif * m_height;
+ m_y = - 0.86 * vjustif * m_font_height;
m_advance_x = 0;
m_advance_y = 0;
m_pos = 0;
@@ -97,7 +109,7 @@ class text_label
agg::trans_affine_scaling scale_mtx(1.0 / double(scale_x), 1.0);
trans_affine_compose (m_text_mtx, scale_mtx);
- set_font_size();
+ update_font_size();
load_glyph();
}
@@ -118,7 +130,7 @@ class text_label
void approximation_scale(double as) { m_text_curve.approximation_scale(as); }
- double get_text_height() const { return m_height; }
+ double get_text_height() const { return m_font_height; }
double get_text_width()
{
@@ -139,6 +151,13 @@ class text_label
return x / double(scale_x);
}
+
+private:
+ void update_font_size()
+ {
+ m_font_eng.height(m_font_height);
+ m_font_eng.width(m_font_width * scale_x);
+ }
};
#endif
diff --git a/agg-plot/window-cpp.h b/agg-plot/window-cpp.h
index 53afe152..20ba4744 100644
--- a/agg-plot/window-cpp.h
+++ b/agg-plot/window-cpp.h
@@ -60,7 +60,7 @@ private:
ref::node* m_tree;
public:
- window(gsl_shell_state* gs, agg::rgba bgcol= colors::white):
+ window(gsl_shell_state* gs, agg::rgba8 bgcol= colors::white):
canvas_window(gs, bgcol), m_tree(0)
{
this->split(".");
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月28日 00:13:25 +0000

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