1998-10-20 00:46:58 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
|
|
|
// Portable drawing routines for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2008-09-16 11:26:22 +04:00
|
|
|
// Copyright 1998-2008 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.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
\file fl_vertex.cxx
|
|
|
|
\brief Portable drawing code for drawing arbitrary shapes with
|
|
|
|
simple 2D transformations.
|
|
|
|
*/
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// Portable drawing code for drawing arbitrary shapes with
|
2001-11-22 18:35:02 +03:00
|
|
|
// simple 2D transformations. See also fl_arc.cxx
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2004-08-26 04:18:43 +04:00
|
|
|
// matt: the Quartz implementation purposly doesn't use the Quartz matrix
|
|
|
|
// operations for reasons of compatibility and maintainability
|
|
|
|
|
2004-08-25 04:20:27 +04:00
|
|
|
#include <config.h>
|
1998-10-06 22:21:25 +04:00
|
|
|
#include <FL/fl_draw.H>
|
|
|
|
#include <FL/x.H>
|
2005-07-17 16:17:50 +04:00
|
|
|
#include <FL/Fl.H>
|
1998-10-06 22:21:25 +04:00
|
|
|
#include <FL/math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
struct matrix {double a, b, c, d, x, y;};
|
|
|
|
|
|
|
|
static matrix m = {1, 0, 0, 1, 0, 0};
|
|
|
|
|
2005-07-14 18:31:09 +04:00
|
|
|
static matrix stack[32];
|
1998-10-06 22:21:25 +04:00
|
|
|
static int sptr = 0;
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Save the current transformation matrix on the stack.
|
|
|
|
The maximum depth of the stack is 4.
|
|
|
|
*/
|
2005-07-14 18:31:09 +04:00
|
|
|
void fl_push_matrix() {
|
|
|
|
if (sptr==32)
|
|
|
|
Fl::error("fl_push_matrix(): matrix stack overflow.");
|
|
|
|
else
|
|
|
|
stack[sptr++] = m;
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Restore the current transformation matrix from the stack.
|
|
|
|
*/
|
2005-07-14 18:31:09 +04:00
|
|
|
void fl_pop_matrix() {
|
|
|
|
if (sptr==0)
|
|
|
|
Fl::error("fl_pop_matrix(): matrix stack underflow.");
|
|
|
|
else
|
|
|
|
m = stack[--sptr];
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Concatenate another transformation onto the current one.
|
|
|
|
\param[in] a,b,c,d,x,y transformation matrix elements such that
|
|
|
|
<tt> X' = aX + cY + x </tt> and <tt> Y' = bX +dY + y </tt>
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_mult_matrix(double a, double b, double c, double d, double x, double y) {
|
|
|
|
matrix o;
|
|
|
|
o.a = a*m.a + b*m.c;
|
|
|
|
o.b = a*m.b + b*m.d;
|
|
|
|
o.c = c*m.a + d*m.c;
|
|
|
|
o.d = c*m.b + d*m.d;
|
|
|
|
o.x = x*m.a + y*m.c + m.x;
|
|
|
|
o.y = x*m.b + y*m.d + m.y;
|
|
|
|
m = o;
|
|
|
|
}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Concatenate scaling transformation onto the current one.
|
|
|
|
\param[in] x,y scale factors in x-direction and y-direction
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_scale(double x,double y) {fl_mult_matrix(x,0,0,y,0,0);}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Concatenate scaling transformation onto the current one.
|
|
|
|
\param[in] x scale factor in both x-direction and y-direction
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_scale(double x) {fl_mult_matrix(x,0,0,x,0,0);}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Concatenate translation transformation onto the current one.
|
|
|
|
\param[in] x,y translation factor in x-direction and y-direction
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_translate(double x,double y) {fl_mult_matrix(1,0,0,1,x,y);}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Concatenate rotation transformation onto the current one.
|
|
|
|
\param[in] d - rotation angle, counter-clockwise in degrees (not radians)
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_rotate(double d) {
|
|
|
|
if (d) {
|
|
|
|
double s, c;
|
|
|
|
if (d == 0) {s = 0; c = 1;}
|
|
|
|
else if (d == 90) {s = 1; c = 0;}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// typedef what the x,y fields in a point are:
|
|
|
|
#ifdef WIN32
|
|
|
|
typedef int COORD_T;
|
2004-08-26 22:24:11 +04:00
|
|
|
# define XPOINT XPoint
|
2004-08-26 04:18:43 +04:00
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
|
|
|
typedef float COORD_T;
|
|
|
|
typedef struct { float x; float y; } QPoint;
|
2004-08-26 22:24:11 +04:00
|
|
|
# define XPOINT QPoint
|
2004-09-01 02:00:49 +04:00
|
|
|
extern float fl_quartz_line_width_;
|
1998-10-06 22:21:25 +04:00
|
|
|
#else
|
|
|
|
typedef short COORD_T;
|
2004-08-26 22:24:11 +04:00
|
|
|
# define XPOINT XPoint
|
1998-10-06 22:21:25 +04:00
|
|
|
#endif
|
|
|
|
|
2004-08-26 04:18:43 +04:00
|
|
|
static XPOINT *p = (XPOINT *)0;
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
static int p_size;
|
|
|
|
static int n;
|
|
|
|
static int what;
|
|
|
|
enum {LINE, LOOP, POLYGON, POINT_};
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Start drawing a list of points. Points are added to the list with fl_vertex()
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_begin_points() {n = 0; what = POINT_;}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Start drawing a list of lines.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_begin_line() {n = 0; what = LINE;}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Start drawing a closed sequence of lines.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_begin_loop() {n = 0; what = LOOP;}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Start drawing a convex filled polygon.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_begin_polygon() {n = 0; what = POLYGON;}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Transform coordinate using current transformation matrix.
|
|
|
|
\param[in] x,y coordinate
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
double fl_transform_x(double x, double y) {return x*m.a + y*m.c + m.x;}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Transform coordinate using current transformation matrix.
|
|
|
|
\param[in] x,y coordinate
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
double fl_transform_y(double x, double y) {return x*m.b + y*m.d + m.y;}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Transform distance using current transformation matrix.
|
|
|
|
\param[in] x,y coordinate
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
double fl_transform_dx(double x, double y) {return x*m.a + y*m.c;}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Transform distance using current transformation matrix.
|
|
|
|
\param[in] x,y coordinate
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
double fl_transform_dy(double x, double y) {return x*m.b + y*m.d;}
|
|
|
|
|
|
|
|
static void fl_transformed_vertex(COORD_T x, COORD_T y) {
|
|
|
|
if (!n || x != p[n-1].x || y != p[n-1].y) {
|
|
|
|
if (n >= p_size) {
|
|
|
|
p_size = p ? 2*p_size : 16;
|
2004-08-26 04:18:43 +04:00
|
|
|
p = (XPOINT*)realloc((void*)p, p_size*sizeof(*p));
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
|
|
|
p[n].x = x;
|
|
|
|
p[n].y = y;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Add coordinate pair to the vertex list without further transformations.
|
|
|
|
\param[in] xf,yf transformed coordinate
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_transformed_vertex(double xf, double yf) {
|
2004-08-26 04:18:43 +04:00
|
|
|
#ifdef __APPLE_QUARTZ__
|
|
|
|
fl_transformed_vertex(COORD_T(xf), COORD_T(yf));
|
|
|
|
#else
|
2001-12-29 00:57:41 +03:00
|
|
|
fl_transformed_vertex(COORD_T(rint(xf)), COORD_T(rint(yf)));
|
2004-08-26 04:18:43 +04:00
|
|
|
#endif
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Add a single vertex to the current path.
|
|
|
|
\param[in] x,y coordinate
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_vertex(double x,double y) {
|
|
|
|
fl_transformed_vertex(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y);
|
|
|
|
}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
End list of points, and draw
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_end_points() {
|
2008-10-14 03:10:43 +04:00
|
|
|
#if defined(USE_X11)
|
|
|
|
if (n>1) XDrawPoints(fl_display, fl_window, fl_gc, p, n, 0);
|
|
|
|
#elif defined(WIN32)
|
1998-10-06 22:21:25 +04:00
|
|
|
for (int i=0; i<n; i++) SetPixel(fl_gc, p[i].x, p[i].y, fl_RGB());
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2004-09-01 02:00:49 +04:00
|
|
|
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
|
2004-08-26 04:18:43 +04:00
|
|
|
for (int i=0; i<n; i++) {
|
|
|
|
CGContextMoveToPoint(fl_gc, p[i].x, p[i].y);
|
|
|
|
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
|
|
|
|
CGContextStrokePath(fl_gc);
|
|
|
|
}
|
2004-09-01 02:00:49 +04:00
|
|
|
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
|
1998-10-06 22:21:25 +04:00
|
|
|
#else
|
2008-10-14 03:10:43 +04:00
|
|
|
# error unsupported platform
|
1998-10-06 22:21:25 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
End list of lines, and draw
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_end_line() {
|
2003-01-15 02:48:01 +03:00
|
|
|
if (n < 2) {
|
|
|
|
fl_end_points();
|
|
|
|
return;
|
|
|
|
}
|
2008-10-14 03:10:43 +04:00
|
|
|
#if defined(USE_X11)
|
|
|
|
if (n>1) XDrawLines(fl_display, fl_window, fl_gc, p, n, 0);
|
|
|
|
#elif defined(WIN32)
|
1998-10-06 22:21:25 +04:00
|
|
|
if (n>1) Polyline(fl_gc, p, n);
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2001-11-27 20:44:08 +03:00
|
|
|
if (n<=1) return;
|
2004-08-26 04:18:43 +04:00
|
|
|
CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
|
|
|
|
for (int i=1; i<n; i++)
|
|
|
|
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
|
|
|
|
CGContextStrokePath(fl_gc);
|
1998-10-06 22:21:25 +04:00
|
|
|
#else
|
2008-10-14 03:10:43 +04:00
|
|
|
# error unsupported platform
|
1998-10-06 22:21:25 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fixloop() { // remove equal points from closed path
|
|
|
|
while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--;
|
|
|
|
}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
End closed sequence of lines, and draw
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_end_loop() {
|
|
|
|
fixloop();
|
|
|
|
if (n>2) fl_transformed_vertex((COORD_T)p[0].x, (COORD_T)p[0].y);
|
|
|
|
fl_end_line();
|
|
|
|
}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
End convex filled polygon, and draw
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_end_polygon() {
|
|
|
|
fixloop();
|
2003-01-15 02:48:01 +03:00
|
|
|
if (n < 3) {
|
|
|
|
fl_end_line();
|
|
|
|
return;
|
|
|
|
}
|
2008-10-14 03:10:43 +04:00
|
|
|
#if defined(USE_X11)
|
|
|
|
if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, Convex, 0);
|
|
|
|
#elif defined(WIN32)
|
1998-10-06 22:21:25 +04:00
|
|
|
if (n>2) {
|
|
|
|
SelectObject(fl_gc, fl_brush());
|
|
|
|
Polygon(fl_gc, p, n);
|
|
|
|
}
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2001-11-27 20:44:08 +03:00
|
|
|
if (n<=1) return;
|
2004-08-26 04:18:43 +04:00
|
|
|
CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
|
|
|
|
for (int i=1; i<n; i++)
|
|
|
|
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
|
|
|
|
CGContextClosePath(fl_gc);
|
|
|
|
CGContextFillPath(fl_gc);
|
1998-10-06 22:21:25 +04:00
|
|
|
#else
|
2008-10-14 03:10:43 +04:00
|
|
|
# error unsupported platform
|
1998-10-06 22:21:25 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gap;
|
2008-10-14 03:10:43 +04:00
|
|
|
#if defined(WIN32)
|
1998-10-06 22:21:25 +04:00
|
|
|
static int counts[20];
|
|
|
|
static int numcount;
|
|
|
|
#endif
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Start drawing a complex filled polygon. The polygon may be concave, may
|
|
|
|
have holes in it, or may be several disconnected pieces. Call fl_gap() to
|
|
|
|
seperate loops of the path.
|
|
|
|
|
|
|
|
To outline the polygone, use fl_begin_loop() and reaplace each fl_gap()
|
|
|
|
with fl_end_loop();fl_begin_loop() pairs.
|
|
|
|
|
|
|
|
\note
|
|
|
|
For portability, you should only draw polygons that appear the same
|
|
|
|
whether "even/odd" or "non-zero" winding rules are used to fill them.
|
|
|
|
Holes should be drawn in the opposite direction to the outside loop.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_begin_complex_polygon() {
|
|
|
|
fl_begin_polygon();
|
|
|
|
gap = 0;
|
2008-10-14 03:10:43 +04:00
|
|
|
#if defined(WIN32)
|
1998-10-06 22:21:25 +04:00
|
|
|
numcount = 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
Call fl_gap() to separate loops of the path.
|
|
|
|
It is unnecessary but harmless to call fl_gap() before the first vertex,
|
|
|
|
after the last vertex, or several times in a row.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_gap() {
|
|
|
|
while (n>gap+2 && p[n-1].x == p[gap].x && p[n-1].y == p[gap].y) n--;
|
|
|
|
if (n > gap+2) {
|
|
|
|
fl_transformed_vertex((COORD_T)p[gap].x, (COORD_T)p[gap].y);
|
2008-10-14 03:10:43 +04:00
|
|
|
#if defined(WIN32)
|
1998-10-06 22:21:25 +04:00
|
|
|
counts[numcount++] = n-gap;
|
|
|
|
#endif
|
|
|
|
gap = n;
|
|
|
|
} else {
|
|
|
|
n = gap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
End complex filled polygon, and draw
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_end_complex_polygon() {
|
|
|
|
fl_gap();
|
2003-01-15 02:48:01 +03:00
|
|
|
if (n < 3) {
|
|
|
|
fl_end_line();
|
|
|
|
return;
|
|
|
|
}
|
2008-10-14 03:10:43 +04:00
|
|
|
#if defined(USE_X11)
|
|
|
|
if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, 0, 0);
|
|
|
|
#elif defined(WIN32)
|
1998-10-06 22:21:25 +04:00
|
|
|
if (n>2) {
|
|
|
|
SelectObject(fl_gc, fl_brush());
|
|
|
|
PolyPolygon(fl_gc, p, counts, numcount);
|
|
|
|
}
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2001-11-27 20:44:08 +03:00
|
|
|
if (n<=1) return;
|
2004-08-26 04:18:43 +04:00
|
|
|
CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
|
|
|
|
for (int i=1; i<n; i++)
|
|
|
|
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
|
|
|
|
CGContextClosePath(fl_gc);
|
|
|
|
CGContextFillPath(fl_gc);
|
1998-10-06 22:21:25 +04:00
|
|
|
#else
|
2008-10-14 03:10:43 +04:00
|
|
|
# error unsupported platform
|
1998-10-06 22:21:25 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// shortcut the closed circles so they use XDrawArc:
|
|
|
|
// warning: these do not draw rotated ellipses correctly!
|
|
|
|
// See fl_arc.c for portable version.
|
|
|
|
|
2008-10-15 01:42:24 +04:00
|
|
|
/**
|
|
|
|
fl_circle() is equivalent to fl_arc(...,0,360) but may be faster.
|
|
|
|
It must be the \e only thing in the path: if you want a circle as part of
|
|
|
|
a complex polygon you must use fl_arc()
|
|
|
|
\param[in] x,y,r center and radius of circle
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void fl_circle(double x, double y,double r) {
|
|
|
|
double xt = fl_transform_x(x,y);
|
|
|
|
double yt = fl_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));
|
2002-01-01 16:11:29 +03:00
|
|
|
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;
|
2008-10-14 03:10:43 +04:00
|
|
|
|
|
|
|
#if defined(USE_X11)
|
|
|
|
(what == POLYGON ? XFillArc : XDrawArc)
|
|
|
|
(fl_display, fl_window, fl_gc, llx, lly, w, h, 0, 360*64);
|
|
|
|
#elif defined(WIN32)
|
1998-10-06 22:21:25 +04:00
|
|
|
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);
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2004-09-01 02:00:49 +04:00
|
|
|
// Quartz warning : circle won't scale to current matrix!
|
2004-08-26 04:18:43 +04:00
|
|
|
CGContextAddArc(fl_gc, xt, yt, (w+h)*0.25f, 0, 2.0f*M_PI, 1);
|
|
|
|
(what == POLYGON ? CGContextFillPath : CGContextStrokePath)(fl_gc);
|
1998-10-06 22:21:25 +04:00
|
|
|
#else
|
2008-10-14 03:10:43 +04:00
|
|
|
# error unsupported platform
|
1998-10-06 22:21:25 +04:00
|
|
|
#endif
|
|
|
|
}
|
1998-10-20 00:46:58 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|