1998-10-19 20:46:58 +00:00
|
|
|
//
|
2005-02-24 21:55:12 +00:00
|
|
|
// "$Id$"
|
1998-10-19 20:46:58 +00:00
|
|
|
//
|
|
|
|
// Portable drawing routines for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2017-05-17 11:54:18 +00:00
|
|
|
// Copyright 1998-2017 by Bill Spitzak and others.
|
1998-10-19 20:46:58 +00:00
|
|
|
//
|
2011-07-19 04:49:30 +00:00
|
|
|
// 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
|
1998-10-19 20:46:58 +00:00
|
|
|
//
|
2005-04-16 00:13:17 +00:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-19 20:46:58 +00:00
|
|
|
//
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2008-10-14 21:42:24 +00:00
|
|
|
/**
|
|
|
|
\file fl_vertex.cxx
|
|
|
|
\brief Portable drawing code for drawing arbitrary shapes with
|
|
|
|
simple 2D transformations.
|
|
|
|
*/
|
|
|
|
|
2016-01-31 01:14:50 +00:00
|
|
|
// Portable code for drawing arbitrary shapes with simple 2D transformations.
|
|
|
|
// See also fl_arc.cxx
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2008-12-07 18:32:55 +00:00
|
|
|
// matt: the Quartz implementation purposely doesn't use the Quartz matrix
|
2004-08-26 00:18:43 +00:00
|
|
|
// operations for reasons of compatibility and maintainability
|
|
|
|
|
2016-01-31 01:14:50 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// all driver code is now in drivers/XXX/Fl_XXX_Graphics_Driver_xyz.cxx
|
|
|
|
// -----------------------------------------------------------------------------
|
2016-01-03 22:54:29 +00:00
|
|
|
|
2016-03-27 17:37:07 +00:00
|
|
|
#include <FL/Fl_Graphics_Driver.H>
|
2005-07-17 12:17:50 +00:00
|
|
|
#include <FL/Fl.H>
|
1998-10-06 18:21:25 +00:00
|
|
|
#include <FL/math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2018-06-23 16:47:40 +00:00
|
|
|
/**
|
2018-06-23 20:50:22 +00:00
|
|
|
\cond DriverDev
|
|
|
|
\addtogroup DriverDeveloper
|
|
|
|
\{
|
2018-06-23 16:47:40 +00:00
|
|
|
*/
|
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_push_matrix() */
|
2011-02-04 23:32:53 +00:00
|
|
|
void Fl_Graphics_Driver::push_matrix() {
|
2011-02-24 18:02:11 +00:00
|
|
|
if (sptr==matrix_stack_size)
|
2005-07-14 14:31:09 +00:00
|
|
|
Fl::error("fl_push_matrix(): matrix stack overflow.");
|
|
|
|
else
|
|
|
|
stack[sptr++] = m;
|
|
|
|
}
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_pop_matrix() */
|
2011-02-04 23:32:53 +00:00
|
|
|
void Fl_Graphics_Driver::pop_matrix() {
|
2005-07-14 14:31:09 +00:00
|
|
|
if (sptr==0)
|
|
|
|
Fl::error("fl_pop_matrix(): matrix stack underflow.");
|
2017-08-14 17:10:26 +00:00
|
|
|
else
|
2005-07-14 14:31:09 +00:00
|
|
|
m = stack[--sptr];
|
|
|
|
}
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_mult_matrix() */
|
2011-02-04 23:32:53 +00:00
|
|
|
void Fl_Graphics_Driver::mult_matrix(double a, double b, double c, double d, double x, double y) {
|
1998-10-06 18:21:25 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_rotate() */
|
2011-02-18 17:22:43 +00:00
|
|
|
void Fl_Graphics_Driver::rotate(double d) {
|
1998-10-06 18:21:25 +00:00
|
|
|
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);}
|
2011-02-18 17:22:43 +00:00
|
|
|
mult_matrix(c,-s,s,c,0,0);
|
1998-10-06 18:21:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_translate() */
|
2016-01-23 20:22:50 +00:00
|
|
|
void Fl_Graphics_Driver::translate(double x,double y) {
|
|
|
|
mult_matrix(1,0,0,1,x,y);
|
|
|
|
}
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_begin_points() */
|
2016-01-23 20:22:50 +00:00
|
|
|
void Fl_Graphics_Driver::begin_points() {
|
|
|
|
n = 0;
|
|
|
|
what = POINT_;
|
|
|
|
}
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_begin_line() */
|
2016-01-23 20:22:50 +00:00
|
|
|
void Fl_Graphics_Driver::begin_line() {
|
|
|
|
n = 0;
|
|
|
|
what = LINE;
|
|
|
|
}
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_begin_loop() */
|
2016-01-23 20:22:50 +00:00
|
|
|
void Fl_Graphics_Driver::begin_loop() {
|
|
|
|
n = 0;
|
|
|
|
what = LOOP;
|
|
|
|
}
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_begin_polygon() */
|
2016-01-23 20:22:50 +00:00
|
|
|
void Fl_Graphics_Driver::begin_polygon() {
|
|
|
|
n = 0;
|
|
|
|
what = POLYGON;
|
|
|
|
}
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_transform_x() */
|
2016-01-23 20:22:50 +00:00
|
|
|
double Fl_Graphics_Driver::transform_x(double x, double y) {
|
|
|
|
return x*m.a + y*m.c + m.x;
|
|
|
|
}
|
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_transform_y() */
|
2016-01-23 20:22:50 +00:00
|
|
|
double Fl_Graphics_Driver::transform_y(double x, double y) {
|
|
|
|
return x*m.b + y*m.d + m.y;
|
|
|
|
}
|
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_transform_dx() */
|
2016-01-23 20:22:50 +00:00
|
|
|
double Fl_Graphics_Driver::transform_dx(double x, double y) {
|
|
|
|
return x*m.a + y*m.c;
|
|
|
|
}
|
|
|
|
|
2016-04-24 08:38:11 +00:00
|
|
|
/** see fl_transform_dy() */
|
2016-01-23 20:22:50 +00:00
|
|
|
double Fl_Graphics_Driver::transform_dy(double x, double y) {
|
|
|
|
return x*m.b + y*m.d;
|
|
|
|
}
|
1998-10-06 18:21:25 +00:00
|
|
|
|
2018-06-23 16:47:40 +00:00
|
|
|
/**
|
2018-06-23 20:50:22 +00:00
|
|
|
\}
|
|
|
|
\endcond
|
2018-06-23 16:47:40 +00:00
|
|
|
*/
|
|
|
|
|
1998-10-19 20:46:58 +00:00
|
|
|
//
|
2005-02-24 21:55:12 +00:00
|
|
|
// End of "$Id$".
|
1998-10-19 20:46:58 +00:00
|
|
|
//
|