diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2016-01-26 21:01:09 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2016-01-26 21:01:09 +0000 |
| commit | ac275b89bcd8333dd1b05bfc9f6fc0accd8e065d (patch) | |
| tree | e4fcd53eee80ae26f2e4500b99bbee9f211a2bd2 /src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx | |
| parent | f1a2730855e544fbc0973aba7e76f18d377a893c (diff) | |
Moved Quartz graphics driver to the new naming scheme
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11057 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx')
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx new file mode 100644 index 000000000..c6288d7fe --- /dev/null +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx @@ -0,0 +1,75 @@ +// +// "$Id$" +// +// Arc (integer) drawing functions 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_QUARTZ_ARCI_CXX +#define FL_CFG_GFX_QUARTZ_ARCI_CXX + +#include "Fl_Quartz_Graphics_Driver.h" + +/** + \file quartz_arci.cxx + \brief Utility functions for drawing circles using integers +*/ + +void Fl_Quartz_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) { + if (w <= 0 || h <= 0) return; + a1 = (-a1)/180.0f*M_PI; a2 = (-a2)/180.0f*M_PI; + float cx = x + 0.5f*w - 0.5f, cy = y + 0.5f*h - 0.5f; + CGContextSetShouldAntialias(fl_gc, true); + if (w!=h) { + CGContextSaveGState(fl_gc); + CGContextTranslateCTM(fl_gc, cx, cy); + CGContextScaleCTM(fl_gc, w-1.0f, h-1.0f); + CGContextAddArc(fl_gc, 0, 0, 0.5, a1, a2, 1); + CGContextRestoreGState(fl_gc); + } else { + float r = (w+h)*0.25f-0.5f; + CGContextAddArc(fl_gc, cx, cy, r, a1, a2, 1); + } + CGContextStrokePath(fl_gc); + CGContextSetShouldAntialias(fl_gc, false); +} + +void Fl_Quartz_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a2) { + if (w <= 0 || h <= 0) return; + a1 = (-a1)/180.0f*M_PI; a2 = (-a2)/180.0f*M_PI; + float cx = x + 0.5f*w - 0.5f, cy = y + 0.5f*h - 0.5f; + CGContextSetShouldAntialias(fl_gc, true); + if (w!=h) { + CGContextSaveGState(fl_gc); + CGContextTranslateCTM(fl_gc, cx, cy); + CGContextScaleCTM(fl_gc, w, h); + CGContextAddArc(fl_gc, 0, 0, 0.5, a1, a2, 1); + CGContextAddLineToPoint(fl_gc, 0, 0); + CGContextClosePath(fl_gc); + CGContextRestoreGState(fl_gc); + } else { + float r = (w+h)*0.25f; + CGContextAddArc(fl_gc, cx, cy, r, a1, a2, 1); + CGContextAddLineToPoint(fl_gc, cx, cy); + CGContextClosePath(fl_gc); + } + CGContextFillPath(fl_gc); + CGContextSetShouldAntialias(fl_gc, false); +} + +#endif // FL_CFG_GFX_QUARTZ_ARCI_CXX + +// +// End of "$Id$". +// |
