Browse Prior Art Database

Smooth Color Gradient Fills between Display Colors

IP.com Disclosure Number: IPCOM000118661D
Original Publication Date: 1997-May-01
Included in the Prior Art Database: 2005-Apr-01
Document File: 4 page(s) / 111K

Publishing Venue

IBM

Related People

Smith, A: AUTHOR

Abstract

In color graphics applications, it is desirable to create a filled area that transitions from one color to another in very smooth steps, particularly where the number of solid colors available is limited. Limitation of solid colors is common. For example, the standard Video Graphics Array/Adapter (VGA) color depth is 256 colors, and Super VGA typically only goes to 65536 colors.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 43% of the total text.

Smooth Color Gradient Fills between Display Colors

      In color graphics applications, it is desirable to create a
filled area that transitions from one color to another in very smooth
steps, particularly where the number of solid colors available is
limited.  Limitation of solid colors is common.  For example, the
standard Video Graphics Array/Adapter (VGA) color depth is 256
colors, and Super VGA typically only goes to 65536 colors.

      Color is typically defined in modern computer systems using
the Red, Green, Blue (RGB) color model.  Using this model, a color is
specified by the amounts of each of these primary colors that
contribute to the color.  A common way of expressing this amount is
by a number in  the range 0 to 255.  For example, the color white is
a combination of 100% red, green, and blue, and would, therefore, be
expressed as (255,  255, 255) in this color model.  Red would be
(255, 0, 0) and yellow (255, 255, 0).

      Since 255 requires 8 bits to represent it, to specify the three
primary colors requires a total of 24-bits, hence, the term 24-bit
color.  A 24-bit color value can be used to express up to 16,777,216
(2 sup 24) unique colors.

      In the solution described, given any two colors, C sub 1 and C
sub 2, the following steps are followed to calculate a suitable
number of increments between the two colors and the RGB value of each
increment:
  1.  Extract the R, G, and B constituent values from
       C sub 1 and C sub 2.
  2.  Calculate the delta for each color plane by subtracting
       the respective colors, so R sub 3 = R sub 1 - R sub 2,
       G sub 3 = G sub 1 - G sub 2, and B sub 3 = B sub 1 - B sub 2.
  3.  Use the largest absolute delta to define the number of
       increments.  The color plane that has the largest delta
       will increment by one, the other two planes will increment
       by their delta divided by the largest delta.
  4.  Loop from C sub 1 to C sub 2 incrementing each color plane
       by the appropriate amount to obtain the RGB value for each
       increment of the loop.

If this is performed for a transition between yellow and red:
  1.  C sub 1 = (R sub 1 255, G sub 1 255, B sub 1 0) and
       C sub 2 = (R sub 2 255, G sub 2 0, B sub 2 0)
  2.  R sub 3 = 255 - 255 = 0, G sub 3 = 255 - 0 = 255,
       B sub 3 = 0 - 0 = 0.
  3.  No. of increments = 255, red increment = 0, green
       increment = 1, blue increment = 0.
  4.  Loop from C sub 1 to C sub 2 incrementing the green
       constituent by 1.
      It can be seen that the maximum number of color transitions
       achieved by this technique is 255.  A refinement would be to
       increment the three color planes individually within the
       main loop to obtain a maximum of 765 transitions.
      In an ideal world, all output devices would support 24-bit
       color...