GradientPattern auf ein Panel malen

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    float Step;
    TRect BandRect;                                   //Panel hat kein Canvas 
    TControlCanvas *PanelCanvas = new TControlCanvas; 
    PanelCanvas->Control=Panel1;
    Step=(float)Panel1->ClientHeight / 256;           //256 Farbbänder

    for(int i=0;i<256;i++)
    {
        BandRect.Left = 0;
        BandRect.Top = (int)(i*Step);
        BandRect.Right = Panel1->ClientWidth + 1;
        BandRect.Bottom = (int)((i+1)*Step);          // horizontale Bänder
        PanelCanvas->Brush->Color = RGB(0, 0, 255-i); // blauer Gradient
        PanelCanvas->FillRect(BandRect);
    }

    delete PanelCanvas;
}

Schreibe einen Kommentar