reflected-stroke.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright © 2008 Chris Wilson
  3. *
  4. * Permission to use, copy, modify, distribute, and sell this software
  5. * and its documentation for any purpose is hereby granted without
  6. * fee, provided that the above copyright notice appear in all copies
  7. * and that both that copyright notice and this permission notice
  8. * appear in supporting documentation, and that the name of
  9. * the author not be used in advertising or publicity pertaining to
  10. * distribution of the software without specific, written prior
  11. * permission. The author makes no representations about the
  12. * suitability of this software for any purpose. It is provided "as
  13. * is" without express or implied warranty.
  14. *
  15. * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  16. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. * FITNESS, IN NO EVENT SHALL THE AUTHOR. BE LIABLE FOR ANY SPECIAL,
  18. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  19. * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
  21. * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22. *
  23. * Author: Chris Wilson <chris@chris-wilson.co.uk>
  24. */
  25. #include "cairo-test.h"
  26. static void
  27. draw_symbol (cairo_t *cr)
  28. {
  29. double dash[] = {6, 3};
  30. cairo_rectangle (cr, -25, -25, 50, 50);
  31. cairo_stroke (cr);
  32. cairo_move_to (cr, 0, -25);
  33. cairo_curve_to (cr, 12.5, -12.5, 12.5, -12.5, 0, 0);
  34. cairo_curve_to (cr, -12.5, 12.5, -12.5, 12.5, 0, 25);
  35. cairo_curve_to (cr, 12.5, 12.5, 12.5, 12.5, 0, 0);
  36. cairo_stroke (cr);
  37. cairo_save (cr);
  38. cairo_set_dash (cr, dash, ARRAY_LENGTH (dash), 0.);
  39. cairo_move_to (cr, 0, 0);
  40. cairo_arc (cr, 0, 0, 12.5, 0, 3 * M_PI / 2);
  41. cairo_close_path (cr);
  42. cairo_stroke (cr);
  43. cairo_restore (cr);
  44. }
  45. static cairo_test_status_t
  46. draw (cairo_t *cr, int width, int height)
  47. {
  48. cairo_set_source_rgb (cr, 1, 1, 1);
  49. cairo_paint (cr);
  50. cairo_set_source_rgb (cr, 0, 0, 0);
  51. cairo_save (cr);
  52. cairo_translate (cr, 50, 50);
  53. cairo_scale (cr, 1, 1);
  54. draw_symbol (cr);
  55. cairo_restore (cr);
  56. cairo_save (cr);
  57. cairo_translate (cr, 150, 50);
  58. cairo_scale (cr, -1, 1);
  59. draw_symbol (cr);
  60. cairo_restore (cr);
  61. cairo_save (cr);
  62. cairo_translate (cr, 150, 150);
  63. cairo_scale (cr, -1, -1);
  64. draw_symbol (cr);
  65. cairo_restore (cr);
  66. cairo_save (cr);
  67. cairo_translate (cr, 50, 150);
  68. cairo_scale (cr, 1, -1);
  69. draw_symbol (cr);
  70. cairo_restore (cr);
  71. return CAIRO_TEST_SUCCESS;
  72. }
  73. CAIRO_TEST (reflected_stroke,
  74. "Exercises the stroker with a reflected ctm",
  75. "stroke, transform", /* keywords */
  76. NULL, /* requirements */
  77. 200, 200,
  78. NULL, draw)