diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2016-04-19 20:44:35 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2016-04-19 20:44:35 +0000 |
| commit | 8a910fe8fb10c5c0b84b132bb80982868992b02f (patch) | |
| tree | 2994d6d74eeab44164b9d8045317de05a0decbe6 | |
| parent | 8d796c2cce0eb429d90b6c795954f376dddee752 (diff) | |
Pico, fixed graphics scaling and circles
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11666 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx b/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx index f2db61ac5..70655d22a 100644 --- a/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx +++ b/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx @@ -23,10 +23,7 @@ #include <FL/math.h> -void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) { - fl_color(r,g,b); - fl_rectf(x,y,w,h); -} +static int sign(int x) { return (x>0)-(x<0); } void Fl_Pico_Graphics_Driver::point(int x, int y) @@ -56,9 +53,6 @@ void Fl_Pico_Graphics_Driver::rectf(int x, int y, int w, int h) } -static int sign(int x) { return (x>0)-(x<0); } - - void Fl_Pico_Graphics_Driver::line(int x, int y, int x1, int y1) { if (x==x1) { @@ -261,12 +255,7 @@ void Fl_Pico_Graphics_Driver::begin_polygon() } -void Fl_Pico_Graphics_Driver::transformed_vertex(double xf, double yf) -{ -} - - -void Fl_Pico_Graphics_Driver::vertex(double x, double y) +void Fl_Pico_Graphics_Driver::transformed_vertex(double x, double y) { if (pn>0) { switch (what) { @@ -282,6 +271,12 @@ void Fl_Pico_Graphics_Driver::vertex(double x, double y) } +void Fl_Pico_Graphics_Driver::vertex(double x, double y) +{ + transformed_vertex(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y); +} + + void Fl_Pico_Graphics_Driver::end_points() { pn = 0; @@ -321,11 +316,6 @@ void Fl_Pico_Graphics_Driver::gap() } -static double _fl_hypot(double x, double y) { - return sqrt(x*x + y*y); -} - - void Fl_Pico_Graphics_Driver::circle(double x, double y, double r) { begin_loop(); @@ -333,18 +323,18 @@ void Fl_Pico_Graphics_Driver::circle(double x, double y, double r) double Y = 0; fl_vertex(x+X,y+Y); - double epsilon; { - double r1 = _fl_hypot(fl_transform_dx(r,0), fl_transform_dy(r,0)); - double r2 = _fl_hypot(fl_transform_dx(0,r), fl_transform_dy(0,r)); - if (r1 > r2) r1 = r2; - if (r1 < 2.) r1 = 2.; - epsilon = 2*acos(1.0 - 0.125/r1); - } - double A = 360.0; - int i = int(ceil(fabs(A)/epsilon)); // Segments in approximation + double rx = fabs(transform_dx(r, r)); + double ry = fabs(transform_dy(r, r)); + + double circ = M_PI*0.5*(rx+ry); + int segs = circ * 360 / 1000; // every line is about three pixels long + if (segs<16) segs = 16; + + double A = 2*M_PI; + int i = segs; if (i) { - epsilon = A/i; // Arc length for equal-size steps + double epsilon = A/i; // Arc length for equal-size steps double cos_e = cos(epsilon); // Rotation coefficients double sin_e = sin(epsilon); do { |
