diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2016-01-26 21:10:49 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2016-01-26 21:10:49 +0000 |
| commit | 6694780c2d02d645f053fd60864c9ff035296a64 (patch) | |
| tree | fd205fc40c3b1b0aa432bbc1bdbe2c78f3d1c60b /src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx | |
| parent | ac275b89bcd8333dd1b05bfc9f6fc0accd8e065d (diff) | |
Moving GDI/WIN32 files to new directroy structure
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11058 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx')
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx new file mode 100644 index 000000000..ee12c9ad8 --- /dev/null +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx @@ -0,0 +1,127 @@ +// +// "$Id$" +// +// Portable drawing routines for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2016 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// http://www.fltk.org/COPYING.php +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#ifndef FL_CFG_GFX_GDI_VERTEX_CXX +#define FL_CFG_GFX_GDI_VERTEX_CXX + +/** + \file gdi_vertex.cxx + \brief Portable drawing code for drawing arbitrary shapes with + simple 2D transformations, implemented for MSWindows GDI. + */ + +#include "Fl_GDI_Graphics_Driver.h" + +#include <FL/fl_draw.H> +#include <FL/x.H> +#include <FL/math.h> + + +void Fl_GDI_Graphics_Driver::transformed_vertex(double xf, double yf) { + transformed_vertex0(COORD_T(rint(xf)), COORD_T(rint(yf))); +} + +void Fl_GDI_Graphics_Driver::vertex(double x,double y) { + transformed_vertex0(COORD_T(x*m.a + y*m.c + m.x), COORD_T(x*m.b + y*m.d + m.y)); +} + +void Fl_GDI_Graphics_Driver::end_points() { + for (int i=0; i<n; i++) SetPixel(fl_gc, p[i].x, p[i].y, fl_RGB()); +} + +void Fl_GDI_Graphics_Driver::end_line() { + if (n < 2) { + end_points(); + return; + } + if (n>1) Polyline(fl_gc, p, n); +} + +void Fl_GDI_Graphics_Driver::end_loop() { + fixloop(); + if (n>2) transformed_vertex((COORD_T)p[0].x, (COORD_T)p[0].y); + end_line(); +} + +void Fl_GDI_Graphics_Driver::end_polygon() { + fixloop(); + if (n < 3) { + end_line(); + return; + } + if (n>2) { + SelectObject(fl_gc, fl_brush()); + Polygon(fl_gc, p, n); + } +} + +void Fl_GDI_Graphics_Driver::begin_complex_polygon() { + begin_polygon(); + gap_ = 0; + numcount = 0; +} + +void Fl_GDI_Graphics_Driver::gap() { + while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--; + if (n > gap_+2) { + transformed_vertex((COORD_T)p[gap_].x, (COORD_T)p[gap_].y); + counts[numcount++] = n-gap_; + gap_ = n; + } else { + n = gap_; + } +} + +void Fl_GDI_Graphics_Driver::end_complex_polygon() { + gap(); + if (n < 3) { + end_line(); + return; + } + if (n>2) { + SelectObject(fl_gc, fl_brush()); + PolyPolygon(fl_gc, p, counts, numcount); + } +} + +// shortcut the closed circles so they use XDrawArc: +// warning: these do not draw rotated ellipses correctly! +// See fl_arc.c for portable version. + +void Fl_GDI_Graphics_Driver::circle(double x, double y,double r) { + double xt = transform_x(x,y); + double yt = transform_y(x,y); + double rx = r * (m.c ? sqrt(m.a*m.a+m.c*m.c) : fabs(m.a)); + double ry = r * (m.b ? sqrt(m.b*m.b+m.d*m.d) : fabs(m.d)); + int llx = (int)rint(xt-rx); + int w = (int)rint(xt+rx)-llx; + int lly = (int)rint(yt-ry); + int h = (int)rint(yt+ry)-lly; + + if (what==POLYGON) { + SelectObject(fl_gc, fl_brush()); + Pie(fl_gc, llx, lly, llx+w, lly+h, 0,0, 0,0); + } else + Arc(fl_gc, llx, lly, llx+w, lly+h, 0,0, 0,0); +} + +#endif // FL_CFG_GFX_GDI_VERTEX_CXX + +// +// End of "$Id$". +// |
