This application claims the benefit of Korean Patent Application No. 10-2008-0010023 filed with the Korean Intellectual Property Office on Jan. 31, 2008, the disclosures of which are incorporated herein by reference in their entirety.
1. Field of the Invention
The present invention relates to color gradient generating method and device, and more particularly, to color gradient generating method and device for expressing a smooth color variation in a two-dimensional vector graph.
2. Related Art
Methods of expressing colors in a two-dimensional vector graph employ a solid expressing a single color, a gradient expressing a smooth color variation, and a bit map using an image file.
When a user selects a specific area, the selected area can be filled with one or plural colors.
When the selected specific area is filled with plural colors, the plural colors can be automatically mixed. The smooth mixture of the colors is called color gradient.
The color gradient is roughly classified into linear gradients and radial gradients and can be usually generated using line segments.
In
For example, as shown in
With the setting of the line segment 100, a color of a different point in the line segment 100 can be determined by interpolating the specific colors. The interpolation of colors can be carried out in various interpolation methods such as linear interpolation or cubic interpolation.
A color of a different point in the area to be filled is determined to be the same as the color of the closest point in the line segment 100.
The linear gradient 120 is the most basic gradient of all gradients.
The radial gradient 110 can be used to exhibit a slightly more complex effect than the linear gradient 120. A start point and an end point should be selected in the line segment 100 to generate the radial gradient 110.
In the radial gradient 110, similarly to the linear gradient 120, colors correspond to points in the line segment 100 and a color of a middle point in the line segment 100 is determined by interpolating specific colors.
The radial gradient 110 is different from the linear gradient 120, in that a color of a different point in the area to be filled is determined on the basis of a distance from the start point in the line segment 100 in view of the characteristic of circle.
Accordingly, the final radial gradient 110 includes concentric rings of colors smoothly and continuously varying.
Colors are smoothly mixed from the start point in the line segment 100, similarly to the linear gradient 120. The points in different beams starting from the start point are colored in the same method depending on the distance from the start point.
The procedure of generating the known color gradient will be described in detail with reference to
As shown in
The position of which the color should be determined may be a position in a pixel or a position in an area determined in advance by a user.
Two colors to be mixed are checked in the line segment on the basis of the calculated distance (S204) and the distances from the colors to be mixed are calculated (S206).
The color of the position in a pixel is finally determined on the basis of the color calculation result (S208).
The interpolation for determining a color can be performed using the following expression.
The known color gradient generating method of performing the above-mentioned procedure has a problem that the operating time of a graphic processor increases because all gradient colors should be calculated per pixel.
When a color gradient is used in one object, the calculated distances in image coordinates may be equal to each other, that is, the calculation results in step 202 may be equal to each other.
However, even when the distances are equal to each other, the distance calculation in the image coordinates should be performed again.
Therefore, there is a problem that the operating time of the graphic processor and the load of the graphic processor due to the repeated calculation increase.
An advantage of some aspects of the invention is that it provides color gradient generating method and device that can reduce the operating time of a graphic processor.
Another advantage of some aspects of the invention is that it provides color gradient generating method and device that can use a distance calculation performed in image coordinates again when distances are equal to each other.
Another advantage of some aspects of the invention is that it provides color gradient generating method and device that can reduce a load of a graphic processor.
Other advantages of the invention will be easily understood from the following description.
According to an aspect of the invention, there is provided a color gradient generating method.
The color gradient generating method includes the steps of: (a) setting at least two colors in a color table including a plurality of colors as control points; (b) storing interpolated colors between the control points; (c) calculating a distance of a position, a color of which should be determined, in coordinates; and (d) determining one interpolated color corresponding to the calculated distance as a color of the position.
The step of (b) may include storing the interpolated colors to correspond to control points located between the control points. The step of (d) may include the sub-steps: searching for the control point corresponding to the calculated distance; and
reading the color corresponding to the searched control point.
The steps of (c) and (d) may be repeatedly performed on all positions of which the colors should be determined. The color gradient generating method may further include a step of temporarily storing the calculated distance and the determined color. Here, the step of (d) may include reading the temporarily-stored color when the calculated distance in the step of (c) is equal to the temporarily-stored distance.
According to another aspect of the invention, there is provided a color gradient generating device.
The color gradient generating device calculates a distance of a position, a color of which should be determined, in coordinates and determines the color of the position in accordance with the calculated distance. Here, the determined color is one of colors obtained by setting at least two colors as control points in a color table including a plurality of colors and interpolating the colors between the control points.
The interpolated colors may be stored to correspond to control points located between the control points and the color of the position may be determined on the basis of the calculated distance by searching for the control point corresponding to the calculated distance and reading the color corresponding to the searched control point.
The distance calculation in the coordinates and the color determination of the position may be repeatedly performed. The calculated distance and the determined color may be temporarily stored and the temporarily-stored color may be read when a distance calculated in the coordinates is equal to the temporarily-stored distance.
According to another aspect of the invention, there is provided a graphic processor.
The graphic processor includes the above-mentioned color gradient generating device.
According to another aspect of the invention, there is provided a recording medium having recorded thereon a program for executing a color gradient generating method.
Here, the recording medium has recorded thereon a computer-readable program allowing a digital processor to execute the color gradient generating method. The color gradient generating method includes: (a) setting at least two colors in a color table including a plurality of colors as control points; (b) storing interpolated colors between the control points; (c) calculating a distance of a position, a color of which should be determined, in coordinates; and (d) determining one interpolated color corresponding to the calculated distance as a color of the position.
The step of (b) may include storing the interpolated colors to correspond to control points located between the control points. The step of (d) may include the sub-steps: searching for the control point corresponding to the calculated distance; and reading the color corresponding to the searched control point.
The steps of (c) and (d) may be repeatedly performed on all positions of which the colors should be determined. The color gradient generating method may further include a step of temporarily storing the calculated distance and the determined color. Here, the step of (d) may include reading the temporarily-stored color when the calculated distance in the step of (c) is equal to the temporarily-stored distance.
As described above, according to the above-mentioned color gradient generating method and device, it is possible to reduce the operating time of a graphic processor.
It is also possible to reuse the calculation result in the image coordinates.
Accordingly, it is possible to reduce the load of the graphic processor.
The above-mentioned goals, features, and advantages of the invention will be apparent from the following detailed description with reference to the accompanying drawings. The invention can be variously modified in various embodiments and specific embodiments will be described and shown in the drawings. The invention is not limited to the embodiments, but it should be understood that the invention includes all the modifications, equivalents, and replacements belonging to the spirit and the technical scope of the invention.
Like reference numerals reference like elements in the drawings. When it is determined that detailed description of known techniques associated with the invention makes the gist of the invention obscure, the detailed description will be omitted.
Terms, “first”, “second”, and the like, can be used to describe various elements, but the elements are not limited to the terms. The terms are used only to distinguish one element from another element.
The terms used in the following description are used to merely describe specific embodiment, but are not intended to limit the invention. An expression of the singular number includes an expression of the plural number, so long as it is clearly read differently. The terms such as “include”, “have”, and the like are intended to indicate that features, numbers, steps, operations, elements, components, or combinations thereof used in the following description exist and that the possibility of existence or addition of one or more different features, numbers, steps, operations, elements, components, or combinations thereof is not excluded.
Hereinafter, exemplary embodiments of the invention will be described in detail with reference to the accompanying drawings.
In an embodiment of the invention, a color table is used to generate a color gradient, so as to reduce the amount of calculation of a graphic processor.
A procedure of generating a color table used in the embodiment of the invention will be described with reference to
The color table that can be used to generate a color gradient includes plural colors, which can be generated using two or more colors as control points.
Interpolated colors are filled between the control points in the color table to generate the color data and the generated color data is stored in a storage unit such as a memory.
In
Then, interpolated color data between red and green is generated between ratio 0 and ratio 128 and is stored in the memory. Interpolated color data between green and violet is generated between ratio 128 and ratio 255 and is stored in the memory.
For example, the colors are determined in such a manner that red is set to ratio 0, a color in which a slight amount of green is mixed with red is set to ratio 1, and a color in which a slight more amount of green is mixed is set to ratio 2. Accordingly, when a value of a color is ratio 128, the corresponding color is green.
The color data generated and stored in the memory is used to generate a gradient.
A procedure of generating a gradient using the color data stored in the memory will be described now with reference to
As shown in
As described above, the position of which the color should be determined may be a position in a pixel or a position in an area determined in advance by a user.
The calculated distance is used as an address in a cache memory included in a graphic processor (S404) and a color having a value corresponding to the calculated distance is extracted from the memory (S406).
For example, when the color value corresponding to the calculated distance is a value corresponding to ratio 128 between control point 0 and control point 128 in
On the other hand, in the past, two colors to be mixed were checked in the line segment on the basis of the calculated distance, distances from the colors to be mixed were calculated, and then the color of the position was determined in accordance with the calculation result.
However, in the invention, since the color data corresponding to distances calculated in advance is stored in the memory and the corresponding color data is read from the memory on the basis of the calculated distance, the calculation process of determining a color can be omitted.
In the invention, since a color corresponding to the calculated distance is extracted from the memory using the calculated distance as an address in the cache memory of the graphic processor, the color data stored in the cache memory can be utilized for the same position, that is, the same distance.
Therefore, the graphic processor need not perform again the procedure of checking two colors to be mixed in the line segment on the basis of the calculated distance and calculating the distances from the colors to be mixed.
The digital processor including the graphic processor which has the gradient generating device according to the embodiment of the invention includes a graphic processor 500, a host processor 510, and a memory 520.
The graphic processor 500 includes the gradient generating device 504 according to the embodiment of the invention and the gradient generating device 504 is connected to the cache memory 502 of the graphic processor 500.
The graphic processor 500 is a logical circuit processing image information of the digital processor and displaying the processed information on a screen. The host processor 510 is a logical circuit processing commands for basic operations of the digital processor.
The gradient generating device 504 of the graphic processor 500 generates a color gradient in an area using color data stored in the memory 520 and the cache memory 502 of the graphic processor 500, as described above.
The cache memory 502 is a storage unit temporarily storing data to be processed by the graphic processor 500 and may temporarily store the color, which is extracted from the memory 520, corresponding to the calculated distance of a position of which the color should be determined.
The calculated distance of the position of which the color should be determined can be used as an address in the cache memory 502.
The memory 520 is a storage unit storing data to be processed by the digital processor and particularly stores color data used to generate a gradient in the embodiment of the invention.
In the digital processor having the above-mentioned configuration, color data set in advance to generate a color gradient of an area is stored in the memory. The color used to generate the color gradient of a position in the area is determined by reading the corresponding color data from the memory.
The calculated is used as an address in the cache memory of the graphic processor and the color data stored in the cache memory can be used for the same position, that is, the same distance value, thereby reducing the processing time and the processing load of the graphic processor 500.
Although the invention has been described with reference to the exemplary embodiments, it will be understood by those skilled in the art that the invention can be modified and changed in various forms without departing from the spirit and scope of the invention described in the appended claims and the modifications and changes belong to the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
10-2008-0010023 | Jan 2008 | KR | national |