/core/externals/google-toolbox-for-mac/AppKit/GTMLinearRGBShading.h

http://macfuse.googlecode.com/ · C++ Header · 76 lines · 18 code · 7 blank · 51 comment · 0 complexity · 792bd005a3ff8eeb1cfa6268c9c00a58 MD5 · raw file

  1. //
  2. // GTMLinearRGBShading.h
  3. //
  4. // Copyright 2006-2008 Google Inc.
  5. //
  6. // Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7. // use this file except in compliance with the License. You may obtain a copy
  8. // of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15. // License for the specific language governing permissions and limitations under
  16. // the License.
  17. //
  18. #import <Cocoa/Cocoa.h>
  19. #import "GTMShading.h"
  20. #import "GTMCalculatedRange.h"
  21. /// A shading that does returns smooth linear values for RGB.
  22. //
  23. /// Thus if you create a shading from 0.0->red to 1.0->blue you will get
  24. /// \verbatim
  25. /// - 0.5->purple
  26. /// - 0.75->eggplant
  27. /// - 0.25->magenta
  28. /// \endverbatim
  29. @interface GTMLinearRGBShading : GTMCalculatedRange <GTMShading> {
  30. @private
  31. CGFunctionRef function_; // function used to calculated shading (STRONG)
  32. CGColorSpaceRef colorSpace_; // colorspace used for shading (STRONG)
  33. BOOL isCalibrated_; // are we using calibrated or device RGB.
  34. CGFloat colorValue_[4]; // the RGBA color values
  35. }
  36. /// Generate a shading with color |begin| at position 0.0 and color |end| at 1.0.
  37. //
  38. // Args:
  39. // begin: color at beginning of range
  40. // end: color at end of range
  41. // colorSpaceName: name of colorspace to draw into must be either
  42. // NSCalibratedRGBColorSpace or NSDeviceRGBColorSpace
  43. //
  44. // Returns:
  45. // a GTMLinearRGBShading
  46. + (id)shadingFromColor:(NSColor *)begin toColor:(NSColor *)end
  47. fromSpaceNamed:(NSString*)colorSpaceName;
  48. /// Generate a shading with a collection of colors at various positions.
  49. //
  50. // Args:
  51. // colors: a C style array containg the colors we are adding
  52. // colorSpaceName: name of colorspace to draw into must be either
  53. // NSCalibratedRGBColorSpace or NSDeviceRGBColorSpace
  54. // positions: a C style array containg the positions we want to
  55. // add the colors at
  56. // numberOfColors: how many colors/positions we are adding
  57. //
  58. // Returns:
  59. // a GTMLinearRGBShading
  60. + (id)shadingWithColors:(NSColor **)colors
  61. fromSpaceNamed:(NSString*)colorSpaceName
  62. atPositions:(CGFloat *)positions
  63. count:(NSUInteger)numberOfColors;
  64. /// Designated initializer
  65. // Args:
  66. // colorSpaceName - name of the colorspace to use must be either
  67. // NSCalibratedRGBColorSpace or NSDeviceRGBColorSpace
  68. - (id)initWithColorSpaceName:(NSString*)colorSpaceName;
  69. @end