You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.8KB

  1. //
  2. // "$Id: unittest_lines.cxx 7913 2010-11-29 18:18:27Z greg.ercolano $"
  3. //
  4. // Unit tests for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. #include <FL/Fl_Box.H>
  28. #include <FL/fl_draw.H>
  29. //
  30. //------- test the line drawing capabilities of this implementation ----------
  31. //
  32. class LineTest : public Fl_Box {
  33. public:
  34. static Fl_Widget *create() {
  35. return new LineTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H);
  36. }
  37. LineTest(int x, int y, int w, int h) : Fl_Box(x, y, w, h) {
  38. label("testing the integer based fl_line calls\n"
  39. "No red pixels should be visible.\n"
  40. "If you see bright red pixels, the line drawing alignment is off,\n"
  41. "or the last pixel in a line does not get drawn.\n"
  42. "If you see dark red pixels, anti-aliasing must be switched off.");
  43. align(FL_ALIGN_INSIDE|FL_ALIGN_BOTTOM|FL_ALIGN_LEFT|FL_ALIGN_WRAP);
  44. box(FL_BORDER_BOX);
  45. }
  46. void draw() {
  47. Fl_Box::draw();
  48. int a = x()+10, b = y()+10; fl_color(FL_BLACK); fl_rect(a, b, 100, 100);
  49. // testing fl_xyline(x, y, x1)
  50. fl_color(FL_RED); fl_point(a+10, b+10); fl_point(a+20, b+10);
  51. fl_color(FL_BLACK); fl_xyline(a+10, b+10, a+20);
  52. // testing fl_xyline(x, y, x1, y2);
  53. fl_color(FL_RED); fl_point(a+10, b+20); fl_point(a+20, b+20);
  54. fl_point(a+20, b+30);
  55. fl_color(FL_BLACK); fl_xyline(a+10, b+20, a+20, b+30);
  56. // testing fl_xyline(x, y, x1, y2, x3);
  57. fl_color(FL_RED); fl_point(a+10, b+40); fl_point(a+20, b+40);
  58. fl_point(a+20, b+50); fl_point(a+30, b+50);
  59. fl_color(FL_BLACK); fl_xyline(a+10, b+40, a+20, b+50, a+30);
  60. //+++ add testing for the fl_yxline commands!
  61. // testing fl_loop(x,y, x,y, x,y, x, y)
  62. fl_color(FL_RED); fl_point(a+60, b+60); fl_point(a+90, b+60);
  63. fl_point(a+60, b+90); fl_point(a+90, b+90);
  64. fl_color(FL_BLACK);
  65. fl_loop(a+60, b+60, a+90, b+60, a+90, b+90, a+60, b+90);
  66. }
  67. };
  68. UnitTest lines("drawing lines", LineTest::create);
  69. //
  70. // End of "$Id: unittest_lines.cxx 7913 2010-11-29 18:18:27Z greg.ercolano $"
  71. //