gradient-constant-alpha.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright © 2005 Red Hat, Inc.
  3. * Copyright © 2008 Chris Wilson
  4. *
  5. * Permission to use, copy, modify, distribute, and sell this software
  6. * and its documentation for any purpose is hereby granted without
  7. * fee, provided that the above copyright notice appear in all copies
  8. * and that both that copyright notice and this permission notice
  9. * appear in supporting documentation, and that the name of
  10. * Red Hat, Inc. not be used in advertising or publicity pertaining to
  11. * distribution of the software without specific, written prior
  12. * permission. Red Hat, Inc. makes no representations about the
  13. * suitability of this software for any purpose. It is provided "as
  14. * is" without express or implied warranty.
  15. *
  16. * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  17. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  18. * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
  19. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  20. * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  21. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
  22. * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23. *
  24. * Author: Carl D. Worth <cworth@cworth.org>
  25. * Chris Wilson <chris@chris-wilson.co.uk>
  26. */
  27. #include "cairo-test.h"
  28. static cairo_test_status_t
  29. draw (cairo_t *cr, int width, int height)
  30. {
  31. cairo_pattern_t *gradient;
  32. gradient = cairo_pattern_create_linear (0, 0,
  33. 0, height);
  34. cairo_pattern_add_color_stop_rgba (gradient, 0.0,
  35. 1.0, 0.0, 0.0,
  36. 0.5);
  37. cairo_pattern_add_color_stop_rgba (gradient, 0.0,
  38. 0.0, 1.0, 0.0,
  39. 0.5);
  40. cairo_pattern_add_color_stop_rgba (gradient, 1.0,
  41. 0.0, 0.0, 1.0,
  42. 0.5);
  43. cairo_set_source (cr, gradient);
  44. cairo_paint (cr);
  45. cairo_pattern_destroy (gradient);
  46. return CAIRO_TEST_SUCCESS;
  47. }
  48. CAIRO_TEST (gradient_constant_alpha,
  49. "Tests drawing of a gradient with constant alpha values in the color stops",
  50. "gradient, alpha", /* keywords */
  51. NULL,
  52. 10, 10,
  53. NULL, draw)