Added scale(), translate(), and rotate() functions to the Fl_Graphics_Driver class.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8443 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
199b32d921
commit
f5f0cf9908
@ -195,6 +195,10 @@ protected:
|
||||
friend void fl_push_matrix();
|
||||
friend void fl_pop_matrix();
|
||||
friend void fl_mult_matrix(double a, double b, double c, double d, double x, double y);
|
||||
friend void fl_scale(double x, double y);
|
||||
friend void fl_scale(double x);
|
||||
friend void fl_translate(double x, double y);
|
||||
friend void fl_rotate(double d);
|
||||
friend double fl_transform_x(double x, double y);
|
||||
friend double fl_transform_y(double x, double y);
|
||||
friend double fl_transform_dx(double x, double y);
|
||||
@ -311,6 +315,14 @@ protected:
|
||||
void pop_matrix();
|
||||
/** \brief see fl_mult_matrix(double a, double b, double c, double d, double x, double y). */
|
||||
void mult_matrix(double a, double b, double c, double d, double x, double y);
|
||||
/** \brief see fl_scale(double x, double y). */
|
||||
inline void scale(double x, double y) { mult_matrix(x,0,0,y,0,0); }
|
||||
/** \brief see fl_scale(double x). */
|
||||
inline void scale(double x) { mult_matrix(x,0,0,x,0,0); }
|
||||
/** \brief see fl_translate(double x, double y). */
|
||||
inline void translate(double x,double y) { mult_matrix(1,0,0,1,x,y); }
|
||||
/** \brief see fl_rotate(double d). */
|
||||
void rotate(double d);
|
||||
/** \brief see fl_transform_x(double x, double y). */
|
||||
double transform_x(double x, double y);
|
||||
/** \brief see fl_transform_y(double x, double y). */
|
||||
|
||||
@ -64,8 +64,8 @@
|
||||
class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
|
||||
public:
|
||||
static const char *class_id;
|
||||
Fl_PostScript_Graphics_Driver();
|
||||
#ifndef FL_DOXYGEN
|
||||
public:
|
||||
enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
|
||||
|
||||
class Clip {
|
||||
@ -115,12 +115,6 @@ class Clip {
|
||||
int start_postscript (int pagecount, enum Fl_Paged_Device::Page_Format format, enum Fl_Paged_Device::Page_Layout layout);
|
||||
/* int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
|
||||
*/
|
||||
void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); };
|
||||
#ifdef __APPLE__
|
||||
void draw(const char* s, int n, float x, float y) {transformed_draw(s,n,x,y); };
|
||||
#endif
|
||||
void draw(int angle, const char *str, int n, int x, int y);
|
||||
void rtl_draw(const char* s, int n, int x, int y);
|
||||
void transformed_draw(const char* s, int n, double x, double y); //precise text placing
|
||||
void transformed_draw(const char* s, double x, double y);
|
||||
int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
|
||||
@ -131,6 +125,21 @@ class Clip {
|
||||
|
||||
enum Fl_Paged_Device::Page_Format page_format_;
|
||||
char *ps_filename_;
|
||||
|
||||
void page_policy(int p);
|
||||
int page_policy(){return page_policy_;};
|
||||
void close_command( int (*cmd)(FILE *)){close_cmd_=cmd;};
|
||||
FILE * file() {return output;};
|
||||
//void orientation (int o);
|
||||
//Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor
|
||||
//Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor
|
||||
void interpolate(int i){interpolate_=i;};
|
||||
int interpolate(){return interpolate_;}
|
||||
|
||||
void page(double pw, double ph, int media = 0);
|
||||
void page(int format);
|
||||
#endif // FL_DOXYGEN
|
||||
|
||||
// implementation of drawing methods
|
||||
void color(Fl_Color c);
|
||||
void color(uchar r, uchar g, uchar b);
|
||||
@ -181,34 +190,23 @@ class Clip {
|
||||
void gap(){gap_=1;};
|
||||
void end_complex_polygon(){end_polygon();};
|
||||
void transformed_vertex(double x, double y);
|
||||
|
||||
void font(int face, int size);
|
||||
double width(const char *, int);
|
||||
void text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h);
|
||||
int height();
|
||||
int descent();
|
||||
|
||||
|
||||
void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0){draw_scaled_image(d,x,y,w,h,w,h,delta,ldelta);};
|
||||
void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0){draw_scaled_image_mono(d,x,y,w,h,w,h,delta,ld);};
|
||||
void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3){draw_scaled_image(call,data, x, y, w, h, w, h, delta);};
|
||||
void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1){draw_scaled_image_mono(call, data, x, y, w, h, w, h, delta);};
|
||||
|
||||
public:
|
||||
void page_policy(int p);
|
||||
int page_policy(){return page_policy_;};
|
||||
void close_command( int (*cmd)(FILE *)){close_cmd_=cmd;};
|
||||
FILE * file() {return output;};
|
||||
//void orientation (int o);
|
||||
//Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor
|
||||
//Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor
|
||||
void interpolate(int i){interpolate_=i;};
|
||||
int interpolate(){return interpolate_;}
|
||||
|
||||
void page(double pw, double ph, int media = 0);
|
||||
void page(int format);
|
||||
|
||||
#endif // FL_DOXYGEN
|
||||
Fl_PostScript_Graphics_Driver();
|
||||
void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); };
|
||||
#ifdef __APPLE__
|
||||
void draw(const char* s, int n, float x, float y) {transformed_draw(s,n,x,y); };
|
||||
#endif
|
||||
void draw(int angle, const char *str, int n, int x, int y);
|
||||
void rtl_draw(const char* s, int n, int x, int y);
|
||||
void font(int face, int size);
|
||||
double width(const char *, int);
|
||||
void text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h);
|
||||
int height();
|
||||
int descent();
|
||||
void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
|
||||
24
FL/fl_draw.H
24
FL/fl_draw.H
@ -333,10 +333,26 @@ inline void fl_push_matrix() { fl_graphics_driver->push_matrix(); };
|
||||
Restores the current transformation matrix from the stack.
|
||||
*/
|
||||
inline void fl_pop_matrix() { fl_graphics_driver->pop_matrix(); };
|
||||
FL_EXPORT void fl_scale(double x, double y);
|
||||
FL_EXPORT void fl_scale(double x);
|
||||
FL_EXPORT void fl_translate(double x, double y);
|
||||
FL_EXPORT void fl_rotate(double d);
|
||||
/**
|
||||
Concatenates scaling transformation onto the current one.
|
||||
\param[in] x,y scale factors in x-direction and y-direction
|
||||
*/
|
||||
inline void fl_scale(double x, double y) { fl_graphics_driver->scale(x, y); };
|
||||
/**
|
||||
Concatenates scaling transformation onto the current one.
|
||||
\param[in] x scale factor in both x-direction and y-direction
|
||||
*/
|
||||
inline void fl_scale(double x) { fl_graphics_driver->scale(x, x); };
|
||||
/**
|
||||
Concatenates translation transformation onto the current one.
|
||||
\param[in] x,y translation factor in x-direction and y-direction
|
||||
*/
|
||||
inline void fl_translate(double x, double y) { fl_graphics_driver->translate(x, y); };
|
||||
/**
|
||||
Concatenates rotation transformation onto the current one.
|
||||
\param[in] d - rotation angle, counter-clockwise in degrees (not radians)
|
||||
*/
|
||||
inline void fl_rotate(double d) { fl_graphics_driver->rotate(d); };
|
||||
/**
|
||||
Concatenates another transformation onto the current one.
|
||||
|
||||
|
||||
@ -69,29 +69,7 @@ void Fl_Graphics_Driver::mult_matrix(double a, double b, double c, double d, dou
|
||||
m = o;
|
||||
}
|
||||
|
||||
/**
|
||||
Concatenates scaling transformation onto the current one.
|
||||
\param[in] x,y scale factors in x-direction and y-direction
|
||||
*/
|
||||
void fl_scale(double x,double y) {fl_mult_matrix(x,0,0,y,0,0);}
|
||||
|
||||
/**
|
||||
Concatenates scaling transformation onto the current one.
|
||||
\param[in] x scale factor in both x-direction and y-direction
|
||||
*/
|
||||
void fl_scale(double x) {fl_mult_matrix(x,0,0,x,0,0);}
|
||||
|
||||
/**
|
||||
Concatenates translation transformation onto the current one.
|
||||
\param[in] x,y translation factor in x-direction and y-direction
|
||||
*/
|
||||
void fl_translate(double x,double y) {fl_mult_matrix(1,0,0,1,x,y);}
|
||||
|
||||
/**
|
||||
Concatenates rotation transformation onto the current one.
|
||||
\param[in] d - rotation angle, counter-clockwise in degrees (not radians)
|
||||
*/
|
||||
void fl_rotate(double d) {
|
||||
void Fl_Graphics_Driver::rotate(double d) {
|
||||
if (d) {
|
||||
double s, c;
|
||||
if (d == 0) {s = 0; c = 1;}
|
||||
@ -99,7 +77,7 @@ void fl_rotate(double d) {
|
||||
else if (d == 180) {s = 0; c = -1;}
|
||||
else if (d == 270 || d == -90) {s = -1; c = 0;}
|
||||
else {s = sin(d*M_PI/180); c = cos(d*M_PI/180);}
|
||||
fl_mult_matrix(c,-s,s,c,0,0);
|
||||
mult_matrix(c,-s,s,c,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user