color_set.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include <grass/gis.h>
  2. /* for convenience, but to be avoided if possible */
  3. /*!
  4. * \brief set a category color
  5. *
  6. * The <b>red, green</b>, and
  7. * <b>blue</b> intensities for the color associated with category <b>cat</b>
  8. * are set in the <b>colors</b> structure. The intensities must be in the
  9. * range 0 -­ 255. Values below zero are set as zero, values above 255 are set as
  10. * 255.
  11. * <b>Use of this routine is discouraged because it defeats the new color
  12. * logic.</b> It is provided only for backward compatibility. Overuse can create
  13. * large color tables. <i>G_add_color_rule</i> should be used whenever
  14. * possible.
  15. * <b>Note.</b> The <b>colors</b> structure must have been initialized by
  16. * <i>G_init_color.</i>
  17. *
  18. * \param cat
  19. * \param red
  20. * \param green
  21. * \param blue
  22. * \param colors
  23. * \return
  24. */
  25. void G_set_color(CELL cat, int r, int g, int b, struct Colors *colors)
  26. {
  27. if (G_is_c_null_value(&cat))
  28. G_set_null_value_color(r, g, b, colors);
  29. else
  30. G_add_color_rule(cat, r, g, b, cat, r, g, b, colors);
  31. }
  32. void G_set_d_color(DCELL val, int r, int g, int b, struct Colors *colors)
  33. {
  34. if (G_is_d_null_value(&val))
  35. G_set_null_value_color(r, g, b, colors);
  36. else
  37. G_add_d_raster_color_rule(&val, r, g, b, &val, r, g, b, colors);
  38. }
  39. /*!
  40. * \brief
  41. *
  42. * Sets the color (in <em>colors</em>) for the NULL-value to <em>r,g,b</em>.
  43. *
  44. * \param r
  45. * \param g
  46. * \param b
  47. * \param colors
  48. * \return
  49. */
  50. void G_set_null_value_color(int red, int grn, int blu, struct Colors *colors)
  51. {
  52. colors->null_red = red;
  53. colors->null_grn = grn;
  54. colors->null_blu = blu;
  55. colors->null_set = 1;
  56. }
  57. /*!
  58. * \brief
  59. *
  60. * Sets the default color (in <em>colors</em>) to <em>r,g,b</em>. This is
  61. * the color for values which do not have an explicit rule.
  62. *
  63. * \param r
  64. * \param g
  65. * \param b
  66. * \param colors
  67. * \return
  68. */
  69. void G_set_default_color(int red, int grn, int blu, struct Colors *colors)
  70. {
  71. colors->undef_red = red;
  72. colors->undef_grn = grn;
  73. colors->undef_blu = blu;
  74. colors->undef_set = 1;
  75. }