1998-10-20 00:46:58 +04:00
|
|
|
//
|
2004-08-26 10:18:12 +04:00
|
|
|
// "$Id: fl_arci.cxx,v 1.4.2.5.2.8 2004/08/26 06:18:12 matthiaswm Exp $"
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
|
|
|
// Arc (integer) drawing functions for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2004-04-11 08:39:01 +04:00
|
|
|
// Copyright 1998-2004 by Bill Spitzak and others.
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2000-06-06 01:21:24 +04:00
|
|
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// "integer" circle drawing functions. These draw the limited
|
|
|
|
// circle types provided by X and NT graphics. The advantage of
|
|
|
|
// these is that small ones draw quite nicely (probably due to stored
|
|
|
|
// hand-drawn bitmaps of small circles!) and may be implemented by
|
|
|
|
// hardware and thus are fast.
|
|
|
|
|
|
|
|
// Probably should add fl_chord.
|
|
|
|
|
|
|
|
// 3/10/98: created
|
|
|
|
|
|
|
|
#include <FL/fl_draw.H>
|
|
|
|
#include <FL/x.H>
|
|
|
|
#ifdef WIN32
|
|
|
|
#include <FL/math.h>
|
|
|
|
#endif
|
2004-08-25 04:20:27 +04:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
void fl_arc(int x,int y,int w,int h,double a1,double a2) {
|
|
|
|
if (w <= 0 || h <= 0) return;
|
|
|
|
#ifdef WIN32
|
|
|
|
int xa = x+w/2+int(w*cos(a1/180.0*M_PI));
|
|
|
|
int ya = y+h/2-int(h*sin(a1/180.0*M_PI));
|
|
|
|
int xb = x+w/2+int(w*cos(a2/180.0*M_PI));
|
|
|
|
int yb = y+h/2-int(h*sin(a2/180.0*M_PI));
|
1999-11-12 03:19:14 +03:00
|
|
|
Arc(fl_gc, x, y, x+w, y+h, xa, ya, xb, yb);
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QD__)
|
|
|
|
Rect r; r.left=x; r.right=x+w; r.top=y; r.bottom=y+h;
|
|
|
|
a1 = a2-a1; a2 = 450-a2;
|
|
|
|
FrameArc(&r, (short int)a2, (short int)a1);
|
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2004-08-26 04:18:43 +04:00
|
|
|
# warning : no support for ovals yet!
|
|
|
|
float cx = x + 0.5f*w, cy = y + 0.5f*h;
|
2004-08-26 10:18:12 +04:00
|
|
|
float r = (w+h)*0.25f;
|
2004-08-26 04:18:43 +04:00
|
|
|
CGContextAddArc(fl_gc, cx, cy, r, a1/180.0f*M_PI, a2/180.0f*M_PI, 1);
|
|
|
|
CGContextStrokePath(fl_gc);
|
1998-10-06 22:21:25 +04:00
|
|
|
#else
|
|
|
|
XDrawArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void fl_pie(int x,int y,int w,int h,double a1,double a2) {
|
|
|
|
if (w <= 0 || h <= 0) return;
|
|
|
|
#ifdef WIN32
|
|
|
|
if (a1 == a2) return;
|
|
|
|
int xa = x+w/2+int(w*cos(a1/180.0*M_PI));
|
|
|
|
int ya = y+h/2-int(h*sin(a1/180.0*M_PI));
|
|
|
|
int xb = x+w/2+int(w*cos(a2/180.0*M_PI));
|
|
|
|
int yb = y+h/2-int(h*sin(a2/180.0*M_PI));
|
|
|
|
SelectObject(fl_gc, fl_brush());
|
1999-11-12 03:19:14 +03:00
|
|
|
Pie(fl_gc, x, y, x+w, y+h, xa, ya, xb, yb);
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QD__)
|
|
|
|
Rect r; r.left=x; r.right=x+w; r.top=y; r.bottom=y+h;
|
|
|
|
a1 = a2-a1; a2 = 450-a2;
|
|
|
|
PaintArc(&r, (short int)a2, (short int)a1);
|
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2004-08-26 10:18:12 +04:00
|
|
|
# warning : no support for ovals yet!
|
|
|
|
float cx = x + 0.5f*w, cy = y + 0.5f*h;
|
|
|
|
float r = (w+h)*0.25f;
|
|
|
|
CGContextAddArc(fl_gc, cx, cy, r, a1/180.0f*M_PI, a2/180.0f*M_PI, 1);
|
|
|
|
CGContextFillPath(fl_gc);
|
1998-10-06 22:21:25 +04:00
|
|
|
#else
|
|
|
|
XFillArc(fl_display, fl_window, fl_gc, x,y,w,h, int(a1*64),int((a2-a1)*64));
|
|
|
|
#endif
|
|
|
|
}
|
1998-10-20 00:46:58 +04:00
|
|
|
|
|
|
|
//
|
2004-08-26 10:18:12 +04:00
|
|
|
// End of "$Id: fl_arci.cxx,v 1.4.2.5.2.8 2004/08/26 06:18:12 matthiaswm Exp $".
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|