This tutorial create color gradient white to yellow by drawing horizontal lines. Each line has a different color value. Download This Tutorials

## Bookmark:

The RGB macro selects a red, green, blue (RGB) color based on the arguments supplied and the color capabilities of the output device. The intensity for each argument is in the range 0 through 255. If all three intensities are zero, the result is black. If all three intensities are 255, the result is white. This example simply draws lines horizontally with different color values. At startup create the color gradient.

```procedure TForm1.FormCreate(Sender: TObject);
Var
C, R, H, W : Integer;
Step : Real;
begin
{ Get form size }
H:=Image1.Height;
W:=Image1.Width;
{ Set fill step size }
Step:=255/H;
C:=0;
For R:=0 To H Do
Begin
{ Select color for gradient starting from white to yellow }

{ The RGB macro selects a red, green, blue (RGB) color
based on the arguments supplied and the color capabilities
of the output device.

The intensity for each argument is in the range 0 through 255.
If all three intensities are zero, the result is black.
If all three intensities are 255, the result is white.}
Image1.Canvas.Pen.Color:=RGB(255,255,255-C);

{ Fill area by drawing lines }

{ Changes the current drawing position to the point (X,Y).
Use MoveTo to set the value of PenPos before calling LineTo.
Calling MoveTo is equivalent to setting the PenPos property.}
Image1.Canvas.MoveTo(0,R);

{ Draws a line on the canvas from PenPos to the point specified
by X and Y, and sets the pen position to (X, Y). }
Image1.Canvas.LineTo(W,R);

{ Chenge fill color }
C:=Round(R*Step);
End;
end;
``` color-gradient.zip
{"ft_lang_label":"__label__en","ft_lang_prob":0.70478946,"math_prob":0.93619806,"size":1905,"snap":"2022-27-2022-33","text_gpt3_token_len":471,"char_repetition_ratio":0.116254605,"word_repetition_ratio":0.32362458,"special_character_ratio":0.26194227,"punctuation_ratio":0.19804402,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9592458,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,null,null,4,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-02T09:17:00Z\",\"WARC-Record-ID\":\"<urn:uuid:6c7a0ff3-9219-4ac3-8bb0-eef9c4c0828a>\",\"Content-Length\":\"14030\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:176b7264-2a3e-4903-a274-224c87fb405c>\",\"WARC-Concurrent-To\":\"<urn:uuid:f874e97d-eaba-4206-98e2-8a16479e9db9>\",\"WARC-IP-Address\":\"104.21.14.14\",\"WARC-Target-URI\":\"http://www.digitalcoding.com/tutorials/delphi/Create-color-gradient.html\",\"WARC-Payload-Digest\":\"sha1:Q3U5HSHEHZOM3OLTZBTAAGT4SOVPNVYG\",\"WARC-Block-Digest\":\"sha1:RP6MOMJJVKZWWMNZ2ZDBH44KMCIZPBIU\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103989282.58_warc_CC-MAIN-20220702071223-20220702101223-00507.warc.gz\"}"}