Sync to AGG tree to support stippi's Painter classes

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10693 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2005-01-12 11:05:58 +00:00
parent 75d0f2ba9b
commit abd0030237
52 changed files with 2979 additions and 287 deletions
+112
View File
@@ -0,0 +1,112 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.2
// Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: [email protected]
// [email protected]
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// classes bezier_ctrl_impl, bezier_ctrl
//
//----------------------------------------------------------------------------
#ifndef AGG_BEZIER_CTRL_INCLUDED
#define AGG_BEZIER_CTRL_INCLUDED
#include "agg_math.h"
#include "agg_ellipse.h"
#include "agg_trans_affine.h"
#include "agg_color_rgba.h"
#include "agg_conv_stroke.h"
#include "agg_conv_curve.h"
#include "agg_polygon_ctrl.h"
namespace agg
{
//--------------------------------------------------------bezier_ctrl_impl
class bezier_ctrl_impl : public ctrl
{
public:
bezier_ctrl_impl();
void curve(double x1, double y1,
double x2, double y2,
double x3, double y3,
double x4, double y4);
curve4& curve();
double x1() const { return m_poly.xn(0); }
double y1() const { return m_poly.yn(0); }
double x2() const { return m_poly.xn(1); }
double y2() const { return m_poly.yn(1); }
double x3() const { return m_poly.xn(2); }
double y3() const { return m_poly.yn(2); }
double x4() const { return m_poly.xn(3); }
double y4() const { return m_poly.yn(3); }
void line_width(double w) { m_stroke.width(w); }
double line_width() const { return m_stroke.width(); }
void point_radius(double r) { m_poly.point_radius(r); }
double point_radius() const { return m_poly.point_radius(); }
virtual bool in_rect(double x, double y) const;
virtual bool on_mouse_button_down(double x, double y);
virtual bool on_mouse_button_up(double x, double y);
virtual bool on_mouse_move(double x, double y, bool button_flag);
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
// Vertex source interface
unsigned num_paths() { return 7; };
void rewind(unsigned id);
unsigned vertex(double* x, double* y);
private:
curve4 m_curve;
ellipse m_ellipse;
conv_stroke<curve4> m_stroke;
polygon_ctrl_impl m_poly;
unsigned m_idx;
};
//----------------------------------------------------------bezier_ctrl
template<class ColorT> class bezier_ctrl : public bezier_ctrl_impl
{
public:
bezier_ctrl() :
m_color(rgba(0.0, 0.0, 0.0))
{
}
void line_color(const ColorT& c) { m_color = c; }
const ColorT& color(unsigned i) const { return m_color; }
private:
bezier_ctrl(const bezier_ctrl<ColorT>&);
const bezier_ctrl<ColorT>& operator = (const bezier_ctrl<ColorT>&);
ColorT m_color;
};
}
#endif
+1
View File
@@ -31,6 +31,7 @@ namespace agg
{
public:
//--------------------------------------------------------------------
virtual ~ctrl() {}
ctrl(double x1, double y1, double x2, double y2, bool flip_y) :
m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2),
m_flip_y(flip_y),
+166
View File
@@ -0,0 +1,166 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.2
// Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: [email protected]
// [email protected]
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// classes polygon_ctrl_impl, polygon_ctrl
//
//----------------------------------------------------------------------------
#ifndef POLYGON_CTRL_INCLUDED
#define POLYGON_CTRL_INCLUDED
#include "agg_conv_stroke.h"
#include "agg_ellipse.h"
#include "agg_color_rgba.h"
#include "agg_ctrl.h"
namespace agg
{
class simple_polygon_vertex_source
{
public:
simple_polygon_vertex_source(const double* polygon, unsigned np,
bool roundoff = false,
bool close = true) :
m_polygon(polygon),
m_num_points(np),
m_vertex(0),
m_roundoff(roundoff),
m_close(close)
{
}
void close(bool f) { m_close = f; }
bool close() const { return m_close; }
void rewind(unsigned)
{
m_vertex = 0;
}
unsigned vertex(double* x, double* y)
{
if(m_vertex > m_num_points) return path_cmd_stop;
if(m_vertex == m_num_points)
{
++m_vertex;
return path_cmd_end_poly | (m_close ? path_flags_close : 0);
}
*x = m_polygon[m_vertex * 2];
*y = m_polygon[m_vertex * 2 + 1];
if(m_roundoff)
{
*x = floor(*x) + 0.5;
*y = floor(*y) + 0.5;
}
++m_vertex;
return (m_vertex == 1) ? path_cmd_move_to : path_cmd_line_to;
}
private:
const double* m_polygon;
unsigned m_num_points;
unsigned m_vertex;
bool m_roundoff;
bool m_close;
};
class polygon_ctrl_impl : public ctrl
{
public:
~polygon_ctrl_impl();
polygon_ctrl_impl(unsigned np, double point_radius=5);
unsigned num_points() const { return m_num_points; }
double xn(unsigned n) const { return m_polygon[n * 2]; }
double yn(unsigned n) const { return m_polygon[n * 2 + 1]; }
double& xn(unsigned n) { return m_polygon[n * 2]; }
double& yn(unsigned n) { return m_polygon[n * 2 + 1]; }
const double* polygon() const { return m_polygon; }
void line_width(double w) { m_stroke.width(w); }
double line_width() const { return m_stroke.width(); }
void point_radius(double r) { m_point_radius = r; }
double point_radius() const { return m_point_radius; }
void in_polygon_check(bool f) { m_in_polygon_check = f; }
bool in_polygon_check() const { return m_in_polygon_check; }
void close(bool f) { m_vs.close(f); }
bool close() const { return m_vs.close(); }
// Vertex source interface
unsigned num_paths() { return 1; }
void rewind(unsigned id);
unsigned vertex(double* x, double* y);
virtual bool in_rect(double x, double y) const;
virtual bool on_mouse_button_down(double x, double y);
virtual bool on_mouse_button_up(double x, double y);
virtual bool on_mouse_move(double x, double y, bool button_flag);
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
private:
bool check_edge(unsigned i, double x, double y) const;
bool point_in_polygon(double x, double y) const;
double* m_polygon;
unsigned m_num_points;
int m_node;
int m_edge;
simple_polygon_vertex_source m_vs;
conv_stroke<simple_polygon_vertex_source> m_stroke;
ellipse m_ellipse;
double m_point_radius;
unsigned m_status;
double m_dx;
double m_dy;
bool m_in_polygon_check;
};
//----------------------------------------------------------polygon_ctrl
template<class ColorT> class polygon_ctrl : public polygon_ctrl_impl
{
public:
polygon_ctrl(unsigned np, double point_radius=5) :
polygon_ctrl_impl(np, point_radius),
m_color(rgba(0.0, 0.0, 0.0))
{
}
void line_color(const ColorT& c) { m_color = c; }
const ColorT& color(unsigned i) const { return m_color; }
private:
polygon_ctrl(const polygon_ctrl<ColorT>&);
const polygon_ctrl<ColorT>& operator = (const polygon_ctrl<ColorT>&);
ColorT m_color;
};
}
#endif
+3 -3
View File
@@ -58,8 +58,8 @@ namespace agg
void active_point(int i);
const double* spline() const { return m_spline_values; }
const unsigned char* spline8() const { return m_spline_values8; }
const double* spline() const { return m_spline_values; }
const int8u* spline8() const { return m_spline_values8; }
double value(double x) const;
void value(unsigned idx, double y);
void point(unsigned idx, double x, double y);
@@ -87,7 +87,7 @@ namespace agg
double m_yp[32];
bspline m_spline;
double m_spline_values[256];
unsigned char m_spline_values8[256];
int8u m_spline_values8[256];
double m_border_width;
double m_border_extra;
double m_curve_width;